---
title: "PATCH /v1/accounts/{id}/keys/{key_id}"
description: "Set or clear a key’s daily and monthly spend caps. Applies from its next call."
canonical_url: https://groundsocial.dev/docs/api/keys-caps
---
# PATCH /v1/accounts/{id}/keys/{key_id}

> Set or clear a key’s daily and monthly spend caps. Applies from its next call.

> ## Agent Instructions
> The Groundsocial REST API is at https://api.groundsocial.dev (OpenAPI: https://groundsocial.dev/openapi.json). Set yourself up with https://groundsocial.dev/SKILL.md; the MCP server is https://api.groundsocial.dev/mcp. Every docs page is Markdown at its URL plus `.md`; the index is https://groundsocial.dev/llms.txt.

|  |  |
| --- | --- |
| Request | `PATCH /v1/accounts/{id}/keys/{key_id}` |
| Operation id | `keys.caps` |
| Cost | Free |
| Auth | Dashboard session: `Authorization: Bearer <session_token>`. API keys are refused. |

## Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | Example: `acct_01J…`. |
| `key_id` | `string` | yes |  |

## Request body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `daily_spend_cap_credits` | `integer \| null` | no | Credits; null for no cap. 0 stops the key spending at all. |
| `monthly_spend_cap_credits` | `integer \| null` | no | Credits; null for no cap. 0 stops the key spending at all. |

## Responses

| Status | Meaning | Schema |
| --- | --- | --- |
| `200` | The key with its new caps. | `ApiKey` |
| `400` | Invalid input. | `Error` |
| `401` | Not signed in, or an API key was sent (keys cannot manage keys). | `Error` |
| `403` | Members can’t change caps; owners and admins can. | `Error` |
| `404` | No such account among yours, or no such key on it. | `Error` |

### ApiKey fields

| Field | Type | Description |
| --- | --- | --- |
| `id` | `string` |  |
| `name` | `string` |  |
| `display_prefix` | `string` | The key’s first characters, to tell keys apart. |
| `source` | `"dashboard" \| "agent_signup" \| "cli" \| "oauth"` |  |
| `scopes` | `string[]` |  |
| `daily_spend_cap_credits` | `integer \| null` |  |
| `monthly_spend_cap_credits` | `integer \| null` |  |
| `spent_today_credits` | `integer` |  |
| `spent_this_month_credits` | `integer` |  |
| `last_used_at` | `string \| null` |  |
| `expires_at` | `string \| null` |  |
| `revoked_at` | `string \| null` |  |
| `created_at` | `string` |  |

Errors use one shape everywhere; see [Errors](https://groundsocial.dev/docs/errors) for every code and what to do.

## Example

cURL:

```bash
curl -X POST "https://api.groundsocial.dev/v1/accounts/acct_01J…/keys/key_01J…" \
  -H "Authorization: Bearer $GROUNDSOCIAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

TypeScript:

```ts
const res = await fetch('https://api.groundsocial.dev/v1/accounts/acct_01J…/keys/key_01J…', {
  method: 'POST',
  headers: { Authorization: `Bearer ${process.env.GROUNDSOCIAL_API_KEY}`, 'Content-Type': 'application/json' },
  body: JSON.stringify({}),
})
if (!res.ok) throw new Error((await res.json()).error.hint)
const data = await res.json()
```

Python:

```python
import os, requests

res = requests.post(
    "https://api.groundsocial.dev/v1/accounts/acct_01J…/keys/key_01J…",
    headers={"Authorization": f"Bearer {os.environ['GROUNDSOCIAL_API_KEY']}"},
    json={},
)
res.raise_for_status()
data = res.json()
```

_Canonical HTML: https://groundsocial.dev/docs/api/keys-caps_

## Site Navigation

### Global Hub
- [Home](https://groundsocial.dev/index.md)
- [Pricing](https://groundsocial.dev/pricing.md)
- [Endpoints](https://groundsocial.dev/endpoints.md)
- [For agents](https://groundsocial.dev/agents.md)
- [Docs](https://groundsocial.dev/docs.md)
- [Compare](https://groundsocial.dev/compare.md)
- [Changelog](https://groundsocial.dev/changelog.md)
- [llms.txt](https://groundsocial.dev/llms.txt)
- [Agent skill](https://groundsocial.dev/SKILL.md)

### On This Topic
- [Groundsocial docs](https://groundsocial.dev/docs.md)
- [Quickstart](https://groundsocial.dev/docs/quickstart.md)
- [Authentication](https://groundsocial.dev/docs/authentication.md)
- [Credits and payments](https://groundsocial.dev/docs/payments.md)
- [Rate limits](https://groundsocial.dev/docs/rate-limits.md)
- [Errors](https://groundsocial.dev/docs/errors.md)
- [Data freshness and caching](https://groundsocial.dev/docs/freshness.md)
- [MCP server](https://groundsocial.dev/docs/mcp.md)
- [SKILL.md, llms.txt and Markdown twins](https://groundsocial.dev/docs/skill.md)
- [CLI](https://groundsocial.dev/docs/cli.md)
- [TypeScript SDK](https://groundsocial.dev/docs/sdk.md)
- [PRAW and snoowrap](https://groundsocial.dev/docs/praw.md)
- [Legal and compliance](https://groundsocial.dev/docs/compliance.md)
- [API reference](https://groundsocial.dev/docs/api.md)

## Structured data

```json
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://groundsocial.dev/"},{"@type":"ListItem","position":2,"name":"Docs","item":"https://groundsocial.dev/docs"},{"@type":"ListItem","position":3,"name":"API reference","item":"https://groundsocial.dev/docs/api"},{"@type":"ListItem","position":4,"name":"PATCH /v1/accounts/{id}/keys/{key_id}","item":"https://groundsocial.dev/docs/api/keys-caps"}]}
```
