docs / reference
API Reference
Direct REST API for event ingestion and custom integrations.
The noburn REST API accepts events from any language or runtime. Use it if your language doesn't have an SDK yet, or if you want full control over the request.
Authentication
All API requests use Bearer token authentication with your project's SDK key:
Authorization: Bearer sk-nb-xxxxxxxxxxxxxxxxSDK keys are project-scoped. A key can only write events to its associated project.
HTTP or SDK?
Every endpoint below is plain HTTPS, so curl or any HTTP client works from any language: Go, Ruby, PHP, Java, Rust, or a no-code tool such as n8n or Make. It is also the quickest way to see noburn answer: paste the curl examples into a terminal.
The SDKs (npm install @noburn/sdk, pip install noburn) add things raw HTTP doesn't do for you:
| SDK | Raw HTTP | |
|---|---|---|
Fallback when noburn is unreachable (onError) | ✓ | You decide what to do on a timeout |
| Fast path: repeat checks answered locally for ~10 s | ✓ | Every check is a round trip |
| Retry of a failed check, and of event deliveries | ✓ | Retry yourself; send event_id so a retry isn't counted twice |
| Token and cost estimates | ✓ | Count tokens yourself |
| Sizing a blocked call you record with no usage | ✓ | Send decision_id from the check, or the call's tokens |
Use the SDK in production where one exists; use HTTP everywhere else.
POST /api/v1/check
The pre-call decision endpoint — call this before every LLM call to get a server-authoritative allow/block. It resolves the project-, per-user-, and per-run budget caps against month-to-date spend, applies your policy rules, and enforces the plan request quota.
Runtime: Node.js, next to the database (Singapore)
Request
POST https://noburn.dev/api/v1/check
Authorization: Bearer sk-nb-xxxxxxxxxxxxxxxx
Content-Type: application/json{
"project_id": "550e8400-e29b-41d4-a716-446655440000",
"model": "gpt-5-mini",
"estimated_tokens_in": 1500,
"estimated_tokens_out": 500,
"end_user_id": "user_abc123",
"run_id": null,
"context": { "plan": "free" }
}Request body
| Field | Type | Required | Description |
|---|---|---|---|
project_id | string (uuid) | ✓ | Must match the SDK key's project |
model | string | ✓ | Model identifier. Max 255 characters |
estimated_tokens_in | number | — | Estimated prompt tokens. Used to price the call server-side for recognized models |
estimated_tokens_out | number | — | Output tokens the call may write (send max_tokens when you set one). Omit it or send 0 when you don't know: noburn reserves the 95th percentile of what this project's calls to this model wrote over the last 30 days, or 2,048 tokens until there are 20 calls |
estimated_cost_usd | number | — | Fallback cost for models noburn doesn't recognize. Ignored when token counts price the call |
estimated_units | object | — | Usage that isn't tokens, for image, video, speech and transcription models: any of images, video_seconds, audio_seconds, characters (non-negative numbers). Priced from noburn's model catalog |
end_user_id | string | — | Enforces this user's per-user budget cap |
run_id | string | — | Enforces this agent run's per-run budget cap (see /api/v1/runs) |
context | object | — | String key-value pairs matched against policy rules, such as plan or feature. Used during the check and never stored. Don't put customer data in it. |
lease | boolean | — | Ask for a fast-path lease (the SDKs send true from 0.4.0). See below |
The server prices recognized models from
estimated_tokens_in/outusing its own pricing table — a client cannot send a cost of0(or a forged value) to slip under a cap.
Response
{
"allowed": true,
"reason": null,
"forced_model_tier": null,
"estimated_cost_usd": 0.00875,
"input_rate_per_m": 2.5,
"output_rate_per_m": 10.0,
"pricing_source": "server_table",
"project_spend_usd": 4.20,
"project_cap_usd": 10.0,
"project_remaining_usd": 5.80,
"user_spend_usd": 0.0,
"user_cap_usd": null,
"user_remaining_usd": null,
"run_spend_usd": 0.0,
"run_cap_usd": null,
"run_remaining_usd": null,
"quota": {
"limit_type": "requests",
"limit": 20,
"used": 8,
"remaining": 12,
"window": "day",
"resets_at": "2026-10-21T00:00:00.000Z",
"plan": "free",
"upgrade_suggested": false
}
}| Field | Type | Description |
|---|---|---|
allowed | boolean | false if the call should be blocked |
reason | string | null | One of budget_exceeded, user_budget_exceeded, quota_exceeded, plan_budget_exceeded, run_budget_exceeded, run_stopped, policy_rule, plan_limit_exceeded — or null when allowed |
forced_model_tier | "small" | "big" | null | Set by a force_small/force_big policy rule — switch to a cheaper/stronger model |
estimated_cost_usd | number | Server-computed cost used for this budget check |
input_rate_per_m / output_rate_per_m | number | null | USD per 1M tokens used for pricing (null for pure client estimates) |
pricing_source | string | server_table, catalog, custom_override, conservative_unknown, or client_estimate |
decision_id / decided_at | string | Only on a block. noburn records every block it decides itself, so it counts toward saved. If you also record the blocked call to /api/v1/events, send this decision_id and use decided_at as timestamp so it counts once |
project_spend_usd / project_cap_usd / project_remaining_usd | number | null | Project budget state |
user_* | number | null | Per-user budget state (when end_user_id is supplied) |
run_* | number | null | Per-run budget state (when run_id is supplied) |
quota | object | null | The end user's usage quota (per-user override, else the plan quota for context.plan). null without end_user_id or when no quota applies. See Usage quotas |
plan_budget | object | null | The shared budget of the plan in context.plan, for every user on it together: { plan, limit_type, limit, used, remaining, window, resets_at }. null when the plan has none. See Shared plan budgets |
lease | object | null | Only with lease: true on an allowed call with room to spare: { id, ttl_ms, expires_at, budget_usd, max_calls }. The caller may allow up to max_calls more calls costing up to budget_usd in total, with the same model, end_user_id, run_id and context, for ttl_ms without calling /check. See Fast path |
| estimated_tokens_out | number \| null | Output tokens this check priced the call with |
| output_estimate | string | caller (the number you sent), history (this project's 95th percentile for the model) or fallback (2,048) |
| winding_down | boolean | true when this call is allowed but the tightest cap can't pay for another like it: ask the model to finish now. See Wind-down |
| wind_down_scope | string \| null | The cap that is running out: project, user, run or plan |
Active leases count as spent in every check, whether or not that check asks for one.
Example — curl
curl -s -w '\n' https://noburn.dev/api/v1/check \
-H 'Authorization: Bearer sk-nb-xxxxxxxxxxxxxxxx' \
-H 'Content-Type: application/json' \
-d '{
"project_id": "550e8400-e29b-41d4-a716-446655440000",
"model": "gpt-5-mini",
"estimated_tokens_in": 1000,
"estimated_tokens_out": 300,
"end_user_id": "user_abc123"
}'When allowed is false, skip the LLM call. An allowed check is not stored; record the call with /api/v1/events once it completes. Your project page has this command with your key and project ID filled in.
GET /api/v1/quota
An end user's allowance without making a call — for "12 of 20 left" in your UI.
GET /api/v1/quota?project_id=<project-id>&end_user_id=user_123&plan=free
Authorization: Bearer sk-nb-xxxxxxxxxxxxxxxx| Param | Required | Description |
|---|---|---|
project_id | no | Defaults to the key's project; must match it (403 otherwise) |
end_user_id | yes | The end user to look up |
plan | no | The plan key to match against your plan quotas |
estimated_cost_usd | no | Cost of the next call, for USD quotas. upgrade_suggested then matches what check would decide for that call |
Returns { "quota": { ... } } with the same object as check, or { "quota": null } when no quota applies. upgrade_suggested is true when a plan quota would block the next call. end_user_id and plan over 255 characters return 400. check does not reject them: it ignores an over-long end_user_id (no per-user cap or quota) and an over-long context.plan (no plan quota), and still enforces the project cap, run cap and rules. A failed lookup returns 503 with code QUOTA_UNAVAILABLE.
POST /api/v1/events
Records an LLM event (blocked or allowed). This is the core ingestion endpoint — the SDK wraps this call.
Runtime: Node.js, next to the database (Singapore) Target latency: p99 < 150ms
The server returns 202 immediately and processes the event asynchronously. Budget evaluation, alert rule checks, and webhook dispatches happen after the response.
Request
POST https://noburn.dev/api/v1/events
Authorization: Bearer sk-nb-xxxxxxxxxxxxxxxx
Content-Type: application/json{
"event_id": "evt_01JC9V3Z8Q4K2M",
"project_id": "550e8400-e29b-41d4-a716-446655440000",
"model": "gpt-5-mini",
"tokens_in": 1423,
"tokens_out": 487,
"cost_usd": 0.00133,
"was_blocked": false,
"end_user_id": "user_abc123",
"block_reason": null,
"latency_ms": 1240,
"timestamp": "2026-11-08T14:32:00.000Z"
}Request body
| Field | Type | Required | Description |
|---|---|---|---|
project_id | string (uuid) | ✓ | Must match the project associated with your SDK key |
model | string | ✓ | Model identifier. Max 255 characters |
tokens_in | number | ✓ | Prompt token count: every prompt token, including any read from or written to the provider's prompt cache |
tokens_out | number | ✓ | Completion token count |
cached_tokens_in | number | — | Of tokens_in, how many were read from the prompt cache. Priced at the model's cache-read rate (for example 0.5× input on gpt-4o, 0.1× on gpt-5-mini and Claude) |
cache_write_tokens_in | number | — | Of tokens_in, how many were written to the prompt cache. Priced at the cache-write rate (1.25× input on Claude) |
cost_usd | number | ✓ | Cost in USD. Use your provider's per-token pricing |
was_blocked | boolean | ✓ | true if the call was blocked before reaching the LLM |
end_user_id | string | — | Per-user identifier for spend tracking. Max 255 characters |
block_reason | string | — | Why the call was blocked. Max 500 characters |
latency_ms | number | — | End-to-end call latency in milliseconds |
timestamp | string (ISO 8601) | — | Defaults to server time if omitted |
event_id | string | — | Idempotency key, 8–64 characters of A–Z a–z 0–9 _ -. Send the same value (and the same timestamp) when you retry a delivery, and noburn stores the call once |
decision_id | string | — | For a blocked call: the decision_id from /api/v1/check, with its decided_at as timestamp. noburn already recorded that block, so this counts it once |
units | object | — | Usage that isn't tokens: any of images, video_seconds, audio_seconds, characters. Priced from noburn's model catalog |
Response
HTTP/1.1 202 AcceptedNo response body. A 202 means the event was accepted and queued for processing.
Error responses
| Status | Code | Reason |
|---|---|---|
400 | BAD_REQUEST | Missing required fields, invalid types, or negative/non-finite tokens_*/cost_usd |
401 | INVALID_SDK_KEY | Missing, malformed, or invalid Authorization header |
403 | FORBIDDEN | SDK key is valid but project_id doesn't match |
429 | RATE_LIMIT | Exceeded 1,000 requests/minute per IP |
Rate limits
| Tier | Limit |
|---|---|
| All plans | 1,000 requests/min per IP |
Set Retry-After header is included on 429 responses.
Example — raw fetch (Node.js)
await fetch('https://noburn.dev/api/v1/events', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.NOBURN_SDK_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
event_id: crypto.randomUUID(), // reuse it if you retry this request
project_id: process.env.NOBURN_PROJECT_ID,
model: 'gpt-5-mini',
tokens_in: 1423,
tokens_out: 487,
cost_usd: 0.00133,
was_blocked: false,
latency_ms: 1240,
}),
});Example — curl
curl -s -o /dev/null -w '%{http_code}\n' https://noburn.dev/api/v1/events \
-H 'Authorization: Bearer sk-nb-xxxxxxxxxxxxxxxx' \
-H 'Content-Type: application/json' \
-d '{
"event_id": "evt_01JC9V3Z8Q4K2M",
"project_id": "550e8400-e29b-41d4-a716-446655440000",
"model": "gpt-5-mini",
"tokens_in": 980,
"tokens_out": 290,
"cost_usd": 0.000825,
"was_blocked": false,
"end_user_id": "user_abc123"
}'
# -> 202POST /api/v1/runs
Starts an agent run — a bounded unit of work that can carry its own budget cap, independent of the project- and per-user caps. Thread the returned run_id through /api/v1/check and /api/v1/events so per-run spend is enforced and reported.
Request
{
"project_id": "550e8400-e29b-41d4-a716-446655440000",
"budget_cap_usd": 0.50,
"end_user_id": "user_abc123",
"metadata": { "task": "summarize" }
}| Field | Type | Required | Description |
|---|---|---|---|
project_id | string (uuid) | ✓ | Must match the SDK key's project |
budget_cap_usd | number | — | Hard cap for this run's spend |
end_user_id | string | — | Attribute the run to an end user |
metadata | object | — | Arbitrary JSON stored with the run |
Response — 201 Created
{ "run_id": "…", "budget_cap_usd": 0.50, "started_at": "2026-01-15T14:32:00.000Z" }Example — curl
curl -s -w '\n' https://noburn.dev/api/v1/runs \
-H 'Authorization: Bearer sk-nb-xxxxxxxxxxxxxxxx' \
-H 'Content-Type: application/json' \
-d '{ "project_id": "550e8400-e29b-41d4-a716-446655440000", "budget_cap_usd": 0.50 }'Pass the returned run_id in every /api/v1/check and /api/v1/events call the run makes.
POST /api/v1/runs/{id}/end
Finalizes a run. Totals its non-blocked spend and marks it completed or budget_exceeded. Idempotent — ending an already-finished run returns its existing state.
Request
{ "project_id": "550e8400-e29b-41d4-a716-446655440000", "outcome": "success" }| Field | Type | Required | Description |
|---|---|---|---|
project_id | string (uuid) | ✓ | Must match the SDK key's project |
outcome | "success" | "failure" | — | Whether the run solved its task. The dashboard's "Runs that didn't finish" report counts failed runs from it, and noburn will learn when to stop a failing run from these labels. Also accepted for a run that already ended or was stopped, if you learn the outcome later; a later report replaces an earlier one. Any other value is a 400 |
Example — curl
curl -s -w '\n' https://noburn.dev/api/v1/runs/RUN_ID/end \
-H 'Authorization: Bearer sk-nb-xxxxxxxxxxxxxxxx' \
-H 'Content-Type: application/json' \
-d '{ "project_id": "550e8400-e29b-41d4-a716-446655440000", "outcome": "success" }'Response
{
"run_id": "…",
"status": "completed",
"outcome": "success",
"spend_usd": 0.32,
"budget_cap_usd": 0.50,
"started_at": "2026-01-15T14:32:00.000Z",
"ended_at": "2026-01-15T14:33:10.000Z"
}POST /api/v1/runs/{id}/stop
Stops a run from outside the agent. From then on every /api/v1/check carrying this run_id returns allowed: false with reason: "run_stopped". Idempotent — stopping an already-stopped run returns its existing state (stopped_now: false); stopping a run that already ended is a no-op that reports its status. A run in another project returns 404. See Stopping a run.
Request
{ "project_id": "550e8400-e29b-41d4-a716-446655440000", "reason": "spend spike" }reason is optional (max 500 characters).
Response
{
"run_id": "…",
"status": "stopped",
"stopped_now": true,
"spend_usd": 4.2,
"budget_cap_usd": 5.00,
"started_at": "2026-01-15T14:32:00.000Z",
"ended_at": "2026-01-15T14:40:12.000Z",
"stopped_at": "2026-01-15T14:40:12.000Z",
"stopped_reason": "spend spike"
}Cost calculation reference
noburn is the pricing authority for budget enforcement. The SDK sends token counts; the server recomputes cost on every check and events call. Dashboard spend is an estimate based on noburn's table — it may differ from your provider invoice.
Pricing sources
Each stored event includes the rates used at ingest time:
pricing_source | Meaning |
|---|---|
server_table | Matched the global noburn pricing table |
custom_override | Matched a per-project rate you configured |
conservative_unknown | Unknown model — floored at Opus-tier rates ($30/$75 per 1M in/out) |
client_estimate | Used the cost_usd / estimated_cost_usd you supplied |
GET /api/v1/pricing
Fetch the current global table, version metadata, and your project's custom overrides. Optional — existing SDK flows work unchanged.
GET https://noburn.dev/api/v1/pricing?project_id=<uuid>
Authorization: Bearer sk-nb-xxxxxxxxxxxxxxxx{
"version": "2026-06-19",
"effective_at": "2026-06-19T00:00:00Z",
"global_table": [{ "model_prefix": "gpt-4o", "input_per_m": 2.5, "output_per_m": 10.0 }],
"project_overrides": [{ "model_prefix": "my-finetune", "input_per_m": 1.0, "output_per_m": 2.0 }],
"unknown_model_floor": { "input_per_m": 30, "output_per_m": 75 }
}Per-project custom rates
Configure gateway pass-through or fine-tuned model rates via the dashboard API:
POST /api/projects/{id}/model-pricing
{ "model_prefix": "my-finetune", "input_per_m": 1.0, "output_per_m": 2.0 }Overrides take precedence over the global table. Prefix matching applies (longest match wins).
For recognized models, noburn recomputes cost server-side from tokens_in/out, pricing cached_tokens_in and cache_write_tokens_in at the model's cache rates (GET /api/v1/pricing lists them as cache_read_per_m and cache_write_per_m; null means the full input rate). The two cache counts together can't exceed tokens_in, or the event is rejected with a 400. Custom model prices have no cache rates, so cached tokens are priced at your custom input rate. For unrecognized models, pass accurate token counts (conservative floor applies) or an explicit estimated_cost_usd / cost_usd.
GET /api/v1/policy
Fetches the enabled policy rules for a project. The SDK calls this on initialization to load server-configured rules.
Runtime: Node.js, next to the database (Singapore)
Query parameters
| Parameter | Required | Description |
|---|---|---|
project_id | ✓ | Your project UUID |
Request
GET /api/v1/policy?project_id=<your-project-id>
Authorization: Bearer sk-nb-xxxxxxxxxxxxxxxxResponse
{
"rules": [
{ "when": { "utilization": ">= 0.8" }, "then": "force_small" },
{ "when": { "model": "gpt-4o" }, "then": "block" }
]
}Rules are returned in evaluation order (position ascending). Only enabled rules are included. An empty rules array means no rules are configured — all calls proceed normally.
Error responses
| Status | Meaning |
|---|---|
401 | Missing or invalid SDK key |
403 | SDK key does not belong to the requested project_id |
400 | project_id query param missing |
Error codes
| Code | HTTP Status | Description |
|---|---|---|
UNAUTHORIZED | 401 | Not signed in |
FORBIDDEN | 403 | Signed in but access denied |
INVALID_SDK_KEY | 401 | SDK key missing or invalid |
NOT_FOUND | 404 | Resource doesn't exist |
BAD_REQUEST | 400 | Invalid request body |
RATE_LIMIT | 429 | Too many requests |
PLAN_LIMIT_EXCEEDED | 402 | Action requires plan upgrade |
INTERNAL_ERROR | 500 | Server error — retry with backoff |