API reference
Every operation is a Firebase callable behind one wrapper: authentication, App Check, input parsing, correlation ids, rate limits and error translation happen above the handler. Two inbound webhooks are the only HTTP endpoints.
Transport
Callables are invoked with the Firebase client SDK; the web app wraps it once.
import { callFunction } from "@/lib/firebase/functions";
// One transport. Server taxonomy codes are preserved end-to-end.
const decision = await callFunction<
{ executionId: string; mode: "hybrid"; modelId: string; estimatedTokens: number },
{ executionId: string; allowed: boolean; reservedTokens: number; remaining: number | null }
>("beginInferenceExecution", {
executionId: "x_01J8Z3K4",
mode: "hybrid",
modelId: "gemini-3.8-flash",
estimatedTokens: 8000,
});The REST contract table in docs/API_CONTRACTS.md describes a future HTTP façade. It is not deployed: there are no /api/v1 routes in this repository. The authoritative surface is the callables below.
HTTP endpoints exist only where a provider must call in: fiatWebhook (payment provider) and workflowWebhook (inbound workflow trigger). Both verify a shared secret before doing anything.
Authorization model
Resolved from the caller's verified token and memberships, never from request fields.
- Authentication
- A verified ID token is required unless the callable is explicitly unauthenticated (the SSO entry points).
- Tenant authorization
- An orgId in the request is checked against the caller's memberships and required role set on every call.
- Entitlements
- Gated operations check the organisation's active entitlements in the same request; absence returns ENTITLEMENT_DENIED with the missing key.
- App Check
- When enforcement is on, a valid App Check token is required; 46 callables additionally consume a single-use token.
Errors
Handlers fail only through the taxonomy. The client keeps the server's code.
{
"code": "ENTITLEMENT_DENIED",
"message": "The cloud entitlement is not active for this organisation.",
"recovery": "upgrade_plan",
"retryable": false,
"correlationId": "tr_01J8Z3K4"
}Codes are stable surface: they are persisted in audit events and compared by telemetry. The web app publishes the same taxonomy in src/lib/domain/errors.ts, with explanation and recovery text for each code.
Callables by module
Names exactly as exported from functions/src/index.ts. Selected callables grouped by module — scheduled triggers and Firestore/Storage event handlers are separate exports and are not listed here.
| Module | Callables |
|---|---|
| Identity | bootstrapUserProfile, setUserPreferences |
| Organizations | createOrganization, inviteMember, acceptInvitation, setMemberRoles, removeMember, transferOwnership, createTeam, listMembers, resendInvitation, cancelInvitation, requestOrgDeletion, cancelOrgDeletion, updateTeam, deleteTeam, addTeamMembers, removeTeamMembers |
| Roles | createCustomRole, updateCustomRole, deleteCustomRole |
| Entitlements | checkEntitlement, grantEntitlement, revokeEntitlement |
| Usage | recordUsageEvent, getUsageSummary |
| Inference | beginInferenceExecution, completeInferenceExecution |
| Agents | assertAgentRunAllowed, startAgentRun, approveAgentRunStep, cancelAgentRun |
| Workflows | validateWorkflow, publishWorkflow, startWorkflowRun, approveWorkflowStep, cancelWorkflowRun |
| Knowledge | retrieveKnowledge |
| Search | searchOrg |
| Integrations | listIntegrations, beginIntegrationConnect, completeIntegrationCallback, disconnectIntegration, testIntegration, listIntegrationHealth, checkIntegrationHealth |
| Payments | createPaymentIntent, verifyEvmPayment, verifySolanaPayment |
| Billing | changeSubscription |
| SSO | configureSso, beginSsoLogin, completeSsoCallback, checkPasswordAuthAllowed |
| Domain claims | claimDomain, verifyDomainClaim, removeDomainClaim |
| Projects | createProject, updateProject, archiveProject, addProjectMembers, removeProjectMembers, transferProjectOwnership |
| Collections | shareCollection, revokeShare, listOrgActivity |
| Privacy | requestAccountExport, exportOrgData, requestAccountDeletion, setLegalHold |
| Notifications | registerDeviceToken, removeDeviceToken |
| Voice | setVoiceConsent, transcribeAudio, synthesizeSpeech, listVoices |
| Admin | listTenants, getTenantDetail, suspendTenant, reinstateTenant, listUsers, setUserStatus, listIncidents, getStatusSummary, getClientConfig, setFeatureFlag |
Rate limits
One transaction charges a per-user and a per-organisation bucket; refusal is RATE_LIMITED, never fail-open.
| Tier | Per user | Per org |
|---|---|---|
| callable.read | 60/min | 600/min |
| callable.write | 20/min | 200/min |
| inference.begin | 30/min, 300/hour | 300/min, 3000/hour |
| search | 30/min | 300/min |
| workflow.start | 10/min | 100/min |
| payment.intent | 5/min | 50/min |
| integration.connect | 5/hour | 50/hour |
| upload.sign | 20/min | 200/min |
Idempotency
Operations that move money or budget take a client-chosen identifier: beginInferenceExecution keys on executionId and returns alreadyStarted on a retry; payment settlement derives a deterministic ledger id per intent and transaction. Stateless reads need none; startAgentRun and startWorkflowRun create a new run per call by design.
Read a module contract
The agent and integration guides drill into the two surfaces with the most moving parts.