API reference
The complete HTTP API is described in OpenAPI 3.1:
openapi.yaml (source:
spec/openapi.yaml). Load it
into any OpenAPI viewer or client generator. A test fails the build if a route the relay serves
is missing from it.
Base URLs: https://subetha.us (production), https://staging.subetha.us (staging, providers
in test mode), http://localhost:8787 (wrangler dev).
Routes at a glance
| Area | Routes |
|---|---|
| Publish (ntfy) | PUT/POST /{topic}, POST / (JSON), GET /file/{id}/{name} (attachments) |
| Subscribe (ntfy) | GET /{topics}/json, /sse, /raw, /ws, /auth; ?poll=1, since, priority, tags |
| Meta | GET /v1/health, /v1/status, /v1/prices, /v1/config |
| Account & billing | GET/POST/PATCH /v1/account, GET /v1/balance, GET /v1/ledger, GET /v1/payments, GET /v1/payments/{id}/receipt, POST /v1/billing/checkout |
| Tokens | GET/POST /v1/tokens, DELETE /v1/tokens/{id} |
| Topics | GET /v1/topics, GET/PUT /v1/topics/{topic} |
| Traces & acks | GET /v1/traces/{id}?topic=, POST /v1/ack |
| Endpoints | GET/POST /v1/endpoints, POST /v1/endpoints/{id}/verify, DELETE /v1/endpoints/{id} |
| Subscriptions | GET/POST /v1/subscriptions, DELETE /v1/subscriptions/{id} |
| Slack | GET /v1/slack/install, GET /v1/slack/oauth, POST /v1/slack/bindings |
| Devices | GET /v1/devices, PATCH/DELETE /v1/devices/{id}, POST /v1/devices/dba (attach a signing key), GET/DELETE /v1/dba/link, POST /v1/dba/link/start, /v1/dba/link/finish (devicebasedauth.org). Retired (410): POST /v1/devices, /v1/device/code, /approve, /token |
| Agents | POST /mcp, GET /.well-known/oauth-protected-resource |
| Provider hooks | POST /v1/hooks/stripe, /v1/hooks/twilio/sms, /v1/hooks/twilio/voice-ack, /v1/hooks/slack/events |
| Local only | POST /v1/dev/bootstrap |
Conventions
- Auth:
Authorization: Bearer <token>; HTTP Basic with an empty user and the token as the password;?auth=<base64url("Bearer <token>")>; or device request signatures (Devices). - Money is integer micro-dollars in responses (
*_usd_micros); request fields that take dollars are named*_usd. - Times are Unix seconds in messages and milliseconds in control-plane records
(
created_at). - CORS is open: the API is meant to be called from web pages with publishable tokens.
X-Cost-Micros,X-Message-Id, andRetry-Afterare exposed to scripts. - Rate limits: 600 requests/minute per credential, 60/minute per IP without one;
429withRetry-Afterwhen exceeded.
Errors
Every error is JSON with a stable error code, the HTTP status, and a human-readable message,
plus fields specific to the error (shortfall_usd_micros on 402):
{ "error": "spend_cap_exceeded", "http": 403, "message": "topic daily cap reached", "cap": "topic_daily" }| Code | HTTP | Meaning |
|---|---|---|
bad_request |
400 | Malformed request. |
invalid_topic |
400 | Topic name does not match the topic grammar. |
invalid_message |
400 | Envelope failed validation. |
message_too_large |
413 | Message body exceeds 4096 bytes (use an attachment). |
unsupported |
400 | Feature not supported in this version (e.g. X-Delay). |
unauthorized |
401 | Missing or invalid credentials. |
signature_required |
401 | Topic policy requires a device signature. |
bad_signature |
401 | Signature does not verify against the sender id. |
insufficient_balance |
402 | Payer balance cannot cover the worst-case cost. Body carries shortfall_usd_micros. |
no_funded_owner |
402 | Anonymous publish to a topic with no funded owner. |
forbidden |
403 | Token scope or policy forbids this action. |
spend_cap_exceeded |
403 | A token, topic, or account spend cap would be exceeded. |
transport_denied |
403 | Policy leaves no allowed transport for a required delivery. |
topic_paused |
403 | Topic, device, or account kill switch is on. |
not_found |
404 | No such resource. |
conflict |
409 | Resource already exists or idempotency key reused with a different body. |
rate_limited |
429 | Rate or burst limit reached. Retry-After is set. |
internal |
500 | Unexpected error. |
provider_unavailable |
503 | An upstream provider is unavailable. |
The codes come from spec/errors.json
and won't change meaning; new ones may be added.
Protocol
The message envelope, canonical JSON, signatures, encryption, dedupe, and topic grammar are
specified in spec/README.md, with
a JSON Schema and
cross-SDK test vectors.