# API tokens

> Tokens: list and revoke. Tokens are made in the panel, at /account/api-tokens.

Source: https://docs.clouduxe.com/api/reference/api-tokens/

Base URL: `https://api.clouduxe.com/v1`. Generated from the API contract, version 2026-12-01.

## The ApiToken object

An API token. The token itself is shown only once, in the panel, when it is created; it is never returned by the API.

### Attributes

- `object` (string, required): The object's type. Always "api_token".
- `id` (string (uuid), required): The token's id.
- `name` (string, required): The token's name.
- `prefix` (string, required): The token's prefix: cxk_live_. One of `cxk_live_`.
- `lastFour` (string, required): The token's last four characters, to tell tokens apart.
- `scopes` (array of string, required): What the token may do.
- `apiVersion` (string, required): The API version used when a request sends no Clouduxe-Version header.
- `ipAllowlist` (array of string, required): Addresses or CIDR ranges the token may be used from. Empty means any address.
- `createdBy` (object, required): Who made it.
  - `personId` (string (uuid), required): The person's id.
  - `name` (string or null, required): Their name, or null.
- `createdAt` (string (date-time), required): When it was made.
- `expiresAt` (string (date-time) or null, required): When it expires, or null for never. A token holding any elevated scope (marked elevated at https://docs.clouduxe.com/api/authentication#scopes) always expires, at most 365 days after creation.
- `lastUsedAt` (string (date-time) or null, required): When it was last used (updated at most once a minute), or null.
- `lastUsedIp` (string or null, required): The address it was last used from, or null.
- `revokedAt` (string (date-time) or null, required): When it was revoked, or null.
- `revokedReason` (string or null, required): Why: user, leaked (reported by secret scanning), member_removed, person_disabled, account_closed or expired. One of `user`, `leaked`, `member_removed`, `person_disabled`, `account_closed`, `expired`.
- `livemode` (boolean, required): True for objects of your live account.

### Example

```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
}
```

## List API tokens

`GET /api-tokens`

Use this to audit which tokens exist and when they were last used. The account owner sees every token on the account; anyone else sees their own.

Token scope: `api_tokens:read`.

### Query parameters

- `limit` (integer): How many objects to return, 1 to 100. Default 20. Default `20`. min 1, max 100.
- `cursor` (string): The nextCursor of the previous page. Valid for 24 hours, with the same filters. max length 512.

### Headers

- `Clouduxe-Version` (string): The API version to use, such as 2026-12-01. Omit it to use your token's version. pattern ^[0-9]{4}-[0-9]{2}-[0-9]{2}$.

### Responses

- `200`: A page of tokens.
- `400`: The request is not valid. Codes: cursor_invalid, version_invalid, parameter_invalid.
- `401`: Authentication failed. Codes: token_missing, token_invalid, token_expired, token_revoked.
- `403`: The token is not allowed to do this. Codes: ip_not_allowed, api_access_disabled, scope_missing.
- `429`: A rate limit was reached. Codes: rate_limited.
- `500`: Unexpected error. Codes: internal_error.
- `503`: Temporarily unavailable. Codes: unavailable.

### Request

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

Node SDK:
```javascript
import { Clouduxe } from "@clouduxe/sdk";

const cx = new Clouduxe({ apiKey: process.env.CLOUDUXE_API_KEY });

for await (const apiToken of cx.apiTokens.list()) {
  console.log(apiToken.id);
}
```

Python:
```python
import os
import requests

res = requests.get(
    "https://api.clouduxe.com/v1/api-tokens",
    headers={
        "Authorization": f"Bearer {os.environ['CLOUDUXE_API_KEY']}",
    },
)
page = res.json()
```

PHP SDK:
```php
<?php
require 'vendor/autoload.php';

$cx = new \Clouduxe\Clouduxe(['apiKey' => getenv('CLOUDUXE_API_KEY')]);

foreach ($cx->apiTokens->list() as $apiToken) {
    echo $apiToken->id, PHP_EOL;
}
```

fetch:
```javascript
const res = await fetch("https://api.clouduxe.com/v1/api-tokens", {
  headers: {
    Authorization: `Bearer ${process.env.CLOUDUXE_API_KEY}`,
  },
});
const page = await res.json();
```

### Response (`200`)

```json
{
  "object": "list",
  "data": [
    {
      "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
    }
  ],
  "hasMore": false,
  "nextCursor": null
}
```


## Get the current token

`GET /api-tokens/current`

Use this to check what the token you hold may do. Needs no scope.

### Headers

- `Clouduxe-Version` (string): The API version to use, such as 2026-12-01. Omit it to use your token's version. pattern ^[0-9]{4}-[0-9]{2}-[0-9]{2}$.

### Responses

- `200`: The token.
- `400`: The request is not valid. Codes: version_invalid.
- `401`: Authentication failed. Codes: token_missing, token_invalid, token_expired, token_revoked.
- `403`: The token is not allowed to do this. Codes: ip_not_allowed, api_access_disabled.
- `429`: A rate limit was reached. Codes: rate_limited.
- `500`: Unexpected error. Codes: internal_error.
- `503`: Temporarily unavailable. Codes: unavailable.

### Request

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

Node SDK:
```javascript
import { Clouduxe } from "@clouduxe/sdk";

const cx = new Clouduxe({ apiKey: process.env.CLOUDUXE_API_KEY });

const apiToken = await cx.apiTokens.getCurrent();
```

Python:
```python
import os
import requests

res = requests.get(
    "https://api.clouduxe.com/v1/api-tokens/current",
    headers={
        "Authorization": f"Bearer {os.environ['CLOUDUXE_API_KEY']}",
    },
)
apiToken = res.json()
```

PHP SDK:
```php
<?php
require 'vendor/autoload.php';

$cx = new \Clouduxe\Clouduxe(['apiKey' => getenv('CLOUDUXE_API_KEY')]);

$apiToken = $cx->apiTokens->getCurrent();
```

fetch:
```javascript
const res = await fetch("https://api.clouduxe.com/v1/api-tokens/current", {
  headers: {
    Authorization: `Bearer ${process.env.CLOUDUXE_API_KEY}`,
  },
});
const apiToken = await res.json();
```

### 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
}
```


## Get an API token

`GET /api-tokens/{tokenId}`

Use this to read one token's details.

Token scope: `api_tokens:read`.

### Path parameters

- `tokenId` (string (uuid), required): The token's id.

### Headers

- `Clouduxe-Version` (string): The API version to use, such as 2026-12-01. Omit it to use your token's version. pattern ^[0-9]{4}-[0-9]{2}-[0-9]{2}$.

### Responses

- `200`: The token.
- `400`: The request is not valid. Codes: version_invalid.
- `401`: Authentication failed. Codes: token_missing, token_invalid, token_expired, token_revoked.
- `403`: The token is not allowed to do this. Codes: ip_not_allowed, api_access_disabled, scope_missing.
- `404`: Not found. Codes: not_found.
- `429`: A rate limit was reached. Codes: rate_limited.
- `500`: Unexpected error. Codes: internal_error.
- `503`: Temporarily unavailable. Codes: unavailable.

### Request

curl:
```bash
curl https://api.clouduxe.com/v1/api-tokens/0b7f3c2a-9e4d-4f1a-8c6b-5d2e7a9f1c3b \
  -H "Authorization: Bearer $CLOUDUXE_API_KEY"
```

Node SDK:
```javascript
import { Clouduxe } from "@clouduxe/sdk";

const cx = new Clouduxe({ apiKey: process.env.CLOUDUXE_API_KEY });

const apiToken = await cx.apiTokens.get("0b7f3c2a-9e4d-4f1a-8c6b-5d2e7a9f1c3b");
```

Python:
```python
import os
import requests

res = requests.get(
    "https://api.clouduxe.com/v1/api-tokens/0b7f3c2a-9e4d-4f1a-8c6b-5d2e7a9f1c3b",
    headers={
        "Authorization": f"Bearer {os.environ['CLOUDUXE_API_KEY']}",
    },
)
apiToken = res.json()
```

PHP SDK:
```php
<?php
require 'vendor/autoload.php';

$cx = new \Clouduxe\Clouduxe(['apiKey' => getenv('CLOUDUXE_API_KEY')]);

$apiToken = $cx->apiTokens->get('0b7f3c2a-9e4d-4f1a-8c6b-5d2e7a9f1c3b');
```

fetch:
```javascript
const res = await fetch("https://api.clouduxe.com/v1/api-tokens/0b7f3c2a-9e4d-4f1a-8c6b-5d2e7a9f1c3b", {
  headers: {
    Authorization: `Bearer ${process.env.CLOUDUXE_API_KEY}`,
  },
});
const apiToken = await res.json();
```

### 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
}
```


## Revoke an API token

`DELETE /api-tokens/{tokenId}`

Use this to stop a token working at once, for example after a leak. Any token can revoke itself without a scope; revoking another token needs api_tokens:write. Revoking a revoked token answers it unchanged. New tokens are made only in the panel.

Token scope: `api_tokens:write`.

### Path parameters

- `tokenId` (string (uuid), required): The token's id.

### Headers

- `Clouduxe-Version` (string): The API version to use, such as 2026-12-01. Omit it to use your token's version. pattern ^[0-9]{4}-[0-9]{2}-[0-9]{2}$.
- `Idempotency-Key` (string, required): A unique key for this logical request, 1 to 128 characters of letters, digits, underscore, dot, colon or hyphen; a UUID is best. Retrying with the same key is safe: the change happens once and the retry gets the same answer. Keys are kept 48 hours. pattern ^[A-Za-z0-9_.:-]{1,128}$.

### Responses

- `200`: The revoked token.
- `400`: The request is not valid. Codes: version_invalid, idempotency_key_required, idempotency_key_invalid.
- `401`: Authentication failed. Codes: token_missing, token_invalid, token_expired, token_revoked.
- `403`: The token is not allowed to do this. Codes: forbidden, ip_not_allowed, api_access_disabled, scope_missing.
- `404`: Not found. Codes: not_found.
- `409`: The request conflicts with the object's current state. Codes: idempotency_in_progress.
- `422`: The request is well formed but cannot be carried out. Codes: idempotency_mismatch.
- `429`: A rate limit was reached. Codes: rate_limited.
- `500`: Unexpected error. Codes: internal_error.
- `503`: Temporarily unavailable. Codes: unavailable, outcome_unknown, limits_unavailable.

### Request

curl:
```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"
```

Node SDK:
```javascript
import { Clouduxe } from "@clouduxe/sdk";

const cx = new Clouduxe({ apiKey: process.env.CLOUDUXE_API_KEY });

const apiToken = await cx.apiTokens.revoke("0b7f3c2a-9e4d-4f1a-8c6b-5d2e7a9f1c3b");
```

Python:
```python
import os
import requests

res = requests.delete(
    "https://api.clouduxe.com/v1/api-tokens/0b7f3c2a-9e4d-4f1a-8c6b-5d2e7a9f1c3b",
    headers={
        "Authorization": f"Bearer {os.environ['CLOUDUXE_API_KEY']}",
        "Idempotency-Key": "6f1c2e9a-4b7d-4e3a-9c8f-1a2b3c4d5e6f",
    },
)
apiToken = res.json()
```

PHP SDK:
```php
<?php
require 'vendor/autoload.php';

$cx = new \Clouduxe\Clouduxe(['apiKey' => getenv('CLOUDUXE_API_KEY')]);

$apiToken = $cx->apiTokens->revoke('0b7f3c2a-9e4d-4f1a-8c6b-5d2e7a9f1c3b');
```

fetch:
```javascript
const res = await fetch("https://api.clouduxe.com/v1/api-tokens/0b7f3c2a-9e4d-4f1a-8c6b-5d2e7a9f1c3b", {
  method: "DELETE",
  headers: {
    Authorization: `Bearer ${process.env.CLOUDUXE_API_KEY}`,
    "Idempotency-Key": "6f1c2e9a-4b7d-4e3a-9c8f-1a2b3c4d5e6f",
  },
});
const apiToken = await res.json();
```

### 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
}
```
