Skip to Content
Spec

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-spec

zod (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

FileWhat it is
error-envelope.schema.jsonJSON Schema 2020-12 for the body of every failed response.
error-codes.jsonEvery error code and its default HTTP status.
analytics-ingest-request.schema.jsonBody of POST to the analytics ingest route.
analytics-ingest-response.schema.jsonBody of its 202 reply.
tracked-event.schema.jsonOne stored analytics event.
webhook-delivery.schema.jsonWebhook body, signed headers and outbox message.
auth.openapi.jsonOpenAPI 3.1 for the session and client-login routes.
contract.jsonThe theme contract: the 78 required and 16 optional CSS variable names.
conformance-cases.jsonRequest 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.

CodeStatus
VALIDATION_FAILED400
INVALID_JSON400
RATE_LIMITED429
RATE_LIMIT_UNAVAILABLE503
MAINTENANCE503
INTERNAL_ERROR500
BAD_REQUEST400
UNAUTHORIZED401
FORBIDDEN403
NOT_FOUND404
METHOD_NOT_ALLOWED405
CONFLICT409
GONE410
PAYLOAD_TOO_LARGE413
UNPROCESSABLE422
HTTP_ERROR500
INVALID_PAYLOAD400
TIMEOUT408
APPROVAL_REQUIRED403
APPROVAL_DECLINED403
APPROVAL_PENDING409
BAD_INPUT400
JOB_FAILED500
UNKNOWN_JOB404
CANCELLED409
BUDGET_EXCEEDED429
JOBS_NOT_CREATED500
DUPLICATE_JOB500
NO_BUDGET_STORE500
TOO_LARGE413
EMPTY400
TYPE_NOT_ALLOWED415
TYPE_MISMATCH415
BAD_KEY400
QUOTA_EXCEEDED413
PRESIGN_UNSUPPORTED501
RESUMABLE_UNSUPPORTED501
INVALID_PHONE400
INVALID_CODE400
CODE_EXPIRED400
TOO_MANY_ATTEMPTS429
CAPTCHA_REQUIRED400
CAPTCHA_FAILED403
CAPTCHA_UNAVAILABLE503
DISPOSABLE_EMAIL400
AI_SPEND_CAP_EXCEEDED429
AI_SPEND_UNAVAILABLE503
OFFER_REFUSED409
BAD_TOKEN400
REDEEM_REFUSED409
invalid_token401
insufficient_scope403

invalid_token and insufficient_scope are lowercase because RFC 6750 fixes their spelling.

Modules