API key format
Account and guest keys follow this format.- Prefix.
xq_ - Body. 64 hexadecimal characters
- Storage. Keep each REST API key in a secret manager. Never log or commit it.
Using your API key
Send account API requests with thex-api-key request header.xq_ value remains an Xquik API
key. OAuth 2.1 access tokens omit the xq_ prefix.
In Postman, paste the key into the Xquik collection’s apiKey variable. Every
request then sends it as x-api-key. See
Run in Postman.Auth methods by endpoint
The cards below list the auth method each endpoint accepts. Most routes accept an API key or dashboard session cookie. Routes that manage API keys or charge saved cards accept only dashboard sessions. X account sign-in routes also take a key with the Connect X accounts permission.API key only
GET /account accepts x-api-key. Use it to check plan, credit balance, and monitor billing from server-side integrations.Session cookie only
POST /api-keys, GET /api-keys, PATCH /api-keys, PATCH /api-keys/{id}, DELETE /api-keys/{id}, POST /api-keys/bulk-revoke, and POST /credits/quick-topup require a dashboard session cookie.An API key or OAuth token gets 403 session_required on these routes.X account sign-in
These take a dashboard session or a key with the Connect X accounts permission. They are
POST /x/accounts, GET /x/account-connection-attempts/{id}, POST /x/account-connection-challenges/{id}/submit, POST /x/accounts/{id}/reauth, POST /x/accounts/bulk-retry, and DELETE /x/accounts/{id}.The permission starts off, and only a dashboard session can turn it on. Full access doesn’t include it. A key without it gets 403 x_account_connect_permission_required. OAuth tokens and MCP tools get 403 session_required, so X passwords never reach a model. See Connect your users’ X accounts.Account and billing
PATCH /account, PUT /account/x-identity, GET /credits, POST /credits/topup, and POST /subscribe accept either x-api-key or a dashboard session cookie. For an account with a plan, POST /subscribe returns the dashboard billing page. The user signs in there.Events and webhooks
* /monitors/*, GET /events/*, * /webhooks/*, and GET /webhooks/{id}/deliveries accept either auth method.Tweets, exports, and X actions
* /draws/*, * /extractions/*, * /x/*, POST /x/media/download, GET /x/accounts, GET /x/accounts/{id}, and * /x-write/* accept either auth method.Content tools and support
GET /trends, GET /radar, * /styles/*, * /drafts/*, POST /compose, and * /support/* accept either auth method.Guest paid reads
A guest key has scope
paid_reads. It authenticates only the prepaid paid-read routes plus guest status and top-up. It never grants account, write, automation, account credential, or OAuth access.Some actions require a same-origin dashboard session. They are API key
management, saved-card top-ups, and X account sign-in and removal. API keys and
OAuth bearer tokens get
403 session_required there. A leaked key reads and
acts on its account’s data. But it never reaches credentials, saved cards, or X
passwords.The MCP server also supports OAuth 2.1 with PKCE for browser-based clients.
See OAuth 2.1 for current client compatibility and setup.
Accountless guest keys
After the user confirms USD 10 to 250,POST /api/v1/guest-wallets makes no
charge. It returns a one-use hosted checkout, a guest key, and a status URL.
The guest key stays inactive for paid reads until Xquik verifies payment. It can authenticate GET /api/v1/guest-wallets/status while pending. Once active, it can call exactly the eligible paid-read routes.Guest credential routes are direct REST only. The API MCP server never exposes wallet creation, status, or top-up as executable operations. See Accountless guest wallets for the complete flow.Machine Payments Protocol
Direct MPP payments also cover 7 fixed-price reads. This replaces API key authentication for those reads. Without credentials, the API server returns a 402 payment challenge.Challenge header
Credential header
After completing the payment, retry the request with a payment credential.Receipt header
Settled responses include a receipt.Eligible endpoints
See the MPP overview for every direct MPP operation and fixed prices.The non-MPP paid reads return
401 with WWW-Authenticate: Bearer and the optional guest wallet action. The direct MPP operations return 402 with WWW-Authenticate: Payment and the same guest action. A failed read never creates checkout.Key management
Create a key
Generate keys from the API Keys page in your dashboard or via the API. The API route accepts session auth only.Create API Key
fullKey) once. Store it in a secret manager.Limit what a key can call
Give each key only the scopes its workload needs. Pick them in the key’s settings on the API keys page. The API takes them asscopes when you create or update a key.A key without
full holds read plus any of write, monitors, exports & billing.
scope still works. paid_reads saves a read only key, and full saves Full access.
Set expiresInDays from 1 to 365 so the key stops working on its own.
Update API key changes the name or scopes later.Restrict a key to your IPs
Give a key an IP allowlist so only your servers can use it. List up to 20 IPs or CIDR ranges, like203.0.113.4 or 198.51.100.0/24.
Both IPv4 & IPv6 work.
Edit the list in the key’s settings on the API keys page.
The API takes it as allowedIps when you create or update a key.
Calls from any other IP get 403 ip_not_allowed.
An empty list allows any IP, so keys without a list work as before.
Xquik saves each range in its standard form, so 198.51.100.7/24 becomes 198.51.100.0/24.
The API keys page shows the IP that last called each key.
Search an IP there to find the keys that list it.
The search also finds keys that IP used in the last 30 days.Pause a key
Pause a key on the API keys page to stop it for a while. Select several keys to pause or resume them together. Pausing never deletes the key. The key keeps its settings. Resume works at once, so the next request goes through. You can’t pause or resume a revoked or expired key. Update API key pauses or resumes 1 key withpaused.
Pause API keys pauses or resumes up to 10,000 keys in 1 request.Cap a key’s monthly credits
SetmonthlyBudgetCredits when you create or update a key. It caps what calls
with the key spend each UTC calendar month. A key without a budget can spend
your whole balance.- At 80%, Xquik sends the account owner 1 warning email per key each month.
- Calls running at once can’t take the key past its budget.
- A call that doesn’t fit what’s left gets
403 api_key_budget_reachedand costs nothing. - A refused call never runs.
- A read with a
limitneeds that many results’ price left. - A media download needs the price of every post it names.
- A read without a
limitreturns only what fits. An extraction, a draw and a style refresh do the same. - A write needs its price plus 20 credits left. It charges only what it uses.
- A started call bills what it delivered, even past a lowered budget.
- The budget applies to REST, MCP and Apify Actor calls that use the key.
- The key works again when the next UTC month starts.
- Raise or remove the budget to unblock the key sooner.
monthlySpentCredits on each key
shows its spend this month.Revoke a key
Revoke API Key
Error response
An invalid or missing API key returns this error.401 Unauthorized
Replace the credential before retrying.
A paused key returns this error.403 Forbidden
REST routes, webhook management routes & the MCP server all send it.
Resume the key, then retry. Keys you never pause work as before.
A call outside the key’s scopes returns this error.403 Forbidden
requiredScope names the scope to add. It is write, monitors, exports, billing or full.
Add it on the API keys page, then retry.
REST & MCP refuse the same calls. Full access keys work as before.
A call from an IP outside the key’s allowlist returns this error.403 Forbidden
The message names the IP that made the call.
Add that IP to the key’s allowlist, or call from a listed IP.
Every call with the key checks the list, REST & MCP included.Security best practices
Apply these API security controls to every environment.Store keys in environment variables
Store keys in environment variables
Never hardcode API keys in your source code. Use environment variables to keep keys separate from your codebase.Access the key in your application.
.env
Never commit keys to version control
Never commit keys to version control
Add If you commit a key by accident, revoke it immediately from your dashboard. Then generate a new one. Treat the exposed key as compromised. A force-push that removes it from history doesn’t change that.
.env to your .gitignore to prevent accidental commits..gitignore
Rotate keys on a schedule
Rotate keys on a schedule
Rotate API keys on a schedule to limit the damage from a leak.
- Create a new key from the dashboard
- Update the key in all your environments
- Verify all services work with the new key
- Revoke the old key
Use separate keys for development & production
Use separate keys for development & production
Create distinct API keys for each environment. A leaked development key then cannot reach production. Each key also records usage for its environment.Give each key a descriptive name, such as “Production Backend”, “Staging”, or “Local Dev”. The name identifies the key in the dashboard.
.env.local
.env.production
Next steps. Quickstart for a complete setup walkthrough, or OAuth Overview for OAuth 2.1 integration.