KeyBark

Set Anthropic workspace spend limits from code: what the Admin API can and can't do

You give each agent or customer its own Anthropic workspace and want to cap its monthly spend from your provisioning script, not by clicking through the Console. Here's what Anthropic's docs say is possible today, what's early access only, and a setup that gets close without it.

Last reviewed 5 Nov 2026

The short version

  • There is an endpoint, POST /v1/organizations/spend_limits, and it takes a workspace scope. But for Claude Console organizations, setting organization and workspace limits through it is an early access preview you request from your Anthropic account team (API reference).
  • Without early access, a workspace spend limit is set by hand: Console → Workspaces → select the workspace → Spend limits.
  • What you can automate with an ordinary Admin API key: creating workspaces, workspace rate limits (including a tokens_per_day ceiling), deactivating API keys, archiving workspaces, and reading cost per workspace.
  • The Default Workspace can't have a spend limit by any route.

1. What the docs say (read 5 Nov 2026)

Two Anthropic pages describe the same endpoint differently, which is why this question keeps coming up:

  • The Spend Limits API guide covers per-member limits for Claude Enterprise organizations and says: “The Spend Limits API is available to Claude Enterprise organizations only. It is not available to Claude Platform (Claude Console) organizations.”
  • The API reference for Set Spend Limit says a Claude Console organization “sets organization and workspace limits, which are monthly and always carry an amount. Setting those limits is in an early access preview. To request access, contact your Anthropic account team.” Listing and deleting Console limits are in the same preview.

So for a normal Console organization the practical answer today is no, unless Anthropic has switched the preview on for you. A feature request on GitHub asks for the same thing.

2. What you can automate today

TaskFrom code?How
Create a workspaceYesPOST /v1/organizations/workspaces with a name (Workspaces)
Set a workspace monthly spend limitEarly access onlyConsole → Workspaces → Spend limits; API only with the preview
Spend limit on the Default WorkspaceNoNot possible anywhere; move keys to another workspace
Set workspace rate limits (RPM, input/output tokens per minute, tokens per day)YesPOST /v1/organizations/workspaces/{workspace_id}/rate_limits/{rate_limit_id} (Rate Limits API); takes effect within about an hour
Create an API keyNoConsole only; the Admin API can read, rename and change the status of keys (Admin API FAQ)
Stop one keyYesPOST /v1/organizations/api_keys/{id} with {"status": "inactive"}
Stop a whole workspaceYes, irreversiblePOST /v1/organizations/workspaces/{id}/archive archives the workspace and every key created for it; can't be undone
Read cost per workspaceYesCost report grouped by workspace_id (legacy or Analytics API, beta)

All of these need an Admin API credential (an sk-ant-admin... key, an org:admin OAuth token, or a personal or service account key not scoped to one workspace). Workspace keys don't work, and the Admin API isn't available for individual accounts.

3. A capped workspace per agent, with one manual step

  1. Create the workspace from code:
    curl -X POST "https://api.anthropic.com/v1/organizations/workspaces" \
      -H "x-api-key: $ANTHROPIC_ADMIN_KEY" \
      -H "anthropic-version: 2026-10-21" \
      -H "content-type: application/json" \
      -d '{"name": "agent-invoice-bot"}'
  2. Set its spend limit in the Console (Workspaces → the new workspace → Spend limits), with alerts at the thresholds you want. This is the step you can't script without early access. Workspace limits can be lower than, but not higher than, your organization's limits, and organization limits always apply.
  3. Add a daily token ceiling from code. List the groups the workspace can override with GET /v1/organizations/workspaces/{id}/rate_limits?include_inherited=true, then set limits on a model group:
    curl "https://api.anthropic.com/v1/organizations/workspaces/$WS_ID/rate_limits/$RATE_LIMIT_ID" \
      -H "x-api-key: $ANTHROPIC_ADMIN_KEY" \
      -H "anthropic-version: 2026-10-21" \
      -H "content-type: application/json" \
      -d '{"limits": [
            {"type": "requests_per_minute", "value": 50},
            {"type": "tokens_per_day", "value": 2000000}
          ]}'
    A token ceiling isn't a dollar cap (cost depends on the model, caching and output length), but it bounds how far a loop can run in a day, and it's the one daily limit you can set from code. Anthropic enforces the lower of the workspace and organization values, and a change takes effect within about an hour, so set it when you create the workspace, not during an incident.
  4. Create the key in the Console inside that workspace, and give it to the agent. Never use a Default Workspace key for an agent.

4. If you have the early access preview

The workspace version of the request, per the API reference (amount is a string in cents; "50000" is $500.00; Console limits are monthly; setting the same scope and period again overwrites it):

curl -X POST "https://api.anthropic.com/v1/organizations/spend_limits" \
  -H "x-api-key: $ANTHROPIC_ADMIN_KEY" \
  -H "anthropic-version: 2026-10-21" \
  -H "content-type: application/json" \
  -d '{
    "scope": {"type": "workspace", "workspace_id": "wrkspc_..."},
    "amount": "50000",
    "period": "monthly"
  }'

If your organization isn't in the preview, don't rely on this call: check the response, and confirm the limit on the workspace's Spend limits panel in the Console. Listing limits (GET /v1/organizations/spend_limits) also needs the anthropic-beta: spend-limit-reads-2026-09-26 header.

5. Watch each workspace's spend from code

A spend limit stops a workspace at a monthly number. To hear about a problem earlier in the month, read cost per workspace and compare it with what's normal:

curl -g "https://api.anthropic.com/v1/organizations/cost_report?\
starting_at=2026-11-01T00:00:00Z&\
ending_at=2026-11-06T00:00:00Z&\
group_by[]=workspace_id" \
  -H "anthropic-version: 2026-10-21" \
  -H "x-api-key: $ANTHROPIC_ADMIN_KEY"
  • The legacy cost report says data “typically appears within 5 minutes” and supports polling once a minute. Default Workspace cost shows with workspace_id: null.
  • The newer Usage and Cost Analytics API (beta header analytics-usage-cost-2026-08-24) has more dimensions, but its data “typically refreshes within 4 hours” and can take up to 24, so it suits reports better than alarms.
  • When one workspace runs far above normal, the quick lever is setting its key to inactive. Archiving the workspace also stops it, but archives every key in it for good.

Checklist

  1. One workspace per agent, customer or environment, created from code; no agent keys in the Default Workspace.
  2. A monthly spend limit and alerts on every workspace (Console, or the API if you have early access).
  3. Per-minute and tokens_per_day rate limits on each agent workspace, set at creation time.
  4. An organization spend limit below your usage tier's cap.
  5. A job that reads cost per workspace and alerts a human when one runs far above normal, with a documented “set key inactive” step.

Not sure which of these you already have? The free AI key limit audit checks your Anthropic, OpenAI and OpenRouter settings in a few minutes (no sign-up, no key needed). For why the Default Workspace matters, see Anthropic Default Workspace limits; for what each limit error looks like, see Anthropic credit balance too low.

Where KeyBark fits (and where it doesn't)

KeyBark reads your Anthropic organization's cost report with an Admin API key from our servers about every 15 minutes during the beta, and emails you when a daily or monthly threshold you set is crossed, or when today's spend jumps above your 7-day average, Default Workspace spend included. If you opt in (paid plans, beta), it can set one named API key to inactive when a threshold is crossed.

Limits, honestly: KeyBark watches organization-wide spend, not each workspace separately. It does not create workspaces or set spend limits or rate limits for you. Checks run on a schedule and Anthropic's cost data lags a few minutes, so an alert can arrive after money has been spent. It isn't a proxy and can't block a request, and the kill switch hasn't been tested on live provider accounts yet, so try it on a non-production key first.

FAQ

Can I set an Anthropic workspace spend limit through the API?

Only if Anthropic has given your organization early access. The Set Spend Limit endpoint (POST /v1/organizations/spend_limits) accepts a workspace scope for Claude Console organizations, but Anthropic's API reference says setting organization and workspace limits through the API is an early access preview you request from your account team. Without it, set workspace spend limits in the Claude Console: Workspaces, select the workspace, Spend limits.

Why does the Spend Limits API guide say it's for Claude Enterprise only?

The Spend Limits API guide covers per-member limits for Claude Enterprise organizations and says it isn't available to Claude Console organizations. The API reference for the same endpoint adds that Console organizations can set organization and workspace limits in an early access preview. Read together: generally available for Enterprise per-user limits, preview-only for Console workspace limits.

What can I automate for workspace limits without early access?

With an Admin API key you can create workspaces, set and clear workspace rate limits (including tokens_per_day on model groups) with the Rate Limits API, set an API key to inactive, archive a workspace, and read cost per workspace from the cost report. Creating API keys and setting spend limits stay manual in the Console.

Can I put a spend limit on the Default Workspace through the API?

No. Anthropic doesn't allow spend limits on the Default Workspace at all, in the Console or through the API. Keys there are capped only by your organization's limit, so move agents to their own workspaces.

Sources (read 5 Nov 2026): Claude API docs Spend Limits API reference, Spend Limits API guide, Workspaces, Admin API, Rate Limits API, Usage and Cost API and Usage and Cost Analytics API; GitHub anthropics/claude-quickstarts issue 371. KeyBark is not affiliated with Anthropic.

Want a second line of defence?

KeyBark watches your OpenAI, Anthropic and OpenRouter spend from the server and flags a crossed threshold or spike by email and on your dashboard. Free for one key.

Not ready to connect a key? Get the weekly tip instead.

One short email a week at most on AI API costs, spend limits and key leaks (OpenAI, Anthropic, OpenRouter). It starts only after you confirm through the link we email you; one-click unsubscribe. See the Privacy Policy.