Bridge Training
API

Errors

Error response format and codes.

Response shape

All errors return JSON with this structure:

{
  "code": "DEAL_NOT_FOUND",
  "message": "Deal abc-123 not found",
  "meta": {}
}
FieldTypeDescription
codestringMachine-readable error code
messagestringHuman-readable description
metaobject?Optional additional context (e.g. field names for validation errors)

Error codes

CodeHTTP StatusDescription
DEAL_NOT_FOUND404The requested deal does not exist
UNAUTHORIZED401Missing or invalid authentication
FORBIDDEN403Authenticated but not allowed
INTERNAL_ERROR500Unexpected server error

Error registry

Errors are defined in apps/api/src/errors/errors.ts as a typed registry organized by domain:

import { errors } from "../errors";

// In a handler:
throw errors.deals.notFound(id);
throw errors.auth.unauthorized();

New error codes are added to the registry as the API grows.

On this page