- API Reference
- Box API
- API keys
Create an API key
Use this to create a key for a bot, a script or the Change IP URL of an anti-detect browser such as AdsPower or Dolphin. A Full access key (xpf_…) has the same rights as the admin login on every route that accepts it, except key management, and is sent as Authorization: Bearer xpf_…; never put it in a URL. A Rotate only key (xpr_…) can only call the rotation links /reset, /api/v1/rotate_ip/proxy/{proxy} and /api/v1/rotate_ip/position/{position}, as the token query parameter or as a Bearer header. The full key is returned once in data.key; the box keeps only a hash, so it cannot show it again (regenerate it instead). The box holds at most 50 keys. Available from XProxy v21.3.61.
/v2/api_keysRequest body application/json · required
Label shown in the panel. 1-40 characters without control characters.
full creates an xpf_ key, rotate an xpr_ key.
full, rotateExpiry time as UTC epoch milliseconds in the future, or null (or omitted) for a key that never expires.
Authentication
Needs the admin login (HTTP Basic, or the panel session). An API key cannot manage API keys: any key sent here, even a valid Full access key, is refused with HTTP 401 invalid_token, also from the LAN. A browser request whose Origin is not the panel's own address is refused with HTTP 403 cross_origin; requests without an Origin header (curl, scripts) are not affected.
How authentication works: login, API keys, LAN and 401 answers →
Responses
The new key, or the reason it was refused. Sent with Cache-Control: no-store.
Either an API key was sent and refused (invalid_token), or no key was sent and the caller is not trusted and sent no valid Basic credentials (the same refusals as other routes). invalid_token is the same body for an unknown, expired, deleted, regenerated, malformed or wrong-type key, so it never tells which. It is answered from every address, including the LAN, loopback, a whitelisted IP and Tailscale. Also sent with WWW-Authenticate and Cache-Control: no-store.
A browser request from another origin.
Errors returned in msg
| msg | Meaning | What to do |
|---|---|---|
invalid_name | The name is missing, empty, longer than 40 characters or has control characters (code field, HTTP 200). | Send a name of 1-40 characters. |
invalid_type | type is not full or rotate (code field). | Send full or rotate. |
invalid_expiry | expires_at is not a whole number in the future (code field). | Send a future time in UTC milliseconds, or null for no expiry. |
limit_reached | The box already holds 50 keys (code field). | Delete a key you no longer use. |
invalid_token | An API key was sent. Keys cannot manage keys (HTTP 401). | Call this with the admin login and no key. |
cross_origin | The request came from a browser page on another origin (HTTP 403, in the code field). | Open the panel itself |