---
title: "Update Spending Limits"
method: PUT
path: "/api-keys/{api_key_id}/spending-limits"
tags: ["API Keys"]
---

# Update Spending Limits

`PUT /api-keys/{api_key_id}/spending-limits`

## Request

- Base URL: `https://be.graph8.com/api/v1`
- URL: `https://be.graph8.com/api/v1/api-keys/{api_key_id}/spending-limits`
- Auth: HTTP bearer

Set the daily and monthly credit caps on a key. The token is unchanged.

ADMIN OR OWNER ONLY, and a key can NEVER change its own caps: a cap that the capped key could lift is not a cap.
An organization key additionally follows the rotation rules (a creator still in the organization, keys of the same
creator, scopes it holds). A full replace: `null` removes a window's cap. Billable calls past a cap are refused
with 402 until the window resets.

## Path parameters

- `api_key_id` string, required: Key id from GET /api-keys.

## Headers

- `X-Target-Org-Id` string, nullable
- `Authorization` string, nullable

## Request body

- ApiKeySpendCapsRequest: Replace a key's spending caps in place. A FULL replace: resend any value you want to keep. A cap is in credits and bounds only the BILLABLE operations that key makes: once the key's spend for the current UTC day (or month) would pass it, the next billable call is refused with 402. `null` removes that window's cap.
  - `daily_credit_cap` integer, nullable: Daily cap in credits, resetting 00:00 UTC; null = no daily cap.
  - `monthly_credit_cap` integer, nullable: Monthly cap in credits, resetting on the 1st; null = no monthly cap.
  - `spend_alert_threshold_pct` integer, nullable: Alert the key owner at this percent of a cap. Defaults to 80 when a cap is set.

## Response `200`

Successful Response

- ApiResponseApiKeyResponse
  - `data` ApiKeyResponse, required: One API key's metadata (never the secret).
    - `api_key_id` string, required
    - `name` string, required
    - `created_at` integer, nullable
    - `expires_at` integer, nullable
    - `is_agency` boolean: Whether this key is agency-scoped. Informational — this door cannot mint one.
    - `mode` string
    - `last_used_at` integer, nullable
    - `scopes` string[]
    - `is_legacy_unrestricted` boolean: True for a key minted before scopes existed. An empty scope list means unrestricted, not 'no access'.
    - `created_by` string, nullable
    - `ip_allowlist` string[]: CIDRs this key is restricted to. Empty = unrestricted.
    - `daily_credit_cap` integer, nullable: Daily spending cap in credits. Null = no daily cap.
    - `monthly_credit_cap` integer, nullable: Monthly spending cap in credits. Null = no monthly cap.
    - `spend_alert_threshold_pct` integer, nullable: Percent of a cap at which the key owner is alerted. Null when no cap is set.
  - `pagination` PaginationMeta
    - `page` integer, required: Current page number (1-indexed)
    - `limit` integer, required: Items per page
    - `total` integer, required: Total number of items
    - `has_next` boolean, required: Whether there are more pages
    - `next_cursor` string, nullable: Opaque cursor for the next page; null when there are no more items. Pass it back as the `cursor` query param to fetch the following page without computing page numbers.
    - `total_available` integer, nullable: Search endpoints only: how many records really match, when known. Can be larger than `total`, which is capped at the 10,000 results that can be paged. For company search this is a distinct-company estimate. Null when unknown; absent outside search.
    - `total_is_lower_bound` boolean, nullable: Search endpoints only: true when more records match than `total` shows (the result set is larger than the 10,000 results that can be paged). Absent outside search.
    - `notes` string[], nullable: Search endpoints only: plain-language notes about the result, e.g. that more records match than can be paged, or that a reversed `between` range was put in order.

## Other responses

- `422`: Validation Error

## Changes

- **2026-10-19** `2e7cfa0ca921`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/graph8/apis/graph8-developer-api/changes/api-keys/:api_key_id/spending-limits/put.md)

---

[API](https://skmtc.dev/graph8/apis/graph8-developer-api.md) · [All operations](https://skmtc.dev/graph8/apis/graph8-developer-api/llms.txt) · [OpenAPI document](https://skmtc.dev/graph8/apis/graph8-developer-api/revisions/2e7cfa0ca921?raw)
