> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xquik.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update API key name & budget, X (Twitter) API docs

> Rename an active Xquik API key, change its scope or set its monthly credit budget. It keeps its secret & expiry, and its next request uses the change.

> For the complete documentation index, see [llms.txt](https://docs.xquik.com/llms.txt).

`PATCH https://xquik.com/api/v1/api-keys/{id}`

Rename a key so its owner is clear. Narrow a key that only reads to `paid_reads`.
Pause a key to stop it for a while, then resume it. Limit a key to your servers with `allowedIps`.
Cap what a key spends each month with `monthlyBudgetCredits`.
Send 1 or more of `name`, `scope`, `paused`, `allowedIps` & `monthlyBudgetCredits`.
The key keeps its secret, prefix and expiry.

**Free.** This endpoint does not consume credits.

```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/bash.json","/languages/csharp.json","/languages/go.json","/languages/java.json","/languages/javascript.json","/languages/kotlin.json","/languages/php.json","/languages/python.json","/languages/ruby.json","/languages/typescript.json"]}}
curl -X PATCH https://dashboard.xquik.com/api/v1/api-keys/42 \
  -H "Cookie: __Host-xquik_session=YOUR_SESSION_COOKIE" \
  -H "Origin: https://dashboard.xquik.com" \
  -H "Sec-Fetch-Site: same-origin" \
  -H "Content-Type: application/json" \
  -d '{"name": "Analytics notebook", "scope": "paid_reads", "monthlyBudgetCredits": 50000}' | jq
```

```javascript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/bash.json","/languages/csharp.json","/languages/go.json","/languages/java.json","/languages/javascript.json","/languages/kotlin.json","/languages/php.json","/languages/python.json","/languages/ruby.json","/languages/typescript.json"]}}
const response = await fetch("https://dashboard.xquik.com/api/v1/api-keys/42", {
  method: "PATCH",
  headers: {
    Cookie: "__Host-xquik_session=YOUR_SESSION_COOKIE",
    Origin: "https://dashboard.xquik.com",
    "Sec-Fetch-Site": "same-origin",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    name: "Analytics notebook",
    scope: "paid_reads",
    monthlyBudgetCredits: 50000,
  }),
});
const key = await response.json();
console.log(key);
```

```python Python theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/bash.json","/languages/csharp.json","/languages/go.json","/languages/java.json","/languages/javascript.json","/languages/kotlin.json","/languages/php.json","/languages/python.json","/languages/ruby.json","/languages/typescript.json"]}}
import requests

response = requests.patch(
    "https://dashboard.xquik.com/api/v1/api-keys/42",
    cookies={"__Host-xquik_session": "YOUR_SESSION_COOKIE"},
    headers={"Origin": "https://dashboard.xquik.com", "Sec-Fetch-Site": "same-origin"},
    json={"name": "Analytics notebook", "scope": "paid_reads", "monthlyBudgetCredits": 50000},
)
key = response.json()
print(key)
```

```go Go theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/bash.json","/languages/csharp.json","/languages/go.json","/languages/java.json","/languages/javascript.json","/languages/kotlin.json","/languages/php.json","/languages/python.json","/languages/ruby.json","/languages/typescript.json"]}}
package main

import (
	"bytes"
	"fmt"
	"io"
	"log"
	"net/http"
)

func main() {
	body := bytes.NewBufferString(`{"name": "Analytics notebook", "scope": "paid_reads", "monthlyBudgetCredits": 50000}`)
	req, err := http.NewRequest("PATCH", "https://dashboard.xquik.com/api/v1/api-keys/42", body)
	if err != nil {
		log.Fatal(err)
	}
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("Origin", "https://dashboard.xquik.com")
	req.Header.Set("Sec-Fetch-Site", "same-origin")
	req.AddCookie(&http.Cookie{Name: "__Host-xquik_session", Value: "YOUR_SESSION_COOKIE"})

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		log.Fatal(err)
	}
	defer resp.Body.Close()

	answer, err := io.ReadAll(resp.Body)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(string(answer))
}
```

## Path parameters

| Path parameter | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | The unique identifier of the API key to update. |

## Headers

| Header | Type | Required | Description |
| - | - | - | - |
| `Cookie` | `string` | Yes | Your signed-in dashboard session cookie, `__Host-xquik_session`. API keys and OAuth tokens get `403 session_required`. |
| `Origin` | `string` | Yes | Must be `https://dashboard.xquik.com`, sent with `Sec-Fetch-Site` set to `same-origin`. The dashboard sends both. |
| `Content-Type` | `string` | Yes | Must be `application/json`. |

## Body

Send at least 1 field.

| Body parameter | Type | Required | Description |
| - | - | - | - |
| `name` | `string` | No | New display name, up to 100 characters. An empty name saves `"Default"`. |
| `scope` | `string` | No | Scope `full` calls every route an API key can use. Scope `paid_reads` calls paid X (Twitter) read routes only. Other routes answer it with `403 insufficient_scope`. The key's next request uses the new scope. |
| `scopes` | `string[]` | No | The scopes the key holds, from `full`, `read`, `write`, `monitors`, `exports` & `billing`. Every key holds `read`. `scopes` wins over `scope`. Missing keeps the key's scopes. The key's next request uses the new list. |
| `connectsXAccounts` | `boolean` | No | Lets this key connect, reconnect & disconnect X accounts. Only a dashboard session can change it. |
| `paused` | `boolean` | No | `true` pauses the key, and `false` resumes it. A paused key gets `403 api_key_paused` on every request. Its next request after you resume goes through. Sending the current state again changes nothing. While paused, the key has `pausedAt`, the time you paused it. A revoked key answers `409 api_key_revoked`. An expired key answers `409 api_key_expired`. |
| `allowedIps` | `string[]` | No | Up to 20 IPv4 or IPv6 addresses or CIDR ranges may use the key. The list replaces the saved one. Send `[]` to allow any IP again. Calls from other IPs get `403 ip_not_allowed`. The key's next request uses the new list. |
| `monthlyBudgetCredits` | `integer` | No | Credits the key can spend each UTC calendar month, from 1 to 1,000,000,000,000. `null` removes the budget, and a missing field keeps it. Raise or remove the budget, & the key's next call works again. |

## Response

### 200 OK

Returns the saved key with the same fields as [List API keys](https://docs.xquik.com/api-reference/api-keys/list.md).

```json theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/bash.json","/languages/csharp.json","/languages/go.json","/languages/java.json","/languages/javascript.json","/languages/kotlin.json","/languages/php.json","/languages/python.json","/languages/ruby.json","/languages/typescript.json"]}}
{
  "id": "42",
  "name": "Analytics notebook",
  "prefix": "xq_a1b2",
  "scope": "paid_reads",
  "scopes": ["read"],
  "allowedIps": [],
  "isActive": true,
  "createdAt": "2026-02-24T10:30:00.000Z",
  "lastUsedAt": "2026-02-24T18:45:12.000Z",
  "monthlyBudgetCredits": 50000,
  "monthlySpentCredits": 1200
}
```

### 400 Invalid input

`{ "error": "invalid_input", "message": "Send name, scopes, paused, allowedIps or monthlyBudgetCredits to change." }`




The body had no field to change, or `scope` was not `full` or `paid_reads`.
A `scopes` entry that was not a scope fails too. So does a `name` longer than 100 characters.
An `allowedIps` entry that isn't an IP or CIDR range fails too. So does a list over 20 entries.
`monthlyBudgetCredits` must be `null` or a whole number from 1 to 1,000,000,000,000.
Xquik changes nothing.

### 401 Unauthenticated

Missing, expired, or invalid dashboard session cookie.

### 404 Not found

No active API key with this ID exists on your account. A revoked key cannot change.

### 429 Rate limited

Too many requests. Wait for the `Retry-After` header before retrying.

> [!NOTE]
>
> API key changes require a same-origin dashboard session. API keys and OAuth bearer tokens cannot
> change account keys.
>
> **Related.** [Create API Key](https://docs.xquik.com/api-reference/api-keys/create.md) · [List API Keys](https://docs.xquik.com/api-reference/api-keys/list.md) · [Revoke API Key](https://docs.xquik.com/api-reference/api-keys/revoke.md)

## Response examples

* **400** `{ "error": "invalid_input", "message": "Invalid input. Check the request body." }`
* **401** `{ "error": "unauthenticated", "message": "Authentication required. Provide a valid API key or bearer token." }`
* **403** `{ "error": "session_required", "message": "API keys & OAuth tokens cannot use this route. Sign in at dashboard.xquik.com/account instead." }`
* **404** `{ "error": "not_found", "message": "Resource not found." }`
* **409** `{ "error": "api_key_revoked", "message": "This API key is revoked. Create a new key at dashboard.xquik.com/api-keys." }`
* **429** `{ "error": "rate_limit_exceeded", "message": "Too many requests. Try again later.", "retryAfter": 60 }`


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.