---
title: "update llm_gateway_key"
method: PATCH
path: "/llm_gateway_keys/{id}"
tags: ["LlmGatewayKeys"]
---

# update llm_gateway_key

`PATCH /llm_gateway_keys/{id}`

## Request

- Base URL: `https://api.aptible.com`
- URL: `https://api.aptible.com/llm_gateway_keys/{id}`
- Auth: API key in header `Authorization`

Changes a key's handle and/or spend_limit. Nothing else about a key can be changed.
Available to the organization's owners and to whoever created the key.

At least one of handle and spend_limit must be sent, and only what is sent changes.
Sending a null or blank spend_limit removes the key's limit.

## Path parameters

- `id` integer, required

## Query parameters

- `no_embed` boolean

## Headers

- `Prefer` 'no_sensitive_extras=true'

## Request body

- UpdateLlmGatewayKeyRequest
  - `handle` string: New handle for the key, unique within the organization
  - `spend_limit` number: New spend limit in USD for this key, or null to remove it. Must not exceed the organization's spend_limit.

## Response `200`

successful

- LlmGatewayKey
  - `id` integer, required: Database ID of the LLM Gateway Key
  - `_type` string, required
  - `handle` string, required: User-provided handle for the key (unique within the organization)
  - `note` string, required: User-provided note
  - `spend_limit` string, required: Spend limit in USD for this key (decimal, serialized as string). Null means the key has no limit of its own. Never exceeds the organization's spend_limit: lowering that lowers any key that was above it.
  - `organization_id` string, required: The organization this key belongs to
  - `created_at` string, dateTime, required
  - `updated_at` string, dateTime, required
  - `gateway_url` string, required: Customer-facing LLM Gateway endpoint URL
  - `token_prefix` string, required: The first characters of the key's token, safe to display and enough to tell keys apart
  - `created_by` object, required: User who created the key
  - `revoked_at` string, dateTime, required: Timestamp when the key was revoked
  - `revoked_by` object, required: User who revoked the key
  - `status` string, required: Key status (ACTIVE or REVOKED)
  - `token` string: Secret API key value (only present on creation)
  - `_links` LlmGatewayKeyLinks
    - `operations` ListAccountsForStack200ResponseLinksStack
      - `href` string, uri
    - `self` ListAccountsForStack200ResponseLinksStack
      - `href` string, uri

## Other responses

- `400`: neither handle nor spend_limit was sent
- `403`: organization not enrolled, or the caller may not update this key
- `404`: not found
- `422`: handle is blank or already used by another key in the organization, or spend_limit is negative or exceeds the organization's spend_limit
- `default`: Error response. Often a 4xx or 5xx status code

## Changes

- **2026-10-20** `ba72edfe0324`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/aptible/apis/aptible-api-v1/changes/llm_gateway_keys/:id/patch.md)

---

[API](https://skmtc.dev/aptible/apis/aptible-api-v1.md) - [All operations](https://skmtc.dev/aptible/apis/aptible-api-v1/llms.txt) - [OpenAPI document](https://skmtc.dev/aptible/apis/aptible-api-v1/revisions/a21f6b1bc6fe?raw)
