API Keys

Renames an active API key, changes its scopes, IP allowlist or monthly credit budget, or pauses or resumes it. Send any of name, scope, scopes, paused, allowedIps & monthlyBudgetCredits. Pausing again keeps the first pause time. Pausing or resuming a revoked or expired key answers 409.

patch/api/v1/api-keys/{id}

Request

  • Base URL
    https://xquik.com
  • URL
    https://xquik.com/api/v1/api-keys/{id}
  • Auth
    API key in cookie __Host-xquik_session

Path parameters

idstring required

Resource ID returned by the matching create or list endpoint.

Request body

namestring

Up to 100 characters. An empty name saves the key as Default.

scope'full' | 'paid_reads'

The scope to save. The key's next request uses it.

scopesstring[]

full calls every route. read calls paid X reads. write, monitors, exports & billing add their routes. scopes wins over scope. Missing keeps the key's scopes.

allowedIpsstring[]

Up to 20 IPv4 or IPv6 addresses or CIDR ranges. The list replaces the saved one, & an empty list allows any IP.

monthlyBudgetCreditsinteger nullable

Credits the key can spend each UTC calendar month. Null removes the budget, & a missing field keeps it.

pausedboolean

true pauses the key, so its calls get 403 api_key_paused. false resumes it, & its next call goes through.

Example request

{
  "name": "Analytics notebook",
  "scope": "paid_reads",
  "scopes": [
    "read",
    "monitors"
  ],
  "allowedIps": [
    "203.0.113.4",
    "198.51.100.0/24"
  ],
  "monthlyBudgetCredits": 50000,
  "paused": true
}

Response

API key updated

idstring required
namestring required
prefixstring required
scope'full' | 'paid_reads' required

full calls every route an API key can use. paid_reads calls paid X reads plus the routes of its scopes. Other routes answer it with 403.

scopesstring[] required

The scopes the key holds, such as read & monitors. A Full access key holds full.

allowedIpsstring[] required

The IPs & CIDR ranges the key accepts calls from. An empty list accepts any IP. The API returns each range with host bits cleared, IPv6 in short form and IPv4-mapped IPv6 as IPv4.

isActiveboolean required
createdAtstring date-time required
expiresAtstring date-time

When the key stops working. Missing when it never expires.

lastUsedAtstring date-time

When the key last made a request. Missing until it does.

monthlyBudgetCreditsinteger

Credits the key can spend each UTC calendar month. Missing when the key has no budget. A call that doesn't fit what's left gets 403 api_key_budget_reached & costs nothing. A refused call never runs. A read with a limit needs that many results' price left, & a media download needs the price of every post it names. A read without a limit, an extraction, a draw & a style refresh return only what fits. A write needs its price plus 20 credits left, & it charges only what it uses. Calls running at once can't take the key past its budget. A started call bills what it delivered, even past a lowered budget.

monthlySpentCreditsinteger required

Credits charged for calls with the key this UTC calendar month. Once it reaches the budget, every call with the key gets 403 api_key_budget_reached until the next UTC month or a higher budget, even a retry with a used Idempotency-Key.

pausedAtstring date-time

When the key was paused. Missing while it works. A paused key gets 403 api_key_paused on every call.

Example response

{
  "id": "42",
  "name": "My API Key",
  "prefix": "xq_live_exam",
  "scope": "paid_reads",
  "scopes": [
    "read"
  ],
  "allowedIps": [
    "203.0.113.4",
    "198.51.100.0/24"
  ],
  "isActive": true,
  "createdAt": "2025-01-15T12:00:00Z",
  "expiresAt": "2025-02-14T12:00:00Z",
  "lastUsedAt": "2025-01-16T09:30:00Z",
  "monthlyBudgetCredits": 50000,
  "monthlySpentCredits": 1200,
  "pausedAt": "2025-01-20T08:00:00Z"
}

Changes