Create a quota
POST/v1/projects/:project_id/quotas
Creates a project-scoped quota. requests is valid for scope: project/api_key; tokens and cost_usd are valid for scope: project/agent/actor; storage_bytes is valid for scope: project only. Any other scope/metric pair is rejected with 400 (no attribution exists to enforce it). An actor quota caps one end user's spend, matched from the generation's session; a null scope_ref means one budget per actor rather than a pooled project total. A cost_usd quota may name one meter_type to cap; omitting it caps every priced meter. A duplicate quota (same project, scope, scope_ref, metric, window, meter_type) is rejected with 409.
storage_bytes caps a stored total rather than a windowed one, so it takes window: current and every other metric refuses that value (400 either way). It is enforced at the corpus write paths — file upload and create, document create, document ingest and re-ingest, memory create — with 409 QUOTA_STORAGE_EXCEEDED and no Retry-After, since no window reset clears a footprint.
Request
Responses
- 201
- 400
- 401
- 403
- 404
- 409
- 413
- 429
- 500
- 502
- 4XX
Quota created successfully
Bad request (invalid scope/metric/window/mode/limit)
Unauthorized
Forbidden
The project does not exist or the caller is not a member of it (RESOURCE_NOT_FOUND).
A matching quota already exists
REQUEST_REJECTED — the request body is over the size the body parser accepts
QUOTA_EXCEEDED — a requests quota on the calling API key or its project is spent for the window; Retry-After says when it reopens
Response Headers
Seconds until the quota window admits a request again
Internal server error
The deployment's admission service is asked about this write and did not answer — ADMISSION_UNAVAILABLE; the write did not happen
The deployment's admission service refused this write — answered under the service's own 4xx status, with its code (matching ^[A-Za-z_][A-Za-z0-9_]{0,63}$, not necessarily an ERROR_CODES key), message and meta; the write did not happen. A status this operation also declares on its own is documented there