{"openapi":"3.1.0","jsonSchemaDialect":"https://json-schema.org/draft/2020-12/schema","info":{"title":"SMS Hub API","version":"0.1.0","description":"Asynchronous SMS forwarding and app-scoped reporting. 202 means durable hub acceptance, not broker acceptance or delivery. Requests are authenticated with application bearer tokens. Queues and callbacks are at-least-once. Same phone number + exact same SMS text returns the existing message ID within the five-minute minimum window and while a bounded pending/uncertain hold remains (default 72 hours from admission). Matching is scoped to application and environment. Idempotency-Key retries remain protected for seven days after the original claim."},"servers":[{"url":"/","description":"This deployment"}],"tags":[{"name":"Messages","description":"Authenticated application send API"},{"name":"Reporting","description":"Authenticated, best-effort reporting history and aggregates"},{"name":"Broker receipts","description":"Signed terminal delivery reports for the JSON/HTTPS adapter"},{"name":"Public","description":"Unauthenticated health and callback verification key"}],"paths":{"/api/v1/messages":{"get":{"operationId":"listMessageHistory","tags":["Reporting"],"summary":"List persisted message metadata","description":"Application and environment are derived from the bearer token and VERCEL_ENV (development when unset); there is no cross-app or environment selector. Filters are strict: unknown or duplicate query parameters return 400. The window is inclusive from and exclusive to, based on messages.createdAt, defaulting to the last 24 hours and limited to 31 days. Pages are newest first, keyset ordered by createdAt then messageId. Cursors freeze the window; there is no total count. Results are best-effort history, not billing or an audit record. No destination, content, callback URL, client reference or provider message ID is returned.","security":[{"ApplicationBearer":[]}],"parameters":[{"name":"from","in":"query","required":false,"description":"Inclusive UTC ISO-8601 start with seconds and at most 3 fractional digits; defaults to 24 hours before to.","schema":{"type":"string","allOf":[{"pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"},{"pattern":"^(?!0000)\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,3})?Z$"}]}},{"name":"to","in":"query","required":false,"description":"Exclusive UTC ISO-8601 end with seconds and at most 3 fractional digits; defaults to the current time. Maximum window is 31 days.","schema":{"type":"string","allOf":[{"pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"},{"pattern":"^(?!0000)\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,3})?Z$"}]}},{"name":"route","in":"query","required":false,"description":"Optional historical route filter; no route permission is required.","schema":{"type":"string","pattern":"^[a-zA-Z0-9_-]{1,64}$"}},{"name":"limit","in":"query","required":false,"description":"Page size from 1 to 100; defaults to 50.","schema":{"type":"string","pattern":"^(?:[1-9]\\d?|100)$"}},{"name":"cursor","in":"query","required":false,"description":"Opaque keyset cursor. Reuse the same filters and window, or omit from/to because the cursor freezes the window.","schema":{"type":"string","minLength":1,"maxLength":2048,"pattern":"^[A-Za-z0-9_-]+$"}},{"name":"messageId","in":"query","required":false,"description":"Optional message ID filter.","schema":{"type":"string","pattern":"^sms_[a-f0-9]{64}$"}}],"responses":{"200":{"description":"A page of message metadata.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageHistory"}}}},"400":{"description":"Invalid, duplicate or unknown query parameter.","headers":{"X-Request-Id":{"description":"Hub-generated request correlation ID; public errors remain generic.","schema":{"type":"string","format":"uuid"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid application bearer token.","headers":{"X-Request-Id":{"description":"Hub-generated request correlation ID; public errors remain generic.","schema":{"type":"string","format":"uuid"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Reporting data is unavailable, disabled or invalid.","headers":{"X-Request-Id":{"description":"Hub-generated request correlation ID; public errors remain generic.","schema":{"type":"string","format":"uuid"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"sendSms","tags":["Messages"],"summary":"Accept an SMS for asynchronous forwarding","description":"Body limit: 16 KiB. Requires an allowed route and valid configuration. Default routes are transactional (also the request default) and marketing, using priority: SMS Barato first, SMS Dev only after proven non-acceptance. Adaptive provider-progress routing with exploration is opt-in per route, not a fastest-handset-delivery guarantee. Optional provider pins submission to an enabled broker without fallback; omit for automatic routing and safe fallback only after proven non-acceptance. Adaptive routes exclude locked candidates from new sends, never resubmitting after acceptance. On adaptive routes, pinned/all-provider locks or unavailable routing storage return 503 before workflow start; established duplicates retain their original acceptance. Preview/development sends are disabled by default. Callback destinations receive additional runtime SSRF checks; expiry must be future and within 24 hours. Mandatory fail-closed admission suppresses matching E.164 destination and exact text for the minimum duplicate window (default 300 seconds, allowed 1–86400) plus a pending/uncertain hold (default 259200 seconds from first admission), scoped per app/environment. Definitive completion/non-acceptance releases only the pending hold; SMS Barato sent is not confirmed handset delivery and does not release it. Route, provider, callback URL, client reference, expiry, and Idempotency-Key are not part of that fingerprint. The first admitted workflow claimant supplies the canonical payload; responses retain the current clientReference. Request keys remain aliases for seven days. Workflow ownership remains the final replay safeguard; this is not rate limiting and does not eliminate provider replay risk.","security":[{"ApplicationBearer":[]}],"parameters":[{"name":"Idempotency-Key","in":"header","required":true,"description":"Required logical-request key scoped to application and environment. Coalesced keys retain the canonical message ID until seven days after the original claim. Keep the entire request, including callbackUrl, unchanged on retries; content admission can also coalesce different keys.","schema":{"type":"string","pattern":"^[\\x21-\\x7e]{1,128}$"},"example":"login-attempt-123"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendSmsRequest"},"example":{"to":"+5511999999999","text":"Your verification code is 123456","route":"transactional","provider":"sms-dev","clientReference":"login-attempt-123","callbackUrl":"https://your-app.example.com/webhooks/sms"}}}},"responses":{"202":{"description":"Durably accepted for processing. This does not confirm upstream or handset delivery.","headers":{"X-Request-Id":{"description":"Hub-generated request correlation ID; public errors remain generic.","schema":{"type":"string","format":"uuid"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Accepted"},"example":{"messageId":"sms_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","status":"accepted","clientReference":"login-attempt-123"}}}},"400":{"description":"Invalid JSON, SMS payload, callback URL, expiry or idempotency key; provider unknown, disabled or not in the selected route.","headers":{"X-Request-Id":{"description":"Hub-generated request correlation ID; public errors remain generic.","schema":{"type":"string","format":"uuid"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid application bearer token.","headers":{"X-Request-Id":{"description":"Hub-generated request correlation ID; public errors remain generic.","schema":{"type":"string","format":"uuid"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Route forbidden or sends disabled outside production.","headers":{"X-Request-Id":{"description":"Hub-generated request correlation ID; public errors remain generic.","schema":{"type":"string","format":"uuid"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Request body exceeds 16 KiB.","headers":{"X-Request-Id":{"description":"Hub-generated request correlation ID; public errors remain generic.","schema":{"type":"string","format":"uuid"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"415":{"description":"Content-Type must be application/json.","headers":{"X-Request-Id":{"description":"Hub-generated request correlation ID; public errors remain generic.","schema":{"type":"string","format":"uuid"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Configuration, mandatory anti-spam admission storage, or durable execution unavailable. Retry the unchanged request with the same idempotency key.","headers":{"X-Request-Id":{"description":"Hub-generated request correlation ID; public errors remain generic.","schema":{"type":"string","format":"uuid"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"callbacks":{"smsStatus":{"{$request.body#/callbackUrl}":{"post":{"operationId":"receiveSmsStatus","summary":"Receive a signed asynchronous SMS status","description":"Only sent when callbackUrl is provided. Accepted SMS Barato and SMS Dev submissions with a provider ID receive up to 84 read-only status lookups over at most 72 hours. New submissions wait one minute for each of the first ten attempts, then 5, 15, and 30 minutes, then hourly. Pending results and transient failures share this budget. Distinct statuses emit queued or sending, followed by sent/send_failed for SMS Barato or delivered/undeliverable for SMS Dev; sent is not confirmed handset delivery. Terminal results stop monitoring; permanent lookup failures, deadline expiry or exhaustion yield delivery_unknown. Unknown or malformed provider responses never establish delivery. No status lookup result triggers resubmission or broker fallback. Historical workflows retain their persisted monitoring policy. Verify Ed25519 over x-sms-timestamp + \".\" + exact raw body using a pinned trusted public key. Enforce timestamp skew, correlate message ownership and deduplicate body eventId. Delivery is at-least-once and may be out of order. Callback failure never resends the SMS. Callback retry budget is bounded; most 4xx are permanent, while 408/429 and 5xx retry.","security":[],"parameters":[{"name":"x-sms-signature","in":"header","required":true,"schema":{"type":"string"},"description":"Base64 Ed25519 signature over timestamp.rawBody."},{"name":"x-sms-timestamp","in":"header","required":true,"schema":{"type":"string","pattern":"^\\d+$"},"description":"Unix seconds when this delivery attempt was signed."},{"name":"x-sms-key-id","in":"header","required":true,"schema":{"type":"string"},"description":"Pinned verification key identifier."},{"name":"x-sms-event-id","in":"header","required":true,"schema":{"type":"string"},"description":"Same event ID as the signed body. Deduplicate using the body value."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SmsStatusEvent"},"example":{"schemaVersion":1,"eventId":"evt_bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb","type":"sms.submitted","messageId":"sms_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","clientReference":"login-attempt-123","occurredAt":"2026-10-05T18:00:05Z","data":{"status":"submitted","brokerId":"sms-dev"}}}}},"responses":{"200":{"description":"Receiver acknowledges the event. Any 2xx response is accepted."},"429":{"description":"Receiver temporarily unavailable; hub retries with backoff."},"500":{"description":"Temporary receiver failure; hub retries with backoff."}}}}}}}},"/api/v1/logs":{"get":{"operationId":"listLifecycleLogs","tags":["Reporting"],"summary":"List lifecycle events for messages in a created-time cohort","description":"Application and environment are derived from the bearer token and VERCEL_ENV (development when unset); there is no cross-app or environment selector. Filters are strict: unknown or duplicate query parameters return 400. The inclusive-from/exclusive-to window (default last 24 hours, maximum 31 days) selects messages by messages.createdAt; event occurredAt may be outside that window. Late and conflicting statuses are preserved. Pages are newest first, keyset ordered by recordedAt then eventId. Cursors freeze the window; there is no total count. Results are best-effort history, not billing or an audit record.","security":[{"ApplicationBearer":[]}],"parameters":[{"name":"from","in":"query","required":false,"description":"Inclusive UTC ISO-8601 start with seconds and at most 3 fractional digits; defaults to 24 hours before to.","schema":{"type":"string","allOf":[{"pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"},{"pattern":"^(?!0000)\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,3})?Z$"}]}},{"name":"to","in":"query","required":false,"description":"Exclusive UTC ISO-8601 end with seconds and at most 3 fractional digits; defaults to the current time. Maximum window is 31 days.","schema":{"type":"string","allOf":[{"pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"},{"pattern":"^(?!0000)\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,3})?Z$"}]}},{"name":"route","in":"query","required":false,"description":"Optional historical route filter; no route permission is required.","schema":{"type":"string","pattern":"^[a-zA-Z0-9_-]{1,64}$"}},{"name":"limit","in":"query","required":false,"description":"Page size from 1 to 100; defaults to 50.","schema":{"type":"string","pattern":"^(?:[1-9]\\d?|100)$"}},{"name":"cursor","in":"query","required":false,"description":"Opaque keyset cursor. Reuse the same filters and window, or omit from/to because the cursor freezes the window.","schema":{"type":"string","minLength":1,"maxLength":2048,"pattern":"^[A-Za-z0-9_-]+$"}},{"name":"messageId","in":"query","required":false,"description":"Optional message ID filter.","schema":{"type":"string","pattern":"^sms_[a-f0-9]{64}$"}},{"name":"status","in":"query","required":false,"description":"Optional lifecycle status filter.","schema":{"type":"string","enum":["submitted","rejected","expired","acceptance_unknown","delivered","undeliverable","delivery_unknown","queued","sending","sent","send_failed"]}}],"responses":{"200":{"description":"A page of lifecycle events.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LifecycleLogs"}}}},"400":{"description":"Invalid, duplicate or unknown query parameter.","headers":{"X-Request-Id":{"description":"Hub-generated request correlation ID; public errors remain generic.","schema":{"type":"string","format":"uuid"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid application bearer token.","headers":{"X-Request-Id":{"description":"Hub-generated request correlation ID; public errors remain generic.","schema":{"type":"string","format":"uuid"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Reporting data is unavailable, disabled or invalid.","headers":{"X-Request-Id":{"description":"Hub-generated request correlation ID; public errors remain generic.","schema":{"type":"string","format":"uuid"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/metrics":{"get":{"operationId":"getReportingMetrics","tags":["Reporting"],"summary":"Get aggregate reporting metrics","description":"Application and environment are derived from the bearer token and VERCEL_ENV (development when unset); there is no cross-app or environment selector. Filters are strict: unknown or duplicate query parameters return 400. The inclusive-from/exclusive-to window (default last 24 hours, maximum 31 days) selects messages by messages.createdAt. Metrics use independent queries and are not an atomic snapshot. totalMessages counts persisted workflow metadata, not successful sends. eventsByStatus counts raw events and distinct messages per status; statuses can overlap and must not be summed as final outcomes. callbacksByOutcome counts HTTP webhook delivery attempts/outcomes, not SMS delivery. Results are best-effort reporting, not billing, audit, readiness, provider balance, raw Vercel or Sentry logs.","security":[{"ApplicationBearer":[]}],"parameters":[{"name":"from","in":"query","required":false,"description":"Inclusive UTC ISO-8601 start with seconds and at most 3 fractional digits; defaults to 24 hours before to.","schema":{"type":"string","allOf":[{"pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"},{"pattern":"^(?!0000)\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,3})?Z$"}]}},{"name":"to","in":"query","required":false,"description":"Exclusive UTC ISO-8601 end with seconds and at most 3 fractional digits; defaults to the current time. Maximum window is 31 days.","schema":{"type":"string","allOf":[{"pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"},{"pattern":"^(?!0000)\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,3})?Z$"}]}},{"name":"route","in":"query","required":false,"description":"Optional historical route filter; no route permission is required.","schema":{"type":"string","pattern":"^[a-zA-Z0-9_-]{1,64}$"}}],"responses":{"200":{"description":"Aggregate reporting metrics.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Metrics"}}}},"400":{"description":"Invalid, duplicate or unknown query parameter.","headers":{"X-Request-Id":{"description":"Hub-generated request correlation ID; public errors remain generic.","schema":{"type":"string","format":"uuid"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid application bearer token.","headers":{"X-Request-Id":{"description":"Hub-generated request correlation ID; public errors remain generic.","schema":{"type":"string","format":"uuid"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Reporting data is unavailable, disabled or invalid.","headers":{"X-Request-Id":{"description":"Hub-generated request correlation ID; public errors remain generic.","schema":{"type":"string","format":"uuid"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/webhooks/brokers/{brokerId}":{"post":{"operationId":"acceptBrokerReceipt","tags":["Broker receipts"],"summary":"Accept a signed broker delivery receipt","description":"JSON/HTTPS adapter contract, not a universal provider format. HMAC-SHA256(webhookSecret, timestamp + \".\" + exact raw body), hex-encoded. Timestamp must be within five minutes. Requires a configured statusMap entry and echoed hub message reference. Extra provider JSON fields are stripped. Receipts are acknowledged only after durable queue publication; unknown message references are quarantined asynchronously.","security":[{"BrokerHmac":[]}],"parameters":[{"name":"brokerId","in":"path","required":true,"schema":{"type":"string","pattern":"^[a-zA-Z0-9_-]{1,64}$"},"description":"Configured broker identifier.","example":"primary"},{"name":"x-sms-timestamp","in":"header","required":true,"schema":{"type":"string","pattern":"^\\d{10}$"},"description":"Unix seconds, within five minutes of hub time."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BrokerReceipt"},"example":{"eventId":"provider-event-123","reference":"sms_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","status":"delivered","occurredAt":"2026-10-05T18:00:05Z"}}}},"responses":{"202":{"description":"Receipt durably queued, not necessarily correlated or forwarded yet.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Acknowledgement"}}}},"400":{"description":"Invalid JSON, receipt or unmapped terminal status.","headers":{"X-Request-Id":{"description":"Hub-generated request correlation ID; public errors remain generic.","schema":{"type":"string","format":"uuid"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Invalid signature or timestamp.","headers":{"X-Request-Id":{"description":"Hub-generated request correlation ID; public errors remain generic.","schema":{"type":"string","format":"uuid"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown broker.","headers":{"X-Request-Id":{"description":"Hub-generated request correlation ID; public errors remain generic.","schema":{"type":"string","format":"uuid"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Body exceeds 16 KiB.","headers":{"X-Request-Id":{"description":"Hub-generated request correlation ID; public errors remain generic.","schema":{"type":"string","format":"uuid"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Configuration or durable queue unavailable.","headers":{"X-Request-Id":{"description":"Hub-generated request correlation ID; public errors remain generic.","schema":{"type":"string","format":"uuid"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/healthz":{"get":{"operationId":"health","tags":["Public"],"summary":"Check service liveness","description":"Does not check broker readiness, credentials or queue availability.","security":[],"responses":{"200":{"description":"Service is responding.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Health"}}}}}}},"/api/v1/signing-key":{"get":{"operationId":"getCallbackSigningKey","tags":["Public"],"summary":"Get the callback verification public key","description":"Ed25519 SPKI PEM. Pin trusted keys; do not treat a key from an untrusted deployment as authorization. No private key or credentials are exposed.","security":[],"responses":{"200":{"description":"Current callback public key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SigningKey"}}}},"503":{"description":"Signing key is unavailable or invalid.","headers":{"X-Request-Id":{"description":"Hub-generated request correlation ID; public errors remain generic.","schema":{"type":"string","format":"uuid"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"securitySchemes":{"ApplicationBearer":{"type":"http","scheme":"bearer","description":"Application API token, not a JWT. Sent as Authorization: Bearer <token>."},"BrokerHmac":{"type":"apiKey","in":"header","name":"x-sms-signature","description":"64 hexadecimal characters: HMAC-SHA256(timestamp.rawBody). Requires x-sms-timestamp as well; see receipt operation."}},"schemas":{"SendSmsRequest":{"type":"object","properties":{"to":{"type":"string","pattern":"^\\+[1-9]\\d{7,14}$","description":"E.164 destination phone number."},"text":{"type":"string","minLength":1,"maxLength":1600,"description":"SMS text. Character count does not guarantee segment count or cost."},"route":{"default":"transactional","description":"Configured route permitted for the authenticated application.","type":"string","pattern":"^[a-zA-Z0-9_-]{1,64}$"},"provider":{"description":"Optional configured broker ID (sms-barato or sms-dev in the default configuration). Must be enabled and belong to the permitted route. Pins submission to this provider without fallback; omit for automatic routing.","type":"string","pattern":"^[a-zA-Z0-9_-]{1,64}$"},"clientReference":{"description":"Caller reference echoed in status callbacks.","type":"string","maxLength":256},"callbackUrl":{"description":"Per-request public HTTPS URL on port 443, without credentials. Redirects are not followed; DNS and connected address must be public. Omit for fire-and-forget.","type":"string","maxLength":2048},"expiresAt":{"description":"UTC expiry within the next 24 hours. Defaults to five minutes from acceptance; checked before every broker submission.","type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"}},"required":["to","text"],"additionalProperties":false},"BrokerReceipt":{"type":"object","properties":{"eventId":{"type":"string","minLength":1,"maxLength":128,"description":"Provider event identifier, stable across retries."},"reference":{"type":"string","pattern":"^sms_[a-f0-9]{64}$","description":"Hub message ID echoed by the broker."},"status":{"type":"string","minLength":1,"maxLength":100,"description":"Provider terminal status configured in the broker statusMap."},"occurredAt":{"type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"}},"required":["eventId","reference","status","occurredAt"]},"Accepted":{"type":"object","properties":{"messageId":{"type":"string","pattern":"^sms_[a-f0-9]{64}$"},"status":{"type":"string","const":"accepted"},"clientReference":{"type":"string","maxLength":256}},"required":["messageId","status"],"additionalProperties":false},"Error":{"type":"object","properties":{"error":{"type":"string"}},"required":["error"],"additionalProperties":false},"Acknowledgement":{"type":"object","properties":{"accepted":{"type":"boolean","const":true}},"required":["accepted"],"additionalProperties":false},"Health":{"type":"object","properties":{"status":{"type":"string","const":"ok"},"service":{"type":"string","const":"sms-hub"}},"required":["status","service"],"additionalProperties":false},"SigningKey":{"type":"object","properties":{"keyId":{"type":"string"},"algorithm":{"type":"string","const":"Ed25519"},"publicKey":{"type":"string","description":"SPKI PEM public key. Pin trusted keys and retain old keys while deployments drain."}},"required":["keyId","algorithm","publicKey"],"additionalProperties":false},"SmsStatusEvent":{"type":"object","properties":{"schemaVersion":{"type":"number","const":1},"eventId":{"type":"string","minLength":1,"maxLength":256,"pattern":"^[\\x21-\\x7e]+$","description":"Opaque, stable ASCII-safe hub identifier; do not parse it. Deduplicate this identifier. Events may repeat or arrive out of order."},"type":{"type":"string","enum":["sms.submitted","sms.rejected","sms.expired","sms.acceptance_unknown","sms.delivered","sms.undeliverable","sms.delivery_unknown","sms.queued","sms.sending","sms.sent","sms.send_failed"]},"messageId":{"type":"string","pattern":"^sms_[a-f0-9]{64}$"},"clientReference":{"type":"string","maxLength":256},"occurredAt":{"type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"},"data":{"type":"object","properties":{"status":{"type":"string","enum":["submitted","rejected","expired","acceptance_unknown","delivered","undeliverable","delivery_unknown","queued","sending","sent","send_failed"]},"brokerId":{"type":"string"},"providerMessageId":{"type":"string","maxLength":256},"safeToFailover":{"type":"boolean"}},"required":["status"],"additionalProperties":false}},"required":["schemaVersion","eventId","type","messageId","occurredAt","data"],"additionalProperties":false},"MessageHistory":{"type":"object","properties":{"window":{"type":"object","properties":{"environment":{"type":"string"},"from":{"type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"},"to":{"type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"},"route":{"type":"string"}},"required":["environment","from","to"],"additionalProperties":false},"items":{"type":"array","items":{"type":"object","properties":{"messageId":{"type":"string","pattern":"^sms_[a-f0-9]{64}$"},"route":{"type":"string"},"createdAt":{"type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"},"expiresAt":{"type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"},"textLength":{"type":"integer","minimum":0,"maximum":9007199254740991},"callbackRequested":{"type":"boolean"}},"required":["messageId","route","createdAt","expiresAt","textLength","callbackRequested"],"additionalProperties":false}},"nextCursor":{"type":["string","null"]}},"required":["window","items","nextCursor"],"additionalProperties":false},"LifecycleLogs":{"type":"object","properties":{"window":{"type":"object","properties":{"environment":{"type":"string"},"from":{"type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"},"to":{"type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"},"route":{"type":"string"}},"required":["environment","from","to"],"additionalProperties":false},"items":{"type":"array","items":{"type":"object","properties":{"eventId":{"type":"string"},"messageId":{"type":"string","pattern":"^sms_[a-f0-9]{64}$"},"status":{"type":"string"},"brokerId":{"type":["string","null"]},"occurredAt":{"type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"},"recordedAt":{"type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"}},"required":["eventId","messageId","status","brokerId","occurredAt","recordedAt"],"additionalProperties":false}},"nextCursor":{"type":["string","null"]}},"required":["window","items","nextCursor"],"additionalProperties":false},"Metrics":{"type":"object","properties":{"window":{"type":"object","properties":{"environment":{"type":"string"},"from":{"type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"},"to":{"type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"},"route":{"type":"string"}},"required":["environment","from","to"],"additionalProperties":false},"totalMessages":{"type":"integer","minimum":0,"maximum":9007199254740991},"messagesByDay":{"type":"array","items":{"type":"object","properties":{"day":{"type":"string","format":"date","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"},"route":{"type":"string"},"messages":{"type":"integer","minimum":0,"maximum":9007199254740991}},"required":["day","route","messages"],"additionalProperties":false}},"eventsByStatus":{"type":"array","items":{"type":"object","properties":{"status":{"type":"string"},"events":{"type":"integer","minimum":0,"maximum":9007199254740991},"messages":{"type":"integer","minimum":0,"maximum":9007199254740991}},"required":["status","events","messages"],"additionalProperties":false}},"callbacksByOutcome":{"type":"array","items":{"type":"object","properties":{"outcome":{"type":"string"},"attempts":{"type":"integer","minimum":0,"maximum":9007199254740991},"messages":{"type":"integer","minimum":0,"maximum":9007199254740991}},"required":["outcome","attempts","messages"],"additionalProperties":false}}},"required":["window","totalMessages","messagesByDay","eventsByStatus","callbacksByOutcome"],"additionalProperties":false}}}}