Skip to content

Update Budgets and Access Policy

PATCH/v1/workspaces/{workspace_id}/guardrails

Overview

Owners and admins only. A budget set to a number replaces that period's limit, null removes it, and periods left out stay as they are. access_policy replaces the whole policy; an empty object or null removes it. An invalid rule is refused with 400 and param naming it, such as access_policy.allowed_models.1.

Authorization

Authorizationstring · headerRequired

Workspace session token sent as Bearer <token>. Authentication guide

Parameters

workspace_idpath · stringRequired

Workspace id.

Request Body

application/json
budgetsobject

A number sets that period's limit in USD, null removes it, and periods left out stay as they are.

Show nested fields
dailynumber | null

Minimum 0 · Maximum 1000000

weeklynumber | null

Minimum 0 · Maximum 1000000

monthlynumber | null

Minimum 0 · Maximum 1000000

access_policyobject | null
Show nested fields
Option 1: object
allowed_modelsstring[]
Show nested fields

See the OpenAPI schema for this nested object.

blocked_modelsstring[]
Show nested fields

See the OpenAPI schema for this nested object.

allowed_providersstring[]
Show nested fields

See the OpenAPI schema for this nested object.

blocked_providersstring[]
Show nested fields

See the OpenAPI schema for this nested object.

allowed_productsstring[]
Show nested fields

See the OpenAPI schema for this nested object.

blocked_productsstring[]
Show nested fields

See the OpenAPI schema for this nested object.

Option 2: null

null

Responses

200Saved budgets, spend and access policy.
application/json
workspace_idstringRequired
budgetsobjectRequired

Spend limits in USD per UTC calendar period. null means no limit.

Show nested fields
dailynumber | nullRequired

Minimum 0

weeklynumber | nullRequired

Weeks start on Monday.

Minimum 0

monthlynumber | nullRequired

Minimum 0

usageobjectRequired

USD spent in the current UTC day, week and month, and in total, including holds for requests in progress. Spend counts in the period its request started.

Show nested fields
dailynumberRequired
weeklynumberRequired
monthlynumberRequired
totalnumberRequired
resets_atobjectRequired

When the current day, week and month end, in UTC.

Show nested fields
dailystringRequired
weeklystringRequired
monthlystringRequired
access_policyobject | nullRequired
Show nested fields
Option 1: object
allowed_modelsstring[]
Show nested fields

See the OpenAPI schema for this nested object.

blocked_modelsstring[]
Show nested fields

See the OpenAPI schema for this nested object.

allowed_providersstring[]
Show nested fields

See the OpenAPI schema for this nested object.

blocked_providersstring[]
Show nested fields

See the OpenAPI schema for this nested object.

allowed_productsstring[]
Show nested fields

See the OpenAPI schema for this nested object.

blocked_productsstring[]
Show nested fields

See the OpenAPI schema for this nested object.

Option 2: null

null

400Request validation failed.
application/json
errorobjectRequired
Show nested fields
codestringRequired
messagestringRequired
paramstring | null
request_idstring | null
metadataobject

Typed detail for some refusals. budget_exceeded (402): limit (key_budget or workspace_budget) and budget with scope, period, limit, usage and resets_at. key_limit_exceeded (402): limit key_spend_limit. access_denied (403): policy (workspace or key), rule (models, providers or products), product, provider and model.

401Authentication is missing or invalid.
application/json
errorobjectRequired
Show nested fields
codestringRequired
messagestringRequired
paramstring | null
request_idstring | null
metadataobject

Typed detail for some refusals. budget_exceeded (402): limit (key_budget or workspace_budget) and budget with scope, period, limit, usage and resets_at. key_limit_exceeded (402): limit key_spend_limit. access_denied (403): policy (workspace or key), rule (models, providers or products), product, provider and model.

403Authenticated principal lacks permission.
application/json
errorobjectRequired
Show nested fields
codestringRequired
messagestringRequired
paramstring | null
request_idstring | null
metadataobject

Typed detail for some refusals. budget_exceeded (402): limit (key_budget or workspace_budget) and budget with scope, period, limit, usage and resets_at. key_limit_exceeded (402): limit key_spend_limit. access_denied (403): policy (workspace or key), rule (models, providers or products), product, provider and model.