# Authentication and scopes

> How a request proves who sent it, how to make an API token in the panel, and which scope each operation needs.

Source: https://docs.clouduxe.com/api/authentication/

Every request carries an API token. The token belongs to one account and
carries a set of scopes, and each operation needs one scope. Tokens are made
only in the panel, never through the API, so a stolen token can never mint a
wider or longer-lived one.

## Send the token

Put the token in the `Authorization` header with the `Bearer` scheme:

```bash
curl https://api.clouduxe.com/v1/api-tokens/current \
  -H "Authorization: Bearer $CLOUDUXE_API_KEY"
```

Any other scheme, a token in the query string or a token in a cookie is refused
with `401` [`token_missing`](https://docs.clouduxe.com/api/errors/#token_missing).

The API speaks HTTPS only. A request over plain HTTP is refused at the edge with
no redirect, so a token sent that way never reaches the API, but it did cross
the network in clear: treat it as leaked and revoke it.

A token is `cxk_live_` followed by 46 letters and digits.

## Make a token

### Step 1: Open API tokens in the panel

Go to [API tokens](https://dash.clouduxe.com/account/api-tokens) in the panel.
The same page lists your webhook endpoints beside your tokens.

### Step 2: Confirm it is you

Making a token needs a fresh confirmation: a passkey, or an email code entered
in the last 10 minutes.

### Step 3: Choose its scopes, expiry and addresses

Give it only the scopes your code needs (the table below lists what each one
opens). Choose an expiry of 7, 30, 90 or 365 days, or none; the panel suggests
90 days. A token that holds an elevated scope always expires, at most 365 days
after it was made.

Optionally, limit it to up to 20 IPv4 or IPv6 addresses or ranges. A request
from anywhere else is refused with `403`
[`ip_not_allowed`](https://docs.clouduxe.com/api/errors/#ip_not_allowed), and the token's creator gets
one email a day for each new address.

### Step 4: Copy it once

The token is shown once, when it is made. Store it in your secret manager or an
environment variable right away. The account owner gets an email naming the
token, who made it, its scopes and its expiry, but never the token itself.

A token's scopes cannot be changed after it is made: make a new token instead.
Each person can hold up to 25 tokens per account. A token also keeps the
API version that was current when it was made; see
[Versioning and changelog](https://docs.clouduxe.com/api/changelog/).

## Scopes

Each operation in the reference names the scope it needs. A token without that
scope gets `403` [`scope_missing`](https://docs.clouduxe.com/api/errors/#scope_missing). This is every
scope in the contract, with the operations it opens:

- `account:read`: Get your account
- `api_tokens:read`: List API tokens; Get an API token
- `api_tokens:write`: Revoke an API token
- `billing:read`: List invoices; Get an invoice; Get an invoice PDF link; Get your wallet; List wallet transactions
- `firewall:read`: Get a firewall; List firewall presets
- `firewall:write`: Turn protection on or off; Set the default policy; Add a firewall rule; Update a firewall rule; Delete a firewall rule; Block an address; Unblock an address; Trust an address; Untrust an address; Apply a firewall preset
- `orders:read`: Preview an order; List orders; Get an order
- `orders:write`: Create an order; Update an order; Retrieve an action's secret; Delete an action's secret
- `protection:read`: Get protection status; List attacks; Get an attack
- `services:destructive`: Reinstall a server; Reset a server's password; Terminate a service; Retrieve an action's secret; Delete an action's secret
- `services:lifecycle`: Change a service's plan; Set cancellation at period end
- `services:read`: List services; Get a service; List a server's OS images; Get a service's traffic; List plan change options; List a service's actions; Get an action
- `services:write`: Update a service; Run a power action
- `ssh_keys:read`: List SSH keys; Get an SSH key
- `ssh_keys:write`: Add an SSH key; Update an SSH key; Delete an SSH key
- `tickets:read`: List support departments; List tickets; Get a ticket; Get an attachment
- `tickets:write`: Open a ticket; Reply to a ticket; Close a ticket; Start an attachment upload; Finish an attachment upload
- `webhooks:read`: List webhook endpoints; Get a webhook endpoint; Get a webhook delivery; List events; Get an event
- `webhooks:write`: Create a webhook endpoint; Update a webhook endpoint; Delete a webhook endpoint; Rotate a webhook secret; Send a test event; Redeliver an event
- No scope: List plans; Get a plan; List regions; Get the current token

Some scopes are elevated: `services:lifecycle`, `services:destructive`,
`ssh_keys:write`, `orders:write`, `webhooks:write` and `api_tokens:write`. They
move money, destroy data, send account data to a URL or revoke access, so the
panel flags them and the creation email names them.

> **Prices need orders:read:** Listing plans and regions needs a valid token and no scope, but plan prices are
> answered only to a token with `orders:read`. Any other token sees each price as
> `null`, with `unpricedReason` set to `no-access`.

## Tokens made by delegates

If you work on an account as a delegate, the panel offers only the scopes your
role can use there:

| Role | Scopes offered |
| --- | --- |
| **Owner** | Every scope. |
| **Admin** and **Operator** | `services:read`, `services:write`, `firewall:read`, `firewall:write` and `services:destructive`. |
| **Viewer** | `services:read` and `firewall:read`. |

For a delegate, `services:destructive` covers reinstalling only, and a
delegate's reinstall takes no SSH keys; a root password reset or a termination
answers `403` [`forbidden`](https://docs.clouduxe.com/api/errors/#forbidden).

On every request, a token can do only what both its scopes and its person's
current role allow. A role change takes effect on the next request, and removing
a member revokes that person's tokens on the account.

## Check and revoke a token

Any token can read itself, with no scope:

`GET /api-tokens/current` (reference: https://docs.clouduxe.com/api/reference/api-tokens/get-current-api-token/)

```bash
curl https://api.clouduxe.com/v1/api-tokens/current \
  -H "Authorization: Bearer $CLOUDUXE_API_KEY"
```

##### Response (`200`)

```json
{
  "object": "api_token",
  "id": "0b7f3c2a-9e4d-4f1a-8c6b-5d2e7a9f1c3b",
  "name": "whmcs-production",
  "prefix": "cxk_live_",
  "lastFour": "Q7x2",
  "scopes": [
    "services:read",
    "services:write",
    "services:lifecycle",
    "services:destructive",
    "orders:read",
    "orders:write",
    "billing:read",
    "ssh_keys:read",
    "ssh_keys:write",
    "webhooks:read"
  ],
  "apiVersion": "2026-12-01",
  "ipAllowlist": [
    "203.0.113.0/24"
  ],
  "createdBy": {
    "personId": "8d1e4b6a-2c3f-4a5b-9d7e-1f0a2b3c4d5e",
    "name": "Asha Rao"
  },
  "createdAt": "2026-12-01T08:15:12Z",
  "expiresAt": "2027-12-01T08:15:12Z",
  "lastUsedAt": "2026-12-04T10:02:41Z",
  "lastUsedIp": "203.0.113.9",
  "revokedAt": null,
  "revokedReason": null,
  "livemode": true
}
```

Revoking takes effect at once, from the panel or with the API. Revoking the
token that makes the request needs no scope; revoking any other token needs
`api_tokens:write`. A revoked token answers `401`
[`token_revoked`](https://docs.clouduxe.com/api/errors/#token_revoked), and an expired one `401`
[`token_expired`](https://docs.clouduxe.com/api/errors/#token_expired).

`DELETE /api-tokens/{tokenId}` (reference: https://docs.clouduxe.com/api/reference/api-tokens/revoke-api-token/)

```bash
curl -X DELETE https://api.clouduxe.com/v1/api-tokens/0b7f3c2a-9e4d-4f1a-8c6b-5d2e7a9f1c3b \
  -H "Authorization: Bearer $CLOUDUXE_API_KEY" \
  -H "Idempotency-Key: 6f1c2e9a-4b7d-4e3a-9c8f-1a2b3c4d5e6f"
```

##### Response (`200`)

```json
{
  "object": "api_token",
  "id": "0b7f3c2a-9e4d-4f1a-8c6b-5d2e7a9f1c3b",
  "name": "whmcs-production",
  "prefix": "cxk_live_",
  "lastFour": "Q7x2",
  "scopes": [
    "services:read",
    "services:write",
    "services:lifecycle",
    "services:destructive",
    "orders:read",
    "orders:write",
    "billing:read",
    "ssh_keys:read",
    "ssh_keys:write",
    "webhooks:read"
  ],
  "apiVersion": "2026-12-01",
  "ipAllowlist": [
    "203.0.113.0/24"
  ],
  "createdBy": {
    "personId": "8d1e4b6a-2c3f-4a5b-9d7e-1f0a2b3c4d5e",
    "name": "Asha Rao"
  },
  "createdAt": "2026-12-01T08:15:12Z",
  "expiresAt": "2027-12-01T08:15:12Z",
  "lastUsedAt": "2026-12-04T10:02:41Z",
  "lastUsedIp": "203.0.113.9",
  "revokedAt": "2026-12-04T10:05:00Z",
  "revokedReason": "user",
  "livemode": true
}
```
