Spec
The wire contract as Zod: the error envelope, error codes, analytics ingest and webhook delivery, plus versioned JSON Schema files, and an OpenAPI document for the auth routes.
betaOn npm, API may still change
bun add @dapplelight/signet-speczod (4.2 or later) is a peer dependency.
Quick start
import { errorEnvelopeSchema } from "@dapplelight/signet-spec/error"
const res = await fetch("/api/orders", { method: "POST", body: "{}" })
if (!res.ok) {
const parsed = errorEnvelopeSchema.safeParse(await res.json())
if (parsed.success) console.log(parsed.data.code, parsed.data.error)
}The Zod schemas in src/error.ts are the source of truth. The JSON files are generated from them, and a test fails when they drift.
Files
| File | What it is |
|---|---|
| error-envelope.schema.json | JSON Schema 2020-12 for the body of every failed response. |
| error-codes.json | Every error code and its default HTTP status. |
| analytics-ingest-request.schema.json | Body of POST to the analytics ingest route. |
| analytics-ingest-response.schema.json | Body of its 202 reply. |
| tracked-event.schema.json | One stored analytics event. |
| webhook-delivery.schema.json | Webhook body, signed headers and outbox message. |
| auth.openapi.json | OpenAPI 3.1 for the session and client-login routes. |
| contract.json | The theme contract: the 78 required and 16 optional CSS variable names. |
| conformance-cases.json | Request and expected-response cases any backend can run. |
Files under /spec/v1/ never change shape. A breaking change ships as v2 alongside.
Every file carries "specVersion": "v1". The same files ship in the package under @dapplelight/signet-spec/schemas/.
Error codes
Every code in ERROR_CODES from @dapplelight/signet-lib/api, in the same order, with the status it is sent with. The ten codes @dapplelight/signet-server gives a bare HTTPException keep the status they are named for. Codes thrown at start-up rather than shown to a person are 500.
| Code | Status |
|---|---|
VALIDATION_FAILED | 400 |
INVALID_JSON | 400 |
RATE_LIMITED | 429 |
RATE_LIMIT_UNAVAILABLE | 503 |
MAINTENANCE | 503 |
INTERNAL_ERROR | 500 |
BAD_REQUEST | 400 |
UNAUTHORIZED | 401 |
FORBIDDEN | 403 |
NOT_FOUND | 404 |
METHOD_NOT_ALLOWED | 405 |
CONFLICT | 409 |
GONE | 410 |
PAYLOAD_TOO_LARGE | 413 |
UNPROCESSABLE | 422 |
HTTP_ERROR | 500 |
INVALID_PAYLOAD | 400 |
TIMEOUT | 408 |
APPROVAL_REQUIRED | 403 |
APPROVAL_DECLINED | 403 |
APPROVAL_PENDING | 409 |
BAD_INPUT | 400 |
JOB_FAILED | 500 |
UNKNOWN_JOB | 404 |
CANCELLED | 409 |
BUDGET_EXCEEDED | 429 |
JOBS_NOT_CREATED | 500 |
DUPLICATE_JOB | 500 |
NO_BUDGET_STORE | 500 |
TOO_LARGE | 413 |
EMPTY | 400 |
TYPE_NOT_ALLOWED | 415 |
TYPE_MISMATCH | 415 |
BAD_KEY | 400 |
QUOTA_EXCEEDED | 413 |
PRESIGN_UNSUPPORTED | 501 |
RESUMABLE_UNSUPPORTED | 501 |
INVALID_PHONE | 400 |
INVALID_CODE | 400 |
CODE_EXPIRED | 400 |
TOO_MANY_ATTEMPTS | 429 |
CAPTCHA_REQUIRED | 400 |
CAPTCHA_FAILED | 403 |
CAPTCHA_UNAVAILABLE | 503 |
DISPOSABLE_EMAIL | 400 |
AI_SPEND_CAP_EXCEEDED | 429 |
AI_SPEND_UNAVAILABLE | 503 |
OFFER_REFUSED | 409 |
BAD_TOKEN | 400 |
REDEEM_REFUSED | 409 |
invalid_token | 401 |
insufficient_scope | 403 |
invalid_token and insufficient_scope are lowercase because RFC 6750 fixes their spelling.
Modules
Error
Envelope schema, error-code table and their types.
Analytics
Ingest request and reply, and the stored event.
Webhooks
Delivery body, signed headers and outbox message.
Schemas
The generated JSON files, as package exports.
OpenAPI
OpenAPI 3.1 document for the session and client-login auth routes.
Conformance
Language-neutral test cases for the wire contract, and a runner that checks any backend against them.