Skip to content

Error Format & Status Codes

Bipkit uses standard HTTP status codes and returns structured JSON error payloads (application/json).

{
"detail": "Missing or invalid API key."
}

For schema validation errors (422 Unprocessable Entity), FastAPI returns field-level diagnostics:

{
"detail": [
{
"loc": ["body", "state"],
"msg": "Field required",
"type": "missing"
}
]
}
Status Meaning Safe to Retry? Action
200 OK Request succeeded — Process response
304 Not Modified Public DPL metadata unchanged (If-None-Match matched ETag) — Reuse cached manifest/keys/calibration
400 Bad Request Malformed request or unsupported option No Fix request payload
401 Unauthorized Missing, revoked, or invalid API key No Check Authorization / X-API-Key header
403 Forbidden Key lacks required scope (e.g., keys:manage) No Use a key with the required scope
404 Not Found Resource (request_id, entry_id, key_id) not found in your org No Verify identifier
422 Unprocessable Entity Request body failed schema validation No Inspect detail[].loc and fix types
429 Too Many Requests Rate limit or monthly decision quota exceeded Yes (after backoff) Honor Retry-After header or check /api/v1/usage/summary
500 / 502 / 503 / 504 Transient server or upstream error Yes (exponential backoff) Retry with jitter; fall back to System Two if latency budget is exceeded

All four official SDKs automatically retry transient 429 and 5xx responses with exponential backoff + jitter (honoring Retry-After). If retries are exhausted or a non-retryable 4xx occurs, catch the typed SDK error:

import {
Bipkit,
AuthenticationError,
RateLimitError,
APIStatusError,
} from "@bipware-org/bipkit";
const bipkit = new Bipkit();
try {
await bipkit.decide({ state, choices });
} catch (err) {
if (err instanceof AuthenticationError) {
console.error("Invalid or revoked BIPKIT_API_KEY");
} else if (err instanceof RateLimitError) {
console.warn(`Rate limited; retry after ${err.retryAfter ?? "backoff"}s`);
} else if (err instanceof APIStatusError) {
console.error(`HTTP ${err.status} (${err.requestId}): ${err.message}`);
} else {
throw err;
}
}