{"openapi":"3.1.0","info":{"title":"Saperly API","version":"0.1.0","description":"Capability interface surface for Saperly. Slug-in-path workspace routes for the dashboard, an org-from-token (sk_) data plane for agents (numbers, connections, messaging, voice, voices, languages, usage, consent, pricing), scoped key provisioning (a keys:admin key mints ceiling-bounded child keys), and the assistant — all over the same capability layer. The MCP server is a separate JSON-RPC 2.0 surface at /mcp (not part of this OpenAPI contract)."},"paths":{"/health":{"get":{"tags":["health"],"operationId":"health.check","parameters":[],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["ok"]}},"required":["status"],"additionalProperties":false}}}}},"summary":"Liveness probe"}},"/workspaces/{slug}/members":{"get":{"tags":["workspace"],"operationId":"workspace.members","parameters":[{"name":"slug","in":"path","schema":{"type":"string","description":"The workspace's URL slug."},"required":true}],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"email":{"type":"string"},"image":{"anyOf":[{"type":"string"},{"type":"null"}]},"role":{"type":"string","enum":["owner","admin","member"]},"systemRole":{"type":"string","enum":["admin","user"]}},"required":["id","name","email","image","role","systemRole"],"additionalProperties":false}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"404":{"description":"WorkspaceNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkspaceNotFound"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}}},"summary":"List the workspace members"}},"/workspaces/{slug}/api-tokens":{"get":{"tags":["workspace"],"operationId":"workspace.api-tokens","parameters":[{"name":"slug","in":"path","schema":{"type":"string","description":"The workspace's URL slug."},"required":true}],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"token":{"type":"string"},"prefix":{"type":"string"},"scopes":{"type":"array","items":{"type":"string","enum":["read","write","admin"]}},"lastUsedAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"createdAt":{"type":"string"},"numberScope":{"anyOf":[{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"null"}]},{"type":"null"}]},"spendLimitCents":{"anyOf":[{"anyOf":[{"type":"number"},{"type":"null"}]},{"type":"null"}]},"spendLimitResetPeriod":{"anyOf":[{"anyOf":[{"type":"string","enum":["monthly"]},{"type":"null"}]},{"type":"null"}]},"spentThisPeriodCents":{"anyOf":[{"anyOf":[{"type":"number"},{"type":"null"}]},{"type":"null"}]},"canProvisionKeys":{"anyOf":[{"type":"boolean"},{"type":"null"}]},"permissions":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"null"}]},"mintedByTokenId":{"anyOf":[{"anyOf":[{"type":"string"},{"type":"null"}]},{"type":"null"}]}},"required":["id","name","token","prefix","scopes","lastUsedAt","createdAt"],"additionalProperties":false}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"404":{"description":"WorkspaceNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkspaceNotFound"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}}},"summary":"List the workspace API tokens"},"post":{"tags":["api-token-registry"],"operationId":"api-token-registry.create","parameters":[{"name":"slug","in":"path","schema":{"type":"string","description":"The workspace's URL slug."},"required":true}],"security":[],"responses":{"201":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"prefix":{"type":"string"},"scopes":{"type":"array","items":{"type":"string","enum":["read","write","admin"]}},"lastUsedAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"createdAt":{"type":"string"},"token":{"type":"string"}},"required":["id","name","prefix","scopes","lastUsedAt","createdAt","token"],"additionalProperties":false}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"404":{"description":"WorkspaceNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkspaceNotFound"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}}},"summary":"Create a scoped API token","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","allOf":[{"minLength":1},{"maxLength":100}]},"scopes":{"type":"array","items":{"type":"string","enum":["read","write","admin"]},"allOf":[{"minItems":1},{"maxItems":3}]},"numberScope":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"null"}]},"spendLimitCents":{"anyOf":[{"type":"number","allOf":[{"minimum":1}]},{"type":"null"}]},"spendLimitResetPeriod":{"anyOf":[{"anyOf":[{"type":"string","enum":["monthly"]},{"type":"null"}]},{"type":"null"}]}},"required":["name","scopes"],"additionalProperties":false,"description":"The new token: a display `name`, the `scopes` it may exercise, an optional `numberScope` allow-list of phone-number ids, and an optional per-key `spendLimitCents` cap (with `spendLimitResetPeriod`). The full secret is returned once on create."}}},"required":true}}},"/workspaces/{slug}/webhooks":{"get":{"tags":["workspace"],"operationId":"workspace.webhooks","parameters":[{"name":"slug","in":"path","schema":{"type":"string","description":"The workspace's URL slug."},"required":true}],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"url":{"type":"string","description":"The HTTPS URL Saperly POSTs each subscribed event to."},"enabled":{"type":"boolean"},"events":{"type":"array","items":{"type":"string"},"description":"The event types this endpoint is subscribed to."},"successRate":{"type":"number","allOf":[{"description":"Delivery success rate (0–100) over all recorded attempts for this endpoint; 100 when there are none yet."}]},"signingSecret":{"type":"string","description":"The endpoint signing secret (`whsec_…`). Verify each delivery by recomputing HMAC-SHA256 over `${x-saperly-timestamp}.${rawBody}` and comparing (constant-time) against the hex in the `x-saperly-signature: v1=<hex>` header."}},"required":["id","url","enabled","events","successRate","signingSecret"],"additionalProperties":false}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"404":{"description":"WorkspaceNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkspaceNotFound"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}}},"description":"Returns every webhook endpoint for the workspace, each including its full `signingSecret` (`whsec_…`) — the reveal surface, so the secret can be re-copied at any time to verify delivery signatures.","summary":"List the workspace webhook endpoints"},"post":{"tags":["workspace"],"operationId":"workspace.create-webhook","parameters":[{"name":"slug","in":"path","schema":{"type":"string","description":"The workspace's URL slug."},"required":true}],"security":[],"responses":{"201":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"url":{"type":"string","description":"The HTTPS URL Saperly POSTs each subscribed event to."},"enabled":{"type":"boolean"},"events":{"type":"array","items":{"type":"string"},"description":"The event types this endpoint is subscribed to."},"successRate":{"type":"number","allOf":[{"description":"Delivery success rate (0–100) over all recorded attempts for this endpoint; 100 when there are none yet."}]},"signingSecret":{"type":"string","description":"The endpoint signing secret (`whsec_…`). Verify each delivery by recomputing HMAC-SHA256 over `${x-saperly-timestamp}.${rawBody}` and comparing (constant-time) against the hex in the `x-saperly-signature: v1=<hex>` header."}},"required":["id","url","enabled","events","successRate","signingSecret"],"additionalProperties":false}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"404":{"description":"WorkspaceNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkspaceNotFound"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}}},"description":"Registers an outbound webhook endpoint and returns it with its full `signingSecret`. Use the secret to verify each delivery’s `x-saperly-signature: v1=<hex>` header (HMAC-SHA256 over `${x-saperly-timestamp}.${rawBody}`).","summary":"Create a webhook endpoint","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string","allOf":[{"minLength":1},{"maxLength":2048,"description":"The HTTPS URL Saperly will POST each subscribed event to."}]},"events":{"type":"array","items":{"type":"string"},"allOf":[{"minItems":1,"description":"The event types this endpoint subscribes to (e.g. `call.completed`, `message.received`). At least one."}]},"description":{"anyOf":[{"type":"string","allOf":[{"maxLength":500,"description":"An optional human label for the endpoint."}]},{"type":"null"}]}},"required":["url","events"],"additionalProperties":false,"description":"The new endpoint: the HTTPS `url` to POST events to, the `events` it subscribes to, and an optional `description`. The response includes the generated `signingSecret`."}}},"required":true}}},"/workspaces/{slug}/webhooks/{webhookId}/deliveries":{"get":{"tags":["workspace"],"operationId":"workspace.webhook-deliveries","parameters":[{"name":"slug","in":"path","schema":{"type":"string","description":"The URL-safe slug identifying the workspace."},"required":true},{"name":"webhookId","in":"path","schema":{"type":"string","description":"The id of the webhook endpoint whose delivery history to read."},"required":true}],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"eventType":{"type":"string","description":"The event type that was delivered (e.g. `call.completed`)."},"status":{"type":"string","description":"The attempt outcome: `delivered` (a 2xx) or `failed`."},"attempts":{"type":"number","allOf":[{"description":"The global attempt number: 1 for the inline first attempt, ≥2 for a queued retry."}]},"responseStatus":{"anyOf":[{"type":"number"},{"type":"null"}],"description":"The HTTP status the receiver returned, or `null`/`0` when the request never got one (DNS/TLS/timeout — e.g. 530 = the receiver's origin/tunnel is unreachable)."},"lastAttemptAt":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"ISO timestamp of this attempt."},"nextAttemptAt":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"ISO timestamp of the next scheduled retry, or `null` when none is pending."}},"required":["id","eventType","status","attempts","responseStatus","lastAttemptAt","nextAttemptAt"],"additionalProperties":false}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"404":{"description":"WorkspaceNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkspaceNotFound"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}}},"description":"Returns the endpoint's most recent delivery attempts (newest first), each with the event type, outcome (`delivered`/`failed`), HTTP `responseStatus`, attempt number, and timestamps — so you can see exactly why a delivery did or didn't land (e.g. a run of `failed` with `responseStatus: 530` means your receiver is unreachable).","summary":"List a webhook endpoint's recent delivery attempts"}},"/workspaces/{slug}/audit-events":{"get":{"tags":["workspace"],"operationId":"workspace.audit-events","parameters":[{"name":"slug","in":"path","schema":{"type":"string","description":"The workspace's URL slug."},"required":true}],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"eventType":{"type":"string"},"targetType":{"type":"string"},"actor":{"type":"string"},"createdAt":{"type":"string"}},"required":["id","eventType","targetType","actor","createdAt"],"additionalProperties":false}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"404":{"description":"WorkspaceNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkspaceNotFound"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}}},"summary":"List the workspace audit-log events"}},"/workspaces/{slug}/api-tokens/{tokenId}/revoke":{"post":{"tags":["api-token-registry"],"operationId":"api-token-registry.revoke","parameters":[{"name":"slug","in":"path","schema":{"type":"string","description":"The URL-safe slug identifying the workspace."},"required":true},{"name":"tokenId","in":"path","schema":{"type":"string","description":"The id of the API token to revoke."},"required":true}],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["revoked"]}},"required":["status"],"additionalProperties":false}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"404":{"description":"WorkspaceNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkspaceNotFound"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}}},"summary":"Revoke an API token"}},"/workspaces/{slug}/invitations":{"post":{"tags":["workspace-invitations"],"operationId":"workspace-invitations.send","parameters":[{"name":"slug","in":"path","schema":{"type":"string","description":"The workspace's URL slug."},"required":true}],"security":[],"responses":{"202":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["queued"]},"delivery":{}},"required":["status","delivery"],"additionalProperties":false}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"404":{"description":"WorkspaceNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkspaceNotFound"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}}},"summary":"Invite a member by email","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"to":{"type":"string","allOf":[{"minLength":3},{"maxLength":320},{"pattern":"^[^\\s@]+@[^\\s@]+$","description":"The email address to send the workspace invitation to."}]}},"required":["to"],"additionalProperties":false,"description":"The invitee for a new workspace invitation."}}},"required":true}}},"/assistant/answer":{"post":{"tags":["assistant"],"operationId":"assistant.answer","parameters":[],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"answer":{"type":"string"},"provider":{"type":"string","enum":["workers-ai","openai-compatible","mock"]},"modelId":{"type":"string"},"usedTools":{"type":"array","items":{"type":"string"}},"assistantConfigured":{"type":"boolean"}},"required":["answer","provider","modelId","usedTools","assistantConfigured"],"additionalProperties":false}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}},"503":{"description":"AssistantUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssistantUnavailable"}}}}},"summary":"Ask the workspace assistant a question","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"workspaceSlug":{"type":"string","allOf":[{"minLength":1},{"maxLength":100}]},"question":{"type":"string","allOf":[{"minLength":1},{"maxLength":2000}]}},"required":["workspaceSlug","question"],"additionalProperties":false,"description":"The workspace to answer for (`workspaceSlug`) and the natural-language `question` to answer."}}},"required":true}}},"/numbers":{"get":{"tags":["numbers"],"operationId":"numbers.list","parameters":[],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"phoneNumber":{"type":"string"},"connectionId":{"anyOf":[{"type":"string"},{"type":"null"}]},"webhookUrl":{"anyOf":[{"type":"string"},{"type":"null"}]},"smsSenderId":{"anyOf":[{"type":"string"},{"type":"null"}]},"callerIdName":{"anyOf":[{"type":"string"},{"type":"null"}]},"country":{"anyOf":[{"type":"string"},{"type":"null"}]},"numberType":{"anyOf":[{"type":"string"},{"type":"null"}]},"monthlyPriceCents":{"anyOf":[{"type":"number"},{"type":"null"}]},"currency":{"anyOf":[{"type":"string"},{"type":"null"}]},"nextChargeAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"releasedAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"createdAt":{"type":"string"}},"required":["id","phoneNumber","connectionId","webhookUrl","country","numberType","monthlyPriceCents","currency","nextChargeAt","releasedAt","createdAt"],"additionalProperties":false}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}}},"summary":"List all phone numbers in the workspace"},"post":{"tags":["numbers"],"operationId":"numbers.provision","parameters":[],"security":[],"responses":{"201":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"phoneNumber":{"type":"string"},"connectionId":{"anyOf":[{"type":"string"},{"type":"null"}]},"webhookUrl":{"anyOf":[{"type":"string"},{"type":"null"}]},"smsSenderId":{"anyOf":[{"type":"string"},{"type":"null"}]},"callerIdName":{"anyOf":[{"type":"string"},{"type":"null"}]},"country":{"anyOf":[{"type":"string"},{"type":"null"}]},"numberType":{"anyOf":[{"type":"string"},{"type":"null"}]},"monthlyPriceCents":{"anyOf":[{"type":"number"},{"type":"null"}]},"currency":{"anyOf":[{"type":"string"},{"type":"null"}]},"nextChargeAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"releasedAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"createdAt":{"type":"string"}},"required":["id","phoneNumber","connectionId","webhookUrl","country","numberType","monthlyPriceCents","currency","nextChargeAt","releasedAt","createdAt"],"additionalProperties":false}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"402":{"description":"InsufficientFunds | PaymentMethodRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/InsufficientFunds"},{"$ref":"#/components/schemas/PaymentMethodRequired"}]}}}},"403":{"description":"AuthorizationDenied | CountryNotAvailable","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/AuthorizationDenied"},{"$ref":"#/components/schemas/CountryNotAvailable"}]}}}},"404":{"description":"NoNumbersAvailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NoNumbersAvailable"}}}},"409":{"description":"NumberQuotaExceeded | PriceChanged | IdempotencyConflict","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/NumberQuotaExceeded"},{"$ref":"#/components/schemas/PriceChanged"},{"$ref":"#/components/schemas/IdempotencyConflict"}]}}}},"422":{"description":"IdempotencyKeyMismatch","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IdempotencyKeyMismatch"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}},"502":{"description":"UpstreamError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpstreamError"}}}}},"summary":"Provision a phone number","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"country":{"anyOf":[{"type":"string","description":"ISO 3166-1 alpha-2 country code to provision a number in (e.g. `US`, `GB`). Defaults to `US`."},{"type":"null"}]},"numberType":{"anyOf":[{"type":"string","description":"The kind of number to provision (e.g. `local`, `toll_free`, `mobile`, `national`). Defaults to `local`."},{"type":"null"}]},"areaCode":{"anyOf":[{"type":"string","description":"Preferred area code / city prefix to search within the country (e.g. `415`). Omit to take any available number."},{"type":"null"}]},"expectedMonthlyPriceCents":{"anyOf":[{"type":"number","allOf":[{"description":"The monthly price (in cents) you quoted to the customer. If the live order price exceeds it, provision fails with `PriceChanged` instead of charging — resubmit with `approveHigherPrice: true` to accept the higher price."}]},{"type":"null"}]},"expectedUpfrontPriceCents":{"anyOf":[{"type":"number","allOf":[{"description":"The one-time upfront price (in cents) you quoted to the customer. If the live order price exceeds it, provision fails with `PriceChanged` instead of charging — resubmit with `approveHigherPrice: true` to accept the higher price."}]},{"type":"null"}]},"approveHigherPrice":{"anyOf":[{"type":"boolean","description":"Set true to accept a live order price higher than the `expected*` values you quoted, instead of failing with `PriceChanged`."},{"type":"null"}]}},"additionalProperties":false}}},"required":true}}},"/numbers/{id}":{"get":{"tags":["numbers"],"operationId":"numbers.get","parameters":[{"name":"id","in":"path","schema":{"type":"string","description":"The phone number's id."},"required":true}],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"phoneNumber":{"type":"string"},"connectionId":{"anyOf":[{"type":"string"},{"type":"null"}]},"webhookUrl":{"anyOf":[{"type":"string"},{"type":"null"}]},"smsSenderId":{"anyOf":[{"type":"string"},{"type":"null"}]},"callerIdName":{"anyOf":[{"type":"string"},{"type":"null"}]},"country":{"anyOf":[{"type":"string"},{"type":"null"}]},"numberType":{"anyOf":[{"type":"string"},{"type":"null"}]},"monthlyPriceCents":{"anyOf":[{"type":"number"},{"type":"null"}]},"currency":{"anyOf":[{"type":"string"},{"type":"null"}]},"nextChargeAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"releasedAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"createdAt":{"type":"string"}},"required":["id","phoneNumber","connectionId","webhookUrl","country","numberType","monthlyPriceCents","currency","nextChargeAt","releasedAt","createdAt"],"additionalProperties":false}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"404":{"description":"NumberNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NumberNotFound"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}}},"summary":"Get a phone number by id"}},"/numbers/{id}/release":{"post":{"tags":["numbers"],"operationId":"numbers.release","parameters":[{"name":"id","in":"path","schema":{"type":"string","description":"The phone number's id."},"required":true}],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["released"]}},"required":["status"],"additionalProperties":false}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"404":{"description":"NumberNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NumberNotFound"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}},"502":{"description":"UpstreamError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpstreamError"}}}}},"summary":"Release a phone number"}},"/numbers/{id}/connection":{"post":{"tags":["numbers"],"operationId":"numbers.assignConnection","parameters":[{"name":"id","in":"path","schema":{"type":"string","description":"The phone number's id."},"required":true}],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"phoneNumber":{"type":"string"},"connectionId":{"anyOf":[{"type":"string"},{"type":"null"}]},"webhookUrl":{"anyOf":[{"type":"string"},{"type":"null"}]},"smsSenderId":{"anyOf":[{"type":"string"},{"type":"null"}]},"callerIdName":{"anyOf":[{"type":"string"},{"type":"null"}]},"country":{"anyOf":[{"type":"string"},{"type":"null"}]},"numberType":{"anyOf":[{"type":"string"},{"type":"null"}]},"monthlyPriceCents":{"anyOf":[{"type":"number"},{"type":"null"}]},"currency":{"anyOf":[{"type":"string"},{"type":"null"}]},"nextChargeAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"releasedAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"createdAt":{"type":"string"}},"required":["id","phoneNumber","connectionId","webhookUrl","country","numberType","monthlyPriceCents","currency","nextChargeAt","releasedAt","createdAt"],"additionalProperties":false}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"404":{"description":"NumberNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NumberNotFound"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}},"502":{"description":"UpstreamError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpstreamError"}}}}},"summary":"Bind a connection to a number","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"connectionId":{"type":"string","description":"The id of the connection to bind to this number. The connection becomes the handler that answers calls and messages on the line."}},"required":["connectionId"],"additionalProperties":false}}},"required":true}}},"/numbers/{id}/webhook":{"post":{"tags":["numbers"],"operationId":"numbers.setWebhook","parameters":[{"name":"id","in":"path","schema":{"type":"string","description":"The phone number's id."},"required":true}],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"phoneNumber":{"type":"string"},"connectionId":{"anyOf":[{"type":"string"},{"type":"null"}]},"webhookUrl":{"anyOf":[{"type":"string"},{"type":"null"}]},"smsSenderId":{"anyOf":[{"type":"string"},{"type":"null"}]},"callerIdName":{"anyOf":[{"type":"string"},{"type":"null"}]},"country":{"anyOf":[{"type":"string"},{"type":"null"}]},"numberType":{"anyOf":[{"type":"string"},{"type":"null"}]},"monthlyPriceCents":{"anyOf":[{"type":"number"},{"type":"null"}]},"currency":{"anyOf":[{"type":"string"},{"type":"null"}]},"nextChargeAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"releasedAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"createdAt":{"type":"string"}},"required":["id","phoneNumber","connectionId","webhookUrl","country","numberType","monthlyPriceCents","currency","nextChargeAt","releasedAt","createdAt"],"additionalProperties":false}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"404":{"description":"NumberNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NumberNotFound"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}}},"description":"Sets the per-number manual-mode conversation-brain URL (a fallback for the connection's `manualWebhookUrl`). NOT an event-notification webhook — to receive call/SMS events, register a workspace webhook endpoint via `POST /workspaces/:slug/webhooks`.","summary":"Set a number's manual-mode brain URL","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string","description":"The per-number MANUAL-mode brain URL: a public `https://` endpoint Saperly POSTs each conversation turn to for a manual-mode line, as a fallback when the connection has no `manualWebhookUrl` and no live agent socket. This is NOT for receiving call/SMS event notifications — for those, register a workspace webhook endpoint (`POST /workspaces/:slug/webhooks`)."}},"required":["url"],"additionalProperties":false}}},"required":true}}},"/numbers/{id}/sms-sender":{"post":{"tags":["numbers"],"operationId":"numbers.setSmsSenderId","parameters":[{"name":"id","in":"path","schema":{"type":"string","description":"The phone number's id."},"required":true}],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"phoneNumber":{"type":"string"},"connectionId":{"anyOf":[{"type":"string"},{"type":"null"}]},"webhookUrl":{"anyOf":[{"type":"string"},{"type":"null"}]},"smsSenderId":{"anyOf":[{"type":"string"},{"type":"null"}]},"callerIdName":{"anyOf":[{"type":"string"},{"type":"null"}]},"country":{"anyOf":[{"type":"string"},{"type":"null"}]},"numberType":{"anyOf":[{"type":"string"},{"type":"null"}]},"monthlyPriceCents":{"anyOf":[{"type":"number"},{"type":"null"}]},"currency":{"anyOf":[{"type":"string"},{"type":"null"}]},"nextChargeAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"releasedAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"createdAt":{"type":"string"}},"required":["id","phoneNumber","connectionId","webhookUrl","country","numberType","monthlyPriceCents","currency","nextChargeAt","releasedAt","createdAt"],"additionalProperties":false}}}},"400":{"description":"InvalidSmsSenderId","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InvalidSmsSenderId"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"404":{"description":"NumberNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NumberNotFound"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}}},"summary":"Set the alphanumeric SMS sender id","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"smsSenderId":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Alphanumeric sender id (1–11 alphanumeric characters) to present on international SMS, or `null` to clear the override and send from the phone number itself."}},"required":["smsSenderId"],"additionalProperties":false}}},"required":true}}},"/numbers/{id}/caller-id":{"post":{"tags":["numbers"],"operationId":"numbers.setCallerIdName","parameters":[{"name":"id","in":"path","schema":{"type":"string","description":"The phone number's id."},"required":true}],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"phoneNumber":{"type":"string"},"connectionId":{"anyOf":[{"type":"string"},{"type":"null"}]},"webhookUrl":{"anyOf":[{"type":"string"},{"type":"null"}]},"smsSenderId":{"anyOf":[{"type":"string"},{"type":"null"}]},"callerIdName":{"anyOf":[{"type":"string"},{"type":"null"}]},"country":{"anyOf":[{"type":"string"},{"type":"null"}]},"numberType":{"anyOf":[{"type":"string"},{"type":"null"}]},"monthlyPriceCents":{"anyOf":[{"type":"number"},{"type":"null"}]},"currency":{"anyOf":[{"type":"string"},{"type":"null"}]},"nextChargeAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"releasedAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"createdAt":{"type":"string"}},"required":["id","phoneNumber","connectionId","webhookUrl","country","numberType","monthlyPriceCents","currency","nextChargeAt","releasedAt","createdAt"],"additionalProperties":false}}}},"400":{"description":"InvalidCallerIdName","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InvalidCallerIdName"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"404":{"description":"NumberNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NumberNotFound"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}},"502":{"description":"UpstreamError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpstreamError"}}}}},"summary":"Set the outbound caller ID name (CNAM)","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"callerIdName":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Outbound caller ID name (1–15 letters, digits, or spaces) registered as the line's CNAM listing, or `null` to clear it and show the bare number."}},"required":["callerIdName"],"additionalProperties":false}}},"required":true}}},"/connections":{"get":{"tags":["connections"],"operationId":"connections.list","parameters":[],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"mode":{"type":"string","enum":["hosted","manual"]},"instructions":{"type":"string"},"llm":{"anyOf":[{"type":"object","properties":{"kind":{"type":"string","enum":["managed"]},"model":{"type":"string"}},"required":["kind","model"],"additionalProperties":false},{"type":"null"}]},"backgroundAudio":{"anyOf":[{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["off"]}},"required":["type"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["office"]},"volume":{"anyOf":[{"anyOf":[{"type":"number"},{"type":"string","enum":["NaN"]},{"type":"string","enum":["Infinity"]},{"type":"string","enum":["-Infinity"]}]},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]}},"required":["type","volume"],"additionalProperties":false}]},{"type":"null"}]},"language":{"anyOf":[{"type":"string"},{"type":"null"}]},"mcpServers":{"anyOf":[{"type":"array","items":{"type":"object","properties":{"url":{"type":"string"},"auth":{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["bearer","none"]},"token":{"anyOf":[{"type":"string"},{"type":"null"}]}},"required":["type"],"additionalProperties":false},{"type":"null"}]},"allowedTools":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"null"}]}},"required":["url"],"additionalProperties":false}},{"type":"null"}]},"callControl":{"anyOf":[{"type":"object","properties":{"endCall":{"anyOf":[{"type":"boolean"},{"type":"null"}]},"sendDtmf":{"anyOf":[{"type":"boolean"},{"type":"null"}]},"transfer":{"anyOf":[{"type":"object","properties":{"targets":{"type":"array","items":{"type":"string"}},"from":{"anyOf":[{"type":"string"},{"type":"null"}]}},"required":["targets"],"additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},{"type":"null"}]},"complianceEnabled":{"type":"boolean"},"smsAutoReply":{"type":"boolean"},"disclosure":{"type":"string"},"recordingEnabled":{"type":"boolean"},"openaiRealtime":{"anyOf":[{"type":"object","properties":{"model":{"type":"string"},"voice":{"anyOf":[{"type":"string"},{"type":"null"}]}},"required":["model"],"additionalProperties":false},{"type":"null"}]},"manualSecret":{"anyOf":[{"type":"string"},{"type":"null"}]},"manualWebhookUrl":{"anyOf":[{"type":"string"},{"type":"null"}]},"createdAt":{"type":"string"},"backend":{"type":"string","enum":["network","openai_realtime"]},"tts":{"anyOf":[{"type":"object","properties":{"voiceId":{"type":"string"}},"required":["voiceId"],"additionalProperties":false},{"type":"null"}]}},"required":["id","name","mode","instructions","llm","language","mcpServers","callControl","complianceEnabled","smsAutoReply","disclosure","recordingEnabled","openaiRealtime","manualSecret","manualWebhookUrl","createdAt","backend","tts"],"additionalProperties":false}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}}},"summary":"List all connections in the workspace"},"post":{"tags":["connections"],"operationId":"connections.create","parameters":[],"security":[],"responses":{"201":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"mode":{"type":"string","enum":["hosted","manual"]},"instructions":{"type":"string"},"llm":{"anyOf":[{"type":"object","properties":{"kind":{"type":"string","enum":["managed"]},"model":{"type":"string"}},"required":["kind","model"],"additionalProperties":false},{"type":"null"}]},"backgroundAudio":{"anyOf":[{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["off"]}},"required":["type"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["office"]},"volume":{"anyOf":[{"anyOf":[{"type":"number"},{"type":"string","enum":["NaN"]},{"type":"string","enum":["Infinity"]},{"type":"string","enum":["-Infinity"]}]},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]}},"required":["type","volume"],"additionalProperties":false}]},{"type":"null"}]},"language":{"anyOf":[{"type":"string"},{"type":"null"}]},"mcpServers":{"anyOf":[{"type":"array","items":{"type":"object","properties":{"url":{"type":"string"},"auth":{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["bearer","none"]},"token":{"anyOf":[{"type":"string"},{"type":"null"}]}},"required":["type"],"additionalProperties":false},{"type":"null"}]},"allowedTools":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"null"}]}},"required":["url"],"additionalProperties":false}},{"type":"null"}]},"callControl":{"anyOf":[{"type":"object","properties":{"endCall":{"anyOf":[{"type":"boolean"},{"type":"null"}]},"sendDtmf":{"anyOf":[{"type":"boolean"},{"type":"null"}]},"transfer":{"anyOf":[{"type":"object","properties":{"targets":{"type":"array","items":{"type":"string"}},"from":{"anyOf":[{"type":"string"},{"type":"null"}]}},"required":["targets"],"additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},{"type":"null"}]},"complianceEnabled":{"type":"boolean"},"smsAutoReply":{"type":"boolean"},"disclosure":{"type":"string"},"recordingEnabled":{"type":"boolean"},"openaiRealtime":{"anyOf":[{"type":"object","properties":{"model":{"type":"string"},"voice":{"anyOf":[{"type":"string"},{"type":"null"}]}},"required":["model"],"additionalProperties":false},{"type":"null"}]},"manualSecret":{"anyOf":[{"type":"string"},{"type":"null"}]},"manualWebhookUrl":{"anyOf":[{"type":"string"},{"type":"null"}]},"createdAt":{"type":"string"},"backend":{"type":"string","enum":["network","openai_realtime"]},"tts":{"anyOf":[{"type":"object","properties":{"voiceId":{"type":"string"}},"required":["voiceId"],"additionalProperties":false},{"type":"null"}]}},"required":["id","name","mode","instructions","llm","language","mcpServers","callControl","complianceEnabled","smsAutoReply","disclosure","recordingEnabled","openaiRealtime","manualSecret","manualWebhookUrl","createdAt","backend","tts"],"additionalProperties":false}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"409":{"description":"IdempotencyConflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IdempotencyConflict"}}}},"422":{"description":"IdempotencyKeyMismatch | UnsupportedModel | UnsupportedVoice | AudioConfigurationError","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/IdempotencyKeyMismatch"},{"$ref":"#/components/schemas/UnsupportedModel"},{"$ref":"#/components/schemas/UnsupportedVoice"},{"$ref":"#/components/schemas/AudioConfigurationError"}]}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}},"502":{"description":"UpstreamError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpstreamError"}}}}},"summary":"Create a connection (provisions inline)","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","allOf":[{"minLength":1},{"maxLength":120,"description":"A human-readable name for the connection (1–120 characters)."}]},"mode":{"anyOf":[{"type":"string","enum":["hosted","manual"],"description":"How the line is handled. 'hosted' (default): an in-network voice assistant (cascade STT → LLM → TTS) is the brain. 'manual': your own LLM is the brain — Saperly forwards text turns and executes the directives you return. Audio stays in-network in both modes."},{"type":"null"}]},"backend":{"anyOf":[{"type":"string","enum":["network","openai_realtime"],"description":"The hosted brain backend. Today only 'network' (an in-network voice assistant) is available; 'openai_realtime' is disabled and rejected on create/update."},{"type":"null"}]},"instructions":{"anyOf":[{"type":"string","description":"The system prompt that defines the assistant's behavior. Put any opening line here — there is no separate greeting field."},{"type":"null"}]},"llm":{"anyOf":[{"type":"object","properties":{"kind":{"type":"string","enum":["managed"],"description":"Always 'managed' — the hosted assistant runs the model in-network."},"model":{"type":"string","description":"The in-network managed model the hosted assistant runs, e.g. \"openai/gpt-4o\"."}},"required":["kind","model"],"additionalProperties":false,"description":"The model the hosted assistant runs. Omit to use the managed default. Hosted mode only."},{"type":"null"}]},"tts":{"anyOf":[{"type":"object","properties":{"provider":{"anyOf":[{"type":"string","description":"The text-to-speech provider. Optional — defaults to the in-network provider, which is all you normally need."},{"type":"null"}]},"voiceId":{"type":"string","description":"The voice the hosted assistant speaks with. Use an `id` returned by `GET /voices` (optionally filtered by `?language=`). Hosted mode only."}},"required":["voiceId"],"additionalProperties":false,"description":"The hosted assistant's text-to-speech voice. Omit `tts` to use the managed default voice; otherwise `{ \"voiceId\": \"<id from GET /voices>\" }` is enough."},{"type":"null"}]},"backgroundAudio":{"anyOf":[{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["off"]}},"required":["type"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["office"]},"volume":{"anyOf":[{"anyOf":[{"type":"number"},{"type":"string","enum":["NaN"]},{"type":"string","enum":["Infinity"]},{"type":"string","enum":["-Infinity"]}]},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]}},"required":["type","volume"],"additionalProperties":false}]},{"type":"null"}]},"language":{"anyOf":[{"type":"string","description":"The spoken language as a BCP-47 tag (e.g. \"en\", \"es\", \"en-US\"). On hosted lines it is the in-network transcription hint — which language the caller speaks (pair it with a voice that speaks the same language, and instruct the model to reply in it). On manual lines it is the Conversation Relay language, steering in-network transcription AND the spoken voice. Discover the supported set from `GET /languages` (or filter `GET /voices` by language); any well-formed tag is accepted. Send \"\" to clear it (auto-detect)."},{"type":"null"}]},"mcpServers":{"anyOf":[{"type":"array","items":{"type":"object","properties":{"url":{"type":"string","description":"Public `https://` URL of your streamable-HTTP MCP server (commonly ending in `/mcp`). SSE-only servers are not supported."},"auth":{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["bearer","none"]},"token":{"anyOf":[{"type":"string","description":"Bearer token sent as `Authorization: Bearer <token>` on every request to your server. Required when `type` is 'bearer'; stored encrypted and never returned in reads."},{"type":"null"}]}},"required":["type"],"additionalProperties":false,"description":"How Saperly authenticates to your MCP server. Use { type: 'none' } (or omit `auth`) for an open server."},{"type":"null"}]},"allowedTools":{"anyOf":[{"type":"array","items":{"type":"string"},"description":"Allow-list of tool names to expose to the assistant. Omit to expose every tool the server advertises."},{"type":"null"}]}},"required":["url"],"additionalProperties":false,"description":"A Model Context Protocol server the hosted assistant may call as tools mid-conversation. Hosted mode only."},"description":"MCP servers the hosted assistant may call as tools during a conversation. Hosted mode only."},{"type":"null"}]},"callControl":{"anyOf":[{"type":"object","properties":{"endCall":{"anyOf":[{"type":"boolean","description":"Allow the brain to hang up the call. Defaults on."},{"type":"null"}]},"sendDtmf":{"anyOf":[{"type":"boolean","description":"Allow the brain to send DTMF (touch-tone) digits. Defaults on."},{"type":"null"}]},"transfer":{"anyOf":[{"type":"object","properties":{"targets":{"type":"array","items":{"type":"string"},"description":"Allowed blind-transfer destinations (E.164 numbers or `sip:` URIs). Transfer only takes effect with at least one target."},"from":{"anyOf":[{"type":"string","description":"Optional caller ID to present on the transferred leg."},{"type":"null"}]}},"required":["targets"],"additionalProperties":false,"description":"Blind-transfer enablement and its allowed targets."},{"type":"null"}]}},"additionalProperties":false,"description":"Which call-control actions the connection's brain may take, projected to whichever backend handles the call. Omitted fields fall back to defaults (end-call + DTMF on, transfer off)."},{"type":"null"}]},"complianceEnabled":{"anyOf":[{"type":"boolean","description":"When true (the default), the do-not-message tool is exposed and `disclosure` is spoken as the line's first, uninterruptible utterance (the TCPA notice). When on with no `disclosure`, a standard org-named default is filled in."},{"type":"null"}]},"smsAutoReply":{"anyOf":[{"type":"boolean","description":"Hosted-line opt-in to auto-answer inbound SMS with the model. Defaults off. (Manual lines forward to their webhook brain regardless.)"},{"type":"null"}]},"disclosure":{"anyOf":[{"type":"string","description":"The TCPA notice spoken first, uninterruptibly, when `complianceEnabled` is on. Leave empty with compliance on and Saperly fills a standard org-named default."},{"type":"null"}]},"openaiRealtime":{"anyOf":[{"type":"object","properties":{"model":{"type":"string","description":"The OpenAI Realtime model id."},"voice":{"anyOf":[{"type":"string","description":"The OpenAI Realtime voice. Distinct from the hosted `tts.voiceId` — this names a built-in OpenAI Realtime voice."},{"type":"null"}]}},"required":["model"],"additionalProperties":false,"description":"Config for the OpenAI-Realtime hosted backend. Only meaningful when `backend` is 'openai_realtime' (currently disabled). The OpenAI project is operator-hosted and not settable here."},{"type":"null"}]},"manualWebhookUrl":{"anyOf":[{"type":"string","description":"Manual-mode webhook-brain URL: where Saperly POSTs each turn (signed with the connection's `manualSecret`) when no live agent socket is connected. Only meaningful for manual mode; send \"\" to clear it."},{"type":"null"}]}},"required":["name"],"additionalProperties":false,"description":"Create a connection — the handler bound to a phone number. Hosted lines configure an in-network assistant (model, voice, language, MCP tools); manual lines forward turns to your own brain."}}},"required":true}}},"/connections/{id}":{"get":{"tags":["connections"],"operationId":"connections.get","parameters":[{"name":"id","in":"path","schema":{"type":"string","description":"The connection's id."},"required":true}],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"mode":{"type":"string","enum":["hosted","manual"]},"instructions":{"type":"string"},"llm":{"anyOf":[{"type":"object","properties":{"kind":{"type":"string","enum":["managed"]},"model":{"type":"string"}},"required":["kind","model"],"additionalProperties":false},{"type":"null"}]},"backgroundAudio":{"anyOf":[{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["off"]}},"required":["type"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["office"]},"volume":{"anyOf":[{"anyOf":[{"type":"number"},{"type":"string","enum":["NaN"]},{"type":"string","enum":["Infinity"]},{"type":"string","enum":["-Infinity"]}]},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]}},"required":["type","volume"],"additionalProperties":false}]},{"type":"null"}]},"language":{"anyOf":[{"type":"string"},{"type":"null"}]},"mcpServers":{"anyOf":[{"type":"array","items":{"type":"object","properties":{"url":{"type":"string"},"auth":{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["bearer","none"]},"token":{"anyOf":[{"type":"string"},{"type":"null"}]}},"required":["type"],"additionalProperties":false},{"type":"null"}]},"allowedTools":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"null"}]}},"required":["url"],"additionalProperties":false}},{"type":"null"}]},"callControl":{"anyOf":[{"type":"object","properties":{"endCall":{"anyOf":[{"type":"boolean"},{"type":"null"}]},"sendDtmf":{"anyOf":[{"type":"boolean"},{"type":"null"}]},"transfer":{"anyOf":[{"type":"object","properties":{"targets":{"type":"array","items":{"type":"string"}},"from":{"anyOf":[{"type":"string"},{"type":"null"}]}},"required":["targets"],"additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},{"type":"null"}]},"complianceEnabled":{"type":"boolean"},"smsAutoReply":{"type":"boolean"},"disclosure":{"type":"string"},"recordingEnabled":{"type":"boolean"},"openaiRealtime":{"anyOf":[{"type":"object","properties":{"model":{"type":"string"},"voice":{"anyOf":[{"type":"string"},{"type":"null"}]}},"required":["model"],"additionalProperties":false},{"type":"null"}]},"manualSecret":{"anyOf":[{"type":"string"},{"type":"null"}]},"manualWebhookUrl":{"anyOf":[{"type":"string"},{"type":"null"}]},"createdAt":{"type":"string"},"backend":{"type":"string","enum":["network","openai_realtime"]},"tts":{"anyOf":[{"type":"object","properties":{"voiceId":{"type":"string"}},"required":["voiceId"],"additionalProperties":false},{"type":"null"}]}},"required":["id","name","mode","instructions","llm","language","mcpServers","callControl","complianceEnabled","smsAutoReply","disclosure","recordingEnabled","openaiRealtime","manualSecret","manualWebhookUrl","createdAt","backend","tts"],"additionalProperties":false}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"404":{"description":"ConnectionNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectionNotFound"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}}},"summary":"Get a connection by id"},"patch":{"tags":["connections"],"operationId":"connections.update","parameters":[{"name":"id","in":"path","schema":{"type":"string","description":"The connection's id."},"required":true}],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"mode":{"type":"string","enum":["hosted","manual"]},"instructions":{"type":"string"},"llm":{"anyOf":[{"type":"object","properties":{"kind":{"type":"string","enum":["managed"]},"model":{"type":"string"}},"required":["kind","model"],"additionalProperties":false},{"type":"null"}]},"backgroundAudio":{"anyOf":[{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["off"]}},"required":["type"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["office"]},"volume":{"anyOf":[{"anyOf":[{"type":"number"},{"type":"string","enum":["NaN"]},{"type":"string","enum":["Infinity"]},{"type":"string","enum":["-Infinity"]}]},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]}},"required":["type","volume"],"additionalProperties":false}]},{"type":"null"}]},"language":{"anyOf":[{"type":"string"},{"type":"null"}]},"mcpServers":{"anyOf":[{"type":"array","items":{"type":"object","properties":{"url":{"type":"string"},"auth":{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["bearer","none"]},"token":{"anyOf":[{"type":"string"},{"type":"null"}]}},"required":["type"],"additionalProperties":false},{"type":"null"}]},"allowedTools":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"null"}]}},"required":["url"],"additionalProperties":false}},{"type":"null"}]},"callControl":{"anyOf":[{"type":"object","properties":{"endCall":{"anyOf":[{"type":"boolean"},{"type":"null"}]},"sendDtmf":{"anyOf":[{"type":"boolean"},{"type":"null"}]},"transfer":{"anyOf":[{"type":"object","properties":{"targets":{"type":"array","items":{"type":"string"}},"from":{"anyOf":[{"type":"string"},{"type":"null"}]}},"required":["targets"],"additionalProperties":false},{"type":"null"}]}},"additionalProperties":false},{"type":"null"}]},"complianceEnabled":{"type":"boolean"},"smsAutoReply":{"type":"boolean"},"disclosure":{"type":"string"},"recordingEnabled":{"type":"boolean"},"openaiRealtime":{"anyOf":[{"type":"object","properties":{"model":{"type":"string"},"voice":{"anyOf":[{"type":"string"},{"type":"null"}]}},"required":["model"],"additionalProperties":false},{"type":"null"}]},"manualSecret":{"anyOf":[{"type":"string"},{"type":"null"}]},"manualWebhookUrl":{"anyOf":[{"type":"string"},{"type":"null"}]},"createdAt":{"type":"string"},"backend":{"type":"string","enum":["network","openai_realtime"]},"tts":{"anyOf":[{"type":"object","properties":{"voiceId":{"type":"string"}},"required":["voiceId"],"additionalProperties":false},{"type":"null"}]}},"required":["id","name","mode","instructions","llm","language","mcpServers","callControl","complianceEnabled","smsAutoReply","disclosure","recordingEnabled","openaiRealtime","manualSecret","manualWebhookUrl","createdAt","backend","tts"],"additionalProperties":false}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"404":{"description":"ConnectionNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectionNotFound"}}}},"422":{"description":"UnsupportedModel | UnsupportedVoice | AudioConfigurationError","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnsupportedModel"},{"$ref":"#/components/schemas/UnsupportedVoice"},{"$ref":"#/components/schemas/AudioConfigurationError"}]}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}},"502":{"description":"UpstreamError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpstreamError"}}}}},"summary":"Update a connection (re-syncs the carrier)","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"anyOf":[{"type":"string","allOf":[{"minLength":1},{"maxLength":120,"description":"A human-readable name for the connection (1–120 characters)."}]},{"type":"null"}]},"mode":{"anyOf":[{"type":"string","enum":["hosted","manual"],"description":"How the line is handled. 'hosted' (default): an in-network voice assistant (cascade STT → LLM → TTS) is the brain. 'manual': your own LLM is the brain — Saperly forwards text turns and executes the directives you return. Audio stays in-network in both modes."},{"type":"null"}]},"backend":{"anyOf":[{"type":"string","enum":["network","openai_realtime"],"description":"The hosted brain backend. Today only 'network' is available; 'openai_realtime' is disabled and rejected."},{"type":"null"}]},"instructions":{"anyOf":[{"type":"string","description":"The system prompt that defines the assistant's behavior."},{"type":"null"}]},"llm":{"anyOf":[{"type":"object","properties":{"kind":{"type":"string","enum":["managed"],"description":"Always 'managed' — the hosted assistant runs the model in-network."},"model":{"type":"string","description":"The in-network managed model the hosted assistant runs, e.g. \"openai/gpt-4o\"."}},"required":["kind","model"],"additionalProperties":false,"description":"The model the hosted assistant runs. Omit to use the managed default. Hosted mode only."},{"type":"null"}]},"tts":{"anyOf":[{"type":"object","properties":{"provider":{"anyOf":[{"type":"string","description":"The text-to-speech provider. Optional — defaults to the in-network provider, which is all you normally need."},{"type":"null"}]},"voiceId":{"type":"string","description":"The voice the hosted assistant speaks with. Use an `id` returned by `GET /voices` (optionally filtered by `?language=`). Hosted mode only."}},"required":["voiceId"],"additionalProperties":false,"description":"The hosted assistant's text-to-speech voice. Omit `tts` to use the managed default voice; otherwise `{ \"voiceId\": \"<id from GET /voices>\" }` is enough."},{"type":"null"}]},"backgroundAudio":{"anyOf":[{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["off"]}},"required":["type"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["office"]},"volume":{"anyOf":[{"anyOf":[{"type":"number"},{"type":"string","enum":["NaN"]},{"type":"string","enum":["Infinity"]},{"type":"string","enum":["-Infinity"]}]},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]}},"required":["type","volume"],"additionalProperties":false}]},{"type":"null"}]},"language":{"anyOf":[{"type":"string","description":"The spoken language as a BCP-47 tag (e.g. \"en\", \"es\", \"en-US\"). Hosted: the in-network transcription hint. Manual: the Conversation Relay language (steers in-network transcription + the spoken voice). Discover values from `GET /languages`. Send \"\" to clear it back to auto-detect."},{"type":"null"}]},"mcpServers":{"anyOf":[{"type":"array","items":{"type":"object","properties":{"url":{"type":"string","description":"Public `https://` URL of your streamable-HTTP MCP server (commonly ending in `/mcp`). SSE-only servers are not supported."},"auth":{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["bearer","none"]},"token":{"anyOf":[{"type":"string","description":"Bearer token sent as `Authorization: Bearer <token>` on every request to your server. Required when `type` is 'bearer'; stored encrypted and never returned in reads."},{"type":"null"}]}},"required":["type"],"additionalProperties":false,"description":"How Saperly authenticates to your MCP server. Use { type: 'none' } (or omit `auth`) for an open server."},{"type":"null"}]},"allowedTools":{"anyOf":[{"type":"array","items":{"type":"string"},"description":"Allow-list of tool names to expose to the assistant. Omit to expose every tool the server advertises."},{"type":"null"}]}},"required":["url"],"additionalProperties":false,"description":"A Model Context Protocol server the hosted assistant may call as tools mid-conversation. Hosted mode only."},"description":"Replaces the full set of MCP servers on the connection (send `[]` to clear). Hosted mode only."},{"type":"null"}]},"callControl":{"anyOf":[{"type":"object","properties":{"endCall":{"anyOf":[{"type":"boolean","description":"Allow the brain to hang up the call. Defaults on."},{"type":"null"}]},"sendDtmf":{"anyOf":[{"type":"boolean","description":"Allow the brain to send DTMF (touch-tone) digits. Defaults on."},{"type":"null"}]},"transfer":{"anyOf":[{"type":"object","properties":{"targets":{"type":"array","items":{"type":"string"},"description":"Allowed blind-transfer destinations (E.164 numbers or `sip:` URIs). Transfer only takes effect with at least one target."},"from":{"anyOf":[{"type":"string","description":"Optional caller ID to present on the transferred leg."},{"type":"null"}]}},"required":["targets"],"additionalProperties":false,"description":"Blind-transfer enablement and its allowed targets."},{"type":"null"}]}},"additionalProperties":false,"description":"Which call-control actions the connection's brain may take, projected to whichever backend handles the call. Omitted fields fall back to defaults (end-call + DTMF on, transfer off)."},{"type":"null"}]},"complianceEnabled":{"anyOf":[{"type":"boolean","description":"Toggle the do-not-message tool + the TCPA `disclosure` opener."},{"type":"null"}]},"smsAutoReply":{"anyOf":[{"type":"boolean","description":"Hosted-line opt-in to auto-answer inbound SMS with the model. Default off."},{"type":"null"}]},"disclosure":{"anyOf":[{"type":"string","description":"The TCPA notice spoken first, uninterruptibly, when compliance is on."},{"type":"null"}]},"openaiRealtime":{"anyOf":[{"type":"object","properties":{"model":{"type":"string","description":"The OpenAI Realtime model id."},"voice":{"anyOf":[{"type":"string","description":"The OpenAI Realtime voice. Distinct from the hosted `tts.voiceId` — this names a built-in OpenAI Realtime voice."},{"type":"null"}]}},"required":["model"],"additionalProperties":false,"description":"Config for the OpenAI-Realtime hosted backend. Only meaningful when `backend` is 'openai_realtime' (currently disabled). The OpenAI project is operator-hosted and not settable here."},{"type":"null"}]},"manualWebhookUrl":{"anyOf":[{"type":"string","description":"Manual-mode webhook-brain URL. Only meaningful for manual mode; send \"\" to clear it."},{"type":"null"}]}},"additionalProperties":false,"description":"Update a connection. Every field is optional — only the fields you send change. The handler re-syncs the carrier so a mode/backend switch reconciles automatically."}}},"required":true}},"delete":{"tags":["connections"],"operationId":"connections.delete","parameters":[{"name":"id","in":"path","schema":{"type":"string","description":"The connection's id."},"required":true}],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["deleted"]}},"required":["status"],"additionalProperties":false}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"404":{"description":"ConnectionNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectionNotFound"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}}},"summary":"Delete a connection"}},"/messages":{"post":{"tags":["messaging"],"operationId":"messaging.send","parameters":[],"security":[],"responses":{"201":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"numberId":{"type":"string"},"direction":{"type":"string","enum":["inbound","outbound"]},"to":{"type":"string"},"from":{"type":"string"},"body":{"type":"string"},"segments":{"type":"number"},"status":{"type":"string"},"createdAt":{"type":"string"}},"required":["id","numberId","direction","to","from","body","segments","status","createdAt"],"additionalProperties":false}}}},"400":{"description":"DestinationNotSupported","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DestinationNotSupported"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"402":{"description":"InsufficientFunds | SpendLimitExceeded","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/InsufficientFunds"},{"$ref":"#/components/schemas/SpendLimitExceeded"}]}}}},"403":{"description":"AuthorizationDenied | RecipientOptedOut","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/AuthorizationDenied"},{"$ref":"#/components/schemas/RecipientOptedOut"}]}}}},"404":{"description":"NumberNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NumberNotFound"}}}},"409":{"description":"IdempotencyConflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IdempotencyConflict"}}}},"422":{"description":"IdempotencyKeyMismatch","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IdempotencyKeyMismatch"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}},"502":{"description":"MessageSendFailed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageSendFailed"}}}}},"summary":"Send an SMS message","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"fromNumberId":{"type":"string","description":"The id of one of your numbers to send the SMS from. Must be a number you own; with a scoped key it must also be within the key's number allow-list."},"to":{"type":"string","description":"The recipient phone number in E.164 format (e.g. `+14155550123`)."},"body":{"type":"string","allOf":[{"minLength":1},{"maxLength":1600,"description":"The message text (1–1600 characters). Long messages are split into multiple segments automatically and billed per segment."}]}},"required":["fromNumberId","to","body"],"additionalProperties":false,"description":"Send a single SMS. The message is checked against the recipient's opt-out (STOP) status and the workspace balance before it leaves the network."}}},"required":true}},"get":{"tags":["messaging"],"operationId":"messaging.list","parameters":[{"name":"numberId","in":"query","schema":{"anyOf":[{"type":"string","description":"Filter to messages sent from or received on this number. Omit to list every message in the workspace."},{"type":"null"}]},"required":false}],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"numberId":{"type":"string"},"direction":{"type":"string","enum":["inbound","outbound"]},"to":{"type":"string"},"from":{"type":"string"},"body":{"type":"string"},"segments":{"type":"number"},"status":{"type":"string"},"createdAt":{"type":"string"}},"required":["id","numberId","direction","to","from","body","segments","status","createdAt"],"additionalProperties":false}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}}},"summary":"List messages (optionally filtered by number)"}},"/calls":{"post":{"tags":["voice"],"operationId":"voice.place","parameters":[],"security":[],"responses":{"201":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"numberId":{"type":"string"},"direction":{"type":"string","enum":["inbound","outbound"]},"to":{"type":"string"},"from":{"type":"string"},"status":{"type":"string","description":"Lifecycle status. `initiated` (placed or ringing, not yet finalized), `completed` (connected and hung up; billed by duration), `no_answer` (the callee never picked up; zero cost), `failed` (the carrier could not connect it, or it was expired unfinalized; zero cost), `rejected` (refused before answer — insufficient balance; zero cost). Only `completed` bills."},"rateCentsPerMin":{"anyOf":[{"type":"number"},{"type":"null"}]},"durationSec":{"anyOf":[{"type":"number"},{"type":"null"}]},"costCents":{"anyOf":[{"type":"number"},{"type":"null"}]},"hasRecording":{"type":"boolean"},"hasTranscript":{"type":"boolean"},"createdAt":{"type":"string"}},"required":["id","numberId","direction","to","from","status","rateCentsPerMin","durationSec","costCents","hasRecording","hasTranscript","createdAt"],"additionalProperties":false}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"402":{"description":"InsufficientFunds | SpendLimitExceeded","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/InsufficientFunds"},{"$ref":"#/components/schemas/SpendLimitExceeded"}]}}}},"403":{"description":"AuthorizationDenied | RecipientOptedOut","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/AuthorizationDenied"},{"$ref":"#/components/schemas/RecipientOptedOut"}]}}}},"404":{"description":"NumberNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NumberNotFound"}}}},"409":{"description":"IdempotencyConflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IdempotencyConflict"}}}},"422":{"description":"NumberHasNoConnection | AudioConfigurationError | UnsupportedVoice | IdempotencyKeyMismatch","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/NumberHasNoConnection"},{"$ref":"#/components/schemas/AudioConfigurationError"},{"$ref":"#/components/schemas/UnsupportedVoice"},{"$ref":"#/components/schemas/IdempotencyKeyMismatch"}]}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}},"502":{"description":"CallStartFailed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CallStartFailed"}}}}},"summary":"Place an outbound call","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"fromNumberId":{"type":"string","description":"The Saperly number id to place the call from."},"to":{"type":"string","description":"The destination in E.164 format, e.g. \"+15555550123\"."},"connectionId":{"anyOf":[{"type":"string","description":"Optional. Use this connection for the call instead of the number's bound one."},{"type":"null"}]},"instructions":{"anyOf":[{"type":"string","description":"A per-call system prompt that overrides the connection's saved instructions for this call only. Omit to run the call on the line's saved config. (Voice/model/language are not per-call overridable via the API — set them on the connection.)"},{"type":"null"}]}},"required":["fromNumberId","to"],"additionalProperties":false,"description":"Place an outbound call from a Saperly number. The connection bound to the number (or `connectionId`) is the brain; audio stays in-network."}}},"required":true}},"get":{"tags":["voice"],"operationId":"voice.list","parameters":[],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"numberId":{"type":"string"},"direction":{"type":"string","enum":["inbound","outbound"]},"to":{"type":"string"},"from":{"type":"string"},"status":{"type":"string","description":"Lifecycle status. `initiated` (placed or ringing, not yet finalized), `completed` (connected and hung up; billed by duration), `no_answer` (the callee never picked up; zero cost), `failed` (the carrier could not connect it, or it was expired unfinalized; zero cost), `rejected` (refused before answer — insufficient balance; zero cost). Only `completed` bills."},"rateCentsPerMin":{"anyOf":[{"type":"number"},{"type":"null"}]},"durationSec":{"anyOf":[{"type":"number"},{"type":"null"}]},"costCents":{"anyOf":[{"type":"number"},{"type":"null"}]},"hasRecording":{"type":"boolean"},"hasTranscript":{"type":"boolean"},"createdAt":{"type":"string"}},"required":["id","numberId","direction","to","from","status","rateCentsPerMin","durationSec","costCents","hasRecording","hasTranscript","createdAt"],"additionalProperties":false}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}}},"summary":"List calls"}},"/calls/{id}/end":{"post":{"tags":["voice"],"operationId":"voice.end","parameters":[{"name":"id","in":"path","schema":{"type":"string","description":"The call's id."},"required":true}],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"numberId":{"type":"string"},"direction":{"type":"string","enum":["inbound","outbound"]},"to":{"type":"string"},"from":{"type":"string"},"status":{"type":"string","description":"Lifecycle status. `initiated` (placed or ringing, not yet finalized), `completed` (connected and hung up; billed by duration), `no_answer` (the callee never picked up; zero cost), `failed` (the carrier could not connect it, or it was expired unfinalized; zero cost), `rejected` (refused before answer — insufficient balance; zero cost). Only `completed` bills."},"rateCentsPerMin":{"anyOf":[{"type":"number"},{"type":"null"}]},"durationSec":{"anyOf":[{"type":"number"},{"type":"null"}]},"costCents":{"anyOf":[{"type":"number"},{"type":"null"}]},"hasRecording":{"type":"boolean"},"hasTranscript":{"type":"boolean"},"createdAt":{"type":"string"}},"required":["id","numberId","direction","to","from","status","rateCentsPerMin","durationSec","costCents","hasRecording","hasTranscript","createdAt"],"additionalProperties":false}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"404":{"description":"CallNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CallNotFound"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}}},"summary":"End a live call"}},"/calls/{id}/transfer":{"post":{"tags":["voice"],"operationId":"voice.transfer","parameters":[{"name":"id","in":"path","schema":{"type":"string","description":"The call's id."},"required":true}],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"numberId":{"type":"string"},"direction":{"type":"string","enum":["inbound","outbound"]},"to":{"type":"string"},"from":{"type":"string"},"status":{"type":"string","description":"Lifecycle status. `initiated` (placed or ringing, not yet finalized), `completed` (connected and hung up; billed by duration), `no_answer` (the callee never picked up; zero cost), `failed` (the carrier could not connect it, or it was expired unfinalized; zero cost), `rejected` (refused before answer — insufficient balance; zero cost). Only `completed` bills."},"rateCentsPerMin":{"anyOf":[{"type":"number"},{"type":"null"}]},"durationSec":{"anyOf":[{"type":"number"},{"type":"null"}]},"costCents":{"anyOf":[{"type":"number"},{"type":"null"}]},"hasRecording":{"type":"boolean"},"hasTranscript":{"type":"boolean"},"createdAt":{"type":"string"}},"required":["id","numberId","direction","to","from","status","rateCentsPerMin","durationSec","costCents","hasRecording","hasTranscript","createdAt"],"additionalProperties":false}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"404":{"description":"CallNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CallNotFound"}}}},"409":{"description":"IdempotencyConflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IdempotencyConflict"}}}},"422":{"description":"IdempotencyKeyMismatch","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IdempotencyKeyMismatch"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}},"502":{"description":"CallStartFailed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CallStartFailed"}}}}},"summary":"Blind-transfer a live call","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"to":{"type":"string","description":"Where to blind-transfer the live leg — an E.164 number (e.g. \"+15551230000\") or a `sip:` URI."}},"required":["to"],"additionalProperties":false}}},"required":true}}},"/calls/{id}":{"get":{"tags":["voice"],"operationId":"voice.get","parameters":[{"name":"id","in":"path","schema":{"type":"string","description":"The call's id."},"required":true}],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"numberId":{"type":"string"},"direction":{"type":"string","enum":["inbound","outbound"]},"to":{"type":"string"},"from":{"type":"string"},"status":{"type":"string","description":"Lifecycle status. `initiated` (placed or ringing, not yet finalized), `completed` (connected and hung up; billed by duration), `no_answer` (the callee never picked up; zero cost), `failed` (the carrier could not connect it, or it was expired unfinalized; zero cost), `rejected` (refused before answer — insufficient balance; zero cost). Only `completed` bills."},"rateCentsPerMin":{"anyOf":[{"type":"number"},{"type":"null"}]},"durationSec":{"anyOf":[{"type":"number"},{"type":"null"}]},"costCents":{"anyOf":[{"type":"number"},{"type":"null"}]},"hasRecording":{"type":"boolean"},"hasTranscript":{"type":"boolean"},"createdAt":{"type":"string"}},"required":["id","numberId","direction","to","from","status","rateCentsPerMin","durationSec","costCents","hasRecording","hasTranscript","createdAt"],"additionalProperties":false}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"404":{"description":"CallNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CallNotFound"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}}},"summary":"Get a call by id"}},"/calls/{id}/recording":{"get":{"tags":["voice"],"operationId":"voice.recording","parameters":[{"name":"id","in":"path","schema":{"type":"string","description":"The call's id."},"required":true}],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"404":{"description":"CallNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CallNotFound"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}},"502":{"description":"UpstreamError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpstreamError"}}}}},"summary":"Get a call recording (302 redirect to a download URL)"}},"/calls/{id}/transcript":{"get":{"tags":["voice"],"operationId":"voice.transcript","parameters":[{"name":"id","in":"path","schema":{"type":"string","description":"The call's id."},"required":true}],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"404":{"description":"CallNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CallNotFound"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}}},"summary":"Get a call transcript"}},"/voices":{"get":{"tags":["voices"],"operationId":"voices.list","parameters":[{"name":"language","in":"query","schema":{"anyOf":[{"type":"string","description":"Filter voices by language — a case-insensitive BCP-47 prefix. \"en\" matches \"en\", \"en-US\", \"en-GB\", … Omit to list every voice."},{"type":"null"}]},"required":false}],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","description":"The voice's opaque, stable id. Pass it straight back as a connection's `tts.voiceId`."},"name":{"type":"string","description":"The voice's display name (e.g. \"Clara - Instructor\")."},"gender":{"type":"string","description":"The voice's gender (e.g. \"female\", \"male\")."},"language":{"type":"string","description":"The language the voice speaks, as a BCP-47 tag (e.g. \"en-US\"). Also the value to use for a connection's `language` field if you want transcription in this language."}},"required":["id","name","gender","language"],"additionalProperties":false,"description":"A selectable in-network text-to-speech voice. Use `id` as a connection's `tts.voiceId`."}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"404":{"description":"CustomVoiceNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomVoiceNotFound"}}}},"409":{"description":"CustomVoiceConflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomVoiceConflict"}}}},"422":{"description":"InvalidVoiceUpload","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InvalidVoiceUpload"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}},"502":{"description":"UpstreamError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpstreamError"}}}}},"summary":"List available voices (optionally filtered by language)"}},"/custom-voices":{"get":{"tags":["customVoices"],"operationId":"customVoices.list","parameters":[],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"language":{"type":"string"},"gender":{"type":"string","enum":["male","female","neutral"]},"status":{"type":"string","enum":["pending","active","failed","expired"]},"failureReason":{"anyOf":[{"type":"string"},{"type":"null"}]},"deletionPending":{"anyOf":[{"type":"boolean"},{"type":"null"}]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","name","language","gender","status","failureReason","createdAt","updatedAt"],"additionalProperties":false}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"404":{"description":"CustomVoiceNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomVoiceNotFound"}}}},"409":{"description":"CustomVoiceConflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomVoiceConflict"}}}},"422":{"description":"InvalidVoiceUpload","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InvalidVoiceUpload"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}},"502":{"description":"UpstreamError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpstreamError"}}}}}},"post":{"tags":["customVoices"],"operationId":"customVoices.create","parameters":[{"name":"idempotency-key","in":"header","schema":{"type":"string","description":"A stable submission key. Reuse it when retrying the same upload."},"required":true}],"security":[],"responses":{"202":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"language":{"type":"string"},"gender":{"type":"string","enum":["male","female","neutral"]},"status":{"type":"string","enum":["pending","active","failed","expired"]},"failureReason":{"anyOf":[{"type":"string"},{"type":"null"}]},"deletionPending":{"anyOf":[{"type":"boolean"},{"type":"null"}]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","name","language","gender","status","failureReason","createdAt","updatedAt"],"additionalProperties":false}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"404":{"description":"CustomVoiceNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomVoiceNotFound"}}}},"409":{"description":"CustomVoiceConflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomVoiceConflict"}}}},"422":{"description":"InvalidVoiceUpload","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InvalidVoiceUpload"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}},"502":{"description":"UpstreamError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpstreamError"}}}}},"description":"Upload a speech recording of up to 10 seconds and 5 MB. Requires connections:write and an Idempotency-Key header. Returns a processing record; poll GET /custom-voices/{id} until active. WAV, MP3, FLAC, OGG and M4A are supported.","summary":"Upload a private voice sample","requestBody":{"content":{"multipart/form-data":{"schema":{"type":"object","properties":{"name":{"type":"string"},"language":{"type":"string"},"gender":{"type":"string","enum":["male","female","neutral"]},"audio":{"type":"string","format":"binary"}},"required":["name","language","gender","audio"],"additionalProperties":false}}},"required":true}}},"/custom-voices/{id}":{"get":{"tags":["customVoices"],"operationId":"customVoices.get","parameters":[{"name":"id","in":"path","schema":{"type":"string"},"required":true}],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"language":{"type":"string"},"gender":{"type":"string","enum":["male","female","neutral"]},"status":{"type":"string","enum":["pending","active","failed","expired"]},"failureReason":{"anyOf":[{"type":"string"},{"type":"null"}]},"deletionPending":{"anyOf":[{"type":"boolean"},{"type":"null"}]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","name","language","gender","status","failureReason","createdAt","updatedAt"],"additionalProperties":false}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"404":{"description":"CustomVoiceNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomVoiceNotFound"}}}},"409":{"description":"CustomVoiceConflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomVoiceConflict"}}}},"422":{"description":"InvalidVoiceUpload","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InvalidVoiceUpload"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}},"502":{"description":"UpstreamError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpstreamError"}}}}}},"delete":{"tags":["customVoices"],"operationId":"customVoices.delete","parameters":[{"name":"id","in":"path","schema":{"type":"string"},"required":true}],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["deleted"]}},"required":["status"],"additionalProperties":false}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"404":{"description":"CustomVoiceNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomVoiceNotFound"}}}},"409":{"description":"CustomVoiceConflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomVoiceConflict"}}}},"422":{"description":"InvalidVoiceUpload","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InvalidVoiceUpload"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}},"502":{"description":"UpstreamError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpstreamError"}}}}}}},"/languages":{"get":{"tags":["languages"],"operationId":"languages.list","parameters":[],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"code":{"type":"string","description":"The BCP-47 primary language subtag (e.g. \"en\", \"es\", \"fr\"). Pass it as a connection's `language`."},"name":{"type":"string","description":"The language's English display name (e.g. \"English\", \"Spanish\")."}},"required":["code","name"],"additionalProperties":false,"description":"A spoken language a connection's `language` field can be set to. Use `code` as the connection's `language`."}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}}},"summary":"List the supported spoken languages"}},"/usage":{"get":{"tags":["usage"],"operationId":"usage.summary","parameters":[{"name":"since","in":"query","schema":{"anyOf":[{"type":"string","description":"Lower bound of the reporting window as an ISO-8601 timestamp (e.g. `2026-01-01T00:00:00Z`). Only usage at or after this instant is counted. Omit for all-time totals."},{"type":"null"}]},"required":false}],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"calls":{"type":"object","properties":{"count":{"type":"number"},"totalCostCents":{"type":"number"},"totalDurationSec":{"type":"number"}},"required":["count","totalCostCents","totalDurationSec"],"additionalProperties":false},"messages":{"type":"object","properties":{"count":{"type":"number"}},"required":["count"],"additionalProperties":false},"balanceCents":{"type":"number"}},"required":["calls","messages","balanceCents"],"additionalProperties":false}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}}},"summary":"Get a usage summary (optionally since a timestamp)"}},"/consent":{"get":{"tags":["consent"],"operationId":"consent.list","parameters":[],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"numberId":{"type":"string"},"peerNumber":{"type":"string"},"consentType":{"type":"string","enum":["implied_inbound","explicit_outbound"]},"source":{"type":"string"},"grantedAt":{"type":"string"},"revokedAt":{"anyOf":[{"type":"string"},{"type":"null"}]}},"required":["id","numberId","peerNumber","consentType","source","grantedAt","revokedAt"],"additionalProperties":false}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}}},"summary":"List all consent records in the workspace"},"post":{"tags":["consent"],"operationId":"consent.record","parameters":[],"security":[],"responses":{"201":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"numberId":{"type":"string"},"peerNumber":{"type":"string"},"consentType":{"type":"string","enum":["implied_inbound","explicit_outbound"]},"source":{"type":"string"},"grantedAt":{"type":"string"},"revokedAt":{"anyOf":[{"type":"string"},{"type":"null"}]}},"required":["id","numberId","peerNumber","consentType","source","grantedAt","revokedAt"],"additionalProperties":false}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}}},"summary":"Record consent for a contact","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"numberId":{"type":"string","description":"The id of your number the consent is scoped to."},"peerNumber":{"type":"string","description":"The contact phone number, in E.164 format (e.g. `+14155550123`), that the consent applies to."},"consentType":{"type":"string","enum":["implied_inbound","explicit_outbound"],"description":"How consent was obtained: `implied_inbound` (the contact messaged you first) or `explicit_outbound` (the contact explicitly agreed to be contacted)."},"source":{"type":"string","description":"A free-text note recording where or how consent was captured, kept for your audit trail (e.g. \"web signup form\")."}},"required":["numberId","peerNumber","consentType","source"],"additionalProperties":false,"description":"Record proof of consent for a contact on one of your numbers."}}},"required":true}}},"/consent/revoke":{"post":{"tags":["consent"],"operationId":"consent.revoke","parameters":[],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["revoked"]}},"required":["status"],"additionalProperties":false}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}}},"summary":"Revoke consent for a contact","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"numberId":{"type":"string","description":"The id of your number the consent to revoke is scoped to."},"peerNumber":{"type":"string","description":"The contact phone number, in E.164 format (e.g. `+14155550123`), whose consent should be revoked."}},"required":["numberId","peerNumber"],"additionalProperties":false,"description":"Revoke a previously recorded consent for a contact on one of your numbers."}}},"required":true}}},"/consent/check":{"get":{"tags":["consent"],"operationId":"consent.check","parameters":[{"name":"numberId","in":"query","schema":{"type":"string","description":"The id of your number to check consent against."},"required":true},{"name":"peerNumber","in":"query","schema":{"type":"string","description":"The contact phone number, in E.164 format (e.g. `+14155550123`), to check for active consent."},"required":true}],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"hasConsent":{"type":"boolean"},"type":{"anyOf":[{"type":"string","enum":["implied_inbound","explicit_outbound"]},{"type":"null"}]}},"required":["hasConsent"],"additionalProperties":false}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}}},"summary":"Check whether a contact has active consent"}},"/pricing/quote":{"get":{"tags":["pricing"],"operationId":"pricing.quote","parameters":[{"name":"country","in":"query","schema":{"type":"string","description":"ISO 3166-1 alpha-2 country code to price a number in (e.g. `US`, `GB`)."},"required":true},{"name":"numberType","in":"query","schema":{"type":"string","description":"The kind of number to price (e.g. `local`, `toll_free`, `mobile`, `national`)."},"required":true}],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"customerMonthlyCents":{"type":"number"},"customerUpfrontCents":{"type":"number"}},"required":["customerMonthlyCents","customerUpfrontCents"],"additionalProperties":false}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}}},"summary":"Quote the price of a phone number"}},"/api-tokens":{"get":{"tags":["keys"],"operationId":"keys.list","parameters":[],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"token":{"type":"string"},"prefix":{"type":"string"},"scopes":{"type":"array","items":{"type":"string","enum":["read","write","admin"]}},"lastUsedAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"createdAt":{"type":"string"},"numberScope":{"anyOf":[{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"null"}]},{"type":"null"}]},"spendLimitCents":{"anyOf":[{"anyOf":[{"type":"number"},{"type":"null"}]},{"type":"null"}]},"spendLimitResetPeriod":{"anyOf":[{"anyOf":[{"type":"string","enum":["monthly"]},{"type":"null"}]},{"type":"null"}]},"spentThisPeriodCents":{"anyOf":[{"anyOf":[{"type":"number"},{"type":"null"}]},{"type":"null"}]},"canProvisionKeys":{"anyOf":[{"type":"boolean"},{"type":"null"}]},"permissions":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"null"}]},"mintedByTokenId":{"anyOf":[{"anyOf":[{"type":"string"},{"type":"null"}]},{"type":"null"}]}},"required":["id","name","token","prefix","scopes","lastUsedAt","createdAt"],"additionalProperties":false}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}}},"summary":"List the workspace's API keys"},"post":{"tags":["keys"],"operationId":"keys.mint","parameters":[],"security":[],"responses":{"201":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"prefix":{"type":"string"},"scopes":{"type":"array","items":{"type":"string","enum":["read","write","admin"]}},"lastUsedAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"createdAt":{"type":"string"},"token":{"type":"string"}},"required":["id","name","prefix","scopes","lastUsedAt","createdAt","token"],"additionalProperties":false}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"409":{"description":"IdempotencyConflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IdempotencyConflict"}}}},"422":{"description":"IdempotencyKeyMismatch","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IdempotencyKeyMismatch"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}}},"summary":"Mint a scoped API key","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","allOf":[{"minLength":1},{"maxLength":100}]},"scopes":{"type":"array","items":{"type":"string","enum":["read","write","admin"]},"allOf":[{"minItems":1},{"maxItems":3}]},"numberScope":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"null"}]},"spendLimitCents":{"anyOf":[{"type":"number","allOf":[{"minimum":1}]},{"type":"null"}]},"spendLimitResetPeriod":{"anyOf":[{"anyOf":[{"type":"string","enum":["monthly"]},{"type":"null"}]},{"type":"null"}]}},"required":["name","scopes"],"additionalProperties":false,"description":"The scoped grant for the new key: a coarse `scopes` set (what the key may do), an optional `numberScope` phone-number allow-list (omit or leave empty to allow every number in the workspace), and an optional per-key `spendLimitCents` cap with an optional `spendLimitResetPeriod` (monthly or lifetime). Each of these must stay within the minting key's own ceiling. The plaintext key is returned exactly once, in the response to this call."}}},"required":true}}},"/api-tokens/{id}/revoke":{"post":{"tags":["keys"],"operationId":"keys.revoke","parameters":[{"name":"id","in":"path","schema":{"type":"string","description":"The API key's id."},"required":true}],"security":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["revoked"]}},"required":["status"],"additionalProperties":false}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"403":{"description":"AuthorizationDenied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizationDenied"}}}},"429":{"description":"RateLimited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimited"}}}},"500":{"description":"InternalError","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternalError"}}}}},"summary":"Revoke an API key"}}},"components":{"schemas":{"WorkspaceNotFound":{"type":"object","properties":{"_tag":{"type":"string","enum":["WorkspaceNotFound"]},"slug":{"type":"string"}},"required":["_tag","slug"],"additionalProperties":false},"InternalError":{"type":"object","properties":{"_tag":{"type":"string","enum":["InternalError"]},"traceId":{"type":"string","description":"A correlation id for this failure — quote it when reporting the problem so the request can be traced."}},"required":["_tag","traceId"],"additionalProperties":false},"Unauthorized":{"type":"object","properties":{"_tag":{"type":"string","enum":["Unauthorized"]},"message":{"type":"string","description":"Why the request was rejected (missing, invalid, or insufficient credentials)."}},"required":["_tag","message"],"additionalProperties":false},"AuthorizationDenied":{"type":"object","properties":{"_tag":{"type":"string","enum":["AuthorizationDenied"]},"reason":{"type":"string"}},"required":["_tag","reason"],"additionalProperties":false},"RateLimited":{"type":"object","properties":{"_tag":{"type":"string","enum":["RateLimited"]},"bucket":{"type":"string","description":"The rate-limit bucket that was exhausted."}},"required":["_tag","bucket"],"additionalProperties":false},"AssistantUnavailable":{"type":"object","properties":{"_tag":{"type":"string","enum":["AssistantUnavailable"]},"reason":{"type":"string"}},"required":["_tag","reason"],"additionalProperties":false},"NumberNotFound":{"type":"object","properties":{"_tag":{"type":"string","enum":["NumberNotFound"]},"numberId":{"type":"string"}},"required":["_tag","numberId"],"additionalProperties":false},"CountryNotAvailable":{"type":"object","properties":{"_tag":{"type":"string","enum":["CountryNotAvailable"]},"country":{"type":"string"},"message":{"type":"string"}},"required":["_tag","country","message"],"additionalProperties":false},"NumberQuotaExceeded":{"type":"object","properties":{"_tag":{"type":"string","enum":["NumberQuotaExceeded"]},"limit":{"type":"number"},"current":{"type":"number"}},"required":["_tag","limit","current"],"additionalProperties":false},"PriceChanged":{"type":"object","properties":{"_tag":{"type":"string","enum":["PriceChanged"]},"phoneNumber":{"type":"string"},"actualMonthlyPriceCents":{"type":"number"},"actualUpfrontPriceCents":{"type":"number"},"expectedMonthlyPriceCents":{"type":"number"},"expectedUpfrontPriceCents":{"type":"number"},"currency":{"type":"string"}},"required":["_tag","phoneNumber","actualMonthlyPriceCents","actualUpfrontPriceCents","expectedMonthlyPriceCents","expectedUpfrontPriceCents","currency"],"additionalProperties":false},"IdempotencyConflict":{"type":"object","properties":{"_tag":{"type":"string","enum":["IdempotencyConflict"]},"message":{"type":"string","description":"Details of the conflict — a concurrent request is still processing under the same `Idempotency-Key`."}},"required":["_tag","message"],"additionalProperties":false},"NoNumbersAvailable":{"type":"object","properties":{"_tag":{"type":"string","enum":["NoNumbersAvailable"]},"country":{"type":"string"},"numberType":{"type":"string"}},"required":["_tag","country","numberType"],"additionalProperties":false},"InsufficientFunds":{"type":"object","properties":{"_tag":{"type":"string","enum":["InsufficientFunds"]},"balanceCents":{"type":"number"},"requestedCents":{"type":"number"}},"required":["_tag","balanceCents","requestedCents"],"additionalProperties":false},"PaymentMethodRequired":{"type":"object","properties":{"_tag":{"type":"string","enum":["PaymentMethodRequired"]},"activeNumbers":{"type":"number"},"message":{"type":"string"}},"required":["_tag","activeNumbers","message"],"additionalProperties":false},"UpstreamError":{"type":"object","properties":{"_tag":{"type":"string","enum":["UpstreamError"]},"status":{"type":"number","allOf":[{"description":"The HTTP status the carrier returned upstream."}]},"code":{"type":"string","description":"A short machine-readable code for the upstream failure."},"message":{"type":"string","description":"A human-readable description of the upstream failure (carrier identity scrubbed)."}},"required":["_tag","status","code","message"],"additionalProperties":false},"IdempotencyKeyMismatch":{"type":"object","properties":{"_tag":{"type":"string","enum":["IdempotencyKeyMismatch"]},"message":{"type":"string","description":"Why the `Idempotency-Key` is unprocessable — either malformed (e.g. over the length cap) or reused for a request with a different payload."}},"required":["_tag","message"],"additionalProperties":false},"InvalidSmsSenderId":{"type":"object","properties":{"_tag":{"type":"string","enum":["InvalidSmsSenderId"]},"reason":{"type":"string"}},"required":["_tag","reason"],"additionalProperties":false},"InvalidCallerIdName":{"type":"object","properties":{"_tag":{"type":"string","enum":["InvalidCallerIdName"]},"reason":{"type":"string"}},"required":["_tag","reason"],"additionalProperties":false},"ConnectionNotFound":{"type":"object","properties":{"_tag":{"type":"string","enum":["ConnectionNotFound"]},"id":{"type":"string"}},"required":["_tag","id"],"additionalProperties":false},"UnsupportedModel":{"type":"object","properties":{"_tag":{"type":"string","enum":["UnsupportedModel"]},"field":{"type":"string"},"model":{"type":"string"},"message":{"type":"string"}},"required":["_tag","field","model","message"],"additionalProperties":false},"UnsupportedVoice":{"type":"object","properties":{"_tag":{"type":"string","enum":["UnsupportedVoice"]},"field":{"type":"string"},"voice":{"type":"string"},"message":{"type":"string"}},"required":["_tag","field","voice","message"],"additionalProperties":false},"AudioConfigurationError":{"type":"object","properties":{"_tag":{"type":"string","enum":["AudioConfigurationError"]},"message":{"type":"string"}},"required":["_tag","message"],"additionalProperties":false},"RecipientOptedOut":{"type":"object","properties":{"_tag":{"type":"string","enum":["RecipientOptedOut"]},"to":{"type":"string"}},"required":["_tag","to"],"additionalProperties":false},"MessageSendFailed":{"type":"object","properties":{"_tag":{"type":"string","enum":["MessageSendFailed"]},"reason":{"type":"string"}},"required":["_tag","reason"],"additionalProperties":false},"DestinationNotSupported":{"type":"object","properties":{"_tag":{"type":"string","enum":["DestinationNotSupported"]},"to":{"type":"string"}},"required":["_tag","to"],"additionalProperties":false},"SpendLimitExceeded":{"type":"object","properties":{"_tag":{"type":"string","enum":["SpendLimitExceeded"]},"limitCents":{"type":"number"},"priorSpendCents":{"type":"number"},"requestedCents":{"type":"number"}},"required":["_tag","limitCents","priorSpendCents","requestedCents"],"additionalProperties":false},"NumberHasNoConnection":{"type":"object","properties":{"_tag":{"type":"string","enum":["NumberHasNoConnection"]},"numberId":{"type":"string"}},"required":["_tag","numberId"],"additionalProperties":false},"CallStartFailed":{"type":"object","properties":{"_tag":{"type":"string","enum":["CallStartFailed"]},"reason":{"type":"string"}},"required":["_tag","reason"],"additionalProperties":false},"CallNotFound":{"type":"object","properties":{"_tag":{"type":"string","enum":["CallNotFound"]},"callId":{"type":"string"}},"required":["_tag","callId"],"additionalProperties":false},"CustomVoiceConflict":{"type":"object","properties":{"_tag":{"type":"string","enum":["CustomVoiceConflict"]},"code":{"type":"string","enum":["not_ready","in_use","conflict"]},"message":{"type":"string"}},"required":["_tag","code","message"],"additionalProperties":false},"CustomVoiceNotFound":{"type":"object","properties":{"_tag":{"type":"string","enum":["CustomVoiceNotFound"]},"message":{"type":"string"}},"required":["_tag","message"],"additionalProperties":false},"InvalidVoiceUpload":{"type":"object","properties":{"_tag":{"type":"string","enum":["InvalidVoiceUpload"]},"message":{"type":"string"}},"required":["_tag","message"],"additionalProperties":false}},"securitySchemes":{}},"security":[],"tags":[{"name":"health","description":"Service liveness. A lightweight, unauthenticated probe for uptime checks and load balancers."},{"name":"workspace","description":"Workspace administration — read the members, API tokens, webhook endpoints, and audit log for a workspace. Dashboard/management routes keyed by the workspace slug in the path."},{"name":"api-token-registry","description":"Manage the scoped `sk_` API keys agents use to call Saperly. Each key carries a set of scopes, an optional number allow-list, and an optional spend cap; revoke a key when it is no longer needed."},{"name":"workspace-invitations","description":"Invite teammates to a workspace by email address."},{"name":"assistant","description":"Ask the built-in workspace assistant a natural-language question and get a text answer back. Backed by an in-network model; availability depends on the operator configuration."},{"name":"numbers","description":"Phone numbers — provision, list, release, and configure the lines in your workspace. Bind a connection to a number to make it answer calls and messages, set a per-number webhook, and override the SMS sender id or caller ID name. The fleet belongs to the workspace your API key resolves to."},{"name":"connections","description":"Connections — the handler bound to a phone number that answers and talks. Hosted lines run an in-network voice assistant (pick the model, voice, language, and MCP tools); manual lines forward turns to your own brain. Audio always stays in-network."},{"name":"messaging","description":"Send and list SMS messages on your numbers. Outbound sends are billed per segment and pass through opt-out (STOP) and spend-limit enforcement before reaching the carrier; inbound messages are recorded against the receiving number."},{"name":"voice","description":"Place and control outbound calls and fetch call records. Audio always stays in-network — there is no live media-control surface here by design. Funds are reserved on start and settled from the carrier-reported duration on end."},{"name":"voices","description":"Discover the in-network text-to-speech voices a hosted connection can speak with. Each voice carries its language, so this endpoint also doubles as the catalogue of supported spoken languages (use a voice's `language` value for a connection's `language` field)."},{"name":"customVoices"},{"name":"languages","description":"Discover the spoken languages a connection can use (its `language` field). The list is derived from the voice catalogue — every language here has at least one voice that speaks it (see `GET /voices`) — and is ordered most-supported first. Any well-formed BCP-47 tag is also accepted on a connection; this is the curated, recommended set."},{"name":"usage","description":"Read metered usage for the workspace — call and message counts, total call cost and duration, and the current prepaid balance. Aggregated over an optional time window; the balance is point-in-time."},{"name":"consent","description":"Track opt-in consent for contacts on your numbers. Record, revoke, list, and check the consent that backs your outbound messaging compliance. (Inbound STOP/START opt-out is handled automatically by the carrier-side keyword path.)"},{"name":"pricing","description":"Pricing — get a live quote for what a phone number will cost before you provision it. Returns the customer-facing monthly and upfront prices for a given country and number type, so you can confirm the cost up front and pass it to `POST /numbers` as the `expected*` price."},{"name":"keys","description":"Provision and manage scoped `sk_` API keys for the workspace. The workspace is always read from the calling key, never from client input. A key holding the `keys:admin` scope can mint child keys (and list/revoke the workspace's keys), bounded by the parent ceiling: a child's scopes, number allow-list, and spend cap must each be a subset of the minting key's own grant."}],"servers":[{"url":"/","description":"This worker"}]}