
# API Key Permissions: Create and Scope a 0x.cloud Key

**A 0x.cloud API key gives a program, script or AI agent access to your account through the REST API and MCP.** API key permissions work like this: every key has its own set of scopes (view, create, delete and more) and a monthly spend cap. The key does exactly what you allowed and can't buy anything new past the amount you set (hourly servers it already runs keep billing).


## API Key Permissions: What Each Scope Allows

Scope names match the [API reference](https://0x.cloud/v1/openapi.json), where every method lists the scope it requires.

| Scope | What it allows | Typical use |
|---|---|---|
| `servers.read` | list servers, their status and load | monitoring, n8n reports |
| `servers.create` | create servers, get an exact price with `dry_run` | an agent spins up a server for a task |
| `servers.delete` | delete servers | CI cleans up temporary servers |
| `servers.exec` | run commands inside a server | an agent installs and configures software |
| `billing.read` | balance and transactions | spending dashboard |
| `servers.*` | every server scope, including delete | your personal admin script |

**Heads up: a default key gets `servers.*`, `billing.read` and `account.read`.** That means it can already delete servers. For an agent key, remove `servers.delete` unless it truly needs it; then it cannot delete a single server, even if someone asks it to.

## Monthly Spend Cap

Besides scopes, each key has a spend cap in dollars per calendar month. It blocks new purchases: a paid request past it gets 402 `key_spend_limit_reached`, nothing is created or charged, even if your balance has more. The counter includes server creation, add-ons, and the hourly charges and renewals of servers that key created. Running servers are not stopped when the cap is hit. How to pick a number: [API key spend limit](https://0x.cloud/kb/billing/api-key-spend-limit).

## How to Create an API Key

1. Sign in to the 0x.cloud dashboard and open the API and MCP section.
2. Create a new key and give it a clear name: `claude-code-laptop`, `n8n-prod`, `ci-deploy`.
3. Check only the scopes it needs.
4. Set a monthly spend cap, for example $20.
5. Optionally set an expiry and a list of IPv4 addresses the key works from (for example, your n8n server's IP).
6. Create the key and save it right away in a password manager or an environment variable. **The key is shown once** and cannot be viewed again.

Keys look like `0x_live_...`. Scopes and caps on an existing key can only be changed in the dashboard; through the API a key can only rename itself.

## Ready-Made Scope Sets

| Who gets the key | Scopes | Spend cap |
|---|---|---|
| Dashboard or n8n balance report | `servers.read`, `billing.read` | spending disabled |
| AI assistant that picks a plan and quotes a price | `servers.read`, `servers.create` | small, e.g. $10 |
| AI agent that creates servers | `servers.read`, `servers.create`, `servers.exec` | your budget, e.g. $20 |
| CI that spins up a build server and deletes it | `servers.read`, `servers.create`, `servers.delete` | build budget |
| Your personal admin script | `servers.*`, `billing.read` | as needed |

For a safe agent setup step by step, see [how to limit an AI agent](https://0x.cloud/kb/ai/limit-ai-agent).

## How to Use the Key

Send the key in the `Authorization: Bearer` header. First check that it works and what it is allowed to do:

```bash
# keep the key in an environment variable, not in code
export OX_API_KEY="0x_live_your_key"

# scopes, spend rule, spent and remaining
curl -s https://0x.cloud/v1/account/key \
  -H "Authorization: Bearer $OX_API_KEY"
```

Then get an exact server price with [dry_run](https://0x.cloud/kb/api-mcp/dry-run). Nothing is created or charged, but the key needs `servers.create`:

```bash
# exact price for s1-2 on hourly billing
curl -s https://0x.cloud/v1/servers \
  -H "Authorization: Bearer $OX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"plan": "s1-2", "billing_cycle": "hourly", "dry_run": true}'
```

Every endpoint is described in the OpenAPI spec and llms.txt; first steps are in the [REST API quickstart](https://0x.cloud/kb/api-mcp/api-quickstart). By default a key can make 120 requests per minute; past that you get 429 `rate_limited`.

The same key works for MCP: server URL `https://0x.cloud/v1/mcp`, key in the Authorization header. Connecting Claude, Cursor and ChatGPT is covered on the [0x.cloud MCP server page](https://0x.cloud/mcp).


```text
Using the 0x.cloud MCP, check what scopes and spend cap my key has: call get_key_info, then show my balance and server list. Do not create or delete anything.
```


## Storing, Rotating and Revoking Keys

- One key per app or agent. Each gets its own scopes and cap, and you can revoke one without touching the rest.
- Keep keys in environment variables, CI secrets or your MCP client settings. Never commit them to git.
- Rotate when someone leaves, a laptop changes hands or you suspect a leak: create a new key, update the app, then revoke the old one.
- To revoke, delete the key in the API and MCP section or call `DELETE https://0x.cloud/v1/api-keys/{id}`. The key's activity log is kept for 90 days, even after deletion, so you can see what it did.

## Errors and Fixes

| API response | Cause | Fix |
|---|---|---|
| 401 `unauthenticated` | key copied partially, with a space, or without `Bearer` | check the header: `Authorization: Bearer 0x_live_...` |
| 403 `insufficient_scope` | the key lacks the scope | grant it in the dashboard or create a key with a different set |
| 402 `key_spend_limit_reached` | the key's monthly cap is used up | raise the cap in the dashboard or delete servers you no longer need |
| 402 `insufficient_balance` | not enough money on the balance | top up |
| 429 `rate_limited` | more than 120 requests per minute | add pauses or raise the key's rate limit |

**Key pushed to a public repo.** Revoke it in the dashboard immediately, create a new one, and review your server list and the key's activity log.

## Where to Put It to Work

API keys let your scripts, CI or an AI agent manage servers. To test a key for real, create an s1-1 server (1 vCPU, 1 GB RAM) on hourly billing through the API: about $0.030750 per hour, and the unused remainder returns to your balance when you delete it. More on what the API can do: [VPS with an API](https://0x.cloud/vps-api).


[Create server: s1-2, $7.99/mo](https://0x.cloud/cabinet/create?plan=s1-2)


## FAQ

**What permissions can a 0x.cloud API key have?**
Scopes are granted one by one: servers.read (view), servers.create (create servers and get prices via dry_run), servers.delete (delete), billing.read (balance) and more. A default key gets servers.*, which includes delete, so remove that scope for an agent.

**What is a key's spend cap?**
A dollar amount per calendar month after which the key can't buy anything new: a paid request gets 402 key_spend_limit_reached. Hourly servers already running keep billing and count toward it.

**Can I view a key again after creating it?**
No, the key is shown once. If you lose it, create a new one and revoke the old one.

**How do I revoke an API key?**
Delete it in the API and MCP section of the dashboard or call DELETE /v1/api-keys/{id}. Requests with that key stop working right away.

**Does the same key work for the API and MCP?**
Yes. You pass the key in the Authorization: Bearer header both for REST API calls and when connecting the MCP server.
