# API keys

- Page: https://bytesms.com/docs/api-keys (markdown: https://bytesms.com/docs/api-keys.md)
- API base URL: https://api.bytesms.com/api (public resources under /api/v1)
- Auth: `Authorization: Bearer tp_live_…` — an API key from Dashboard → API Keys; keep it server-side (e.g. `BYTESMS_API_KEY`)
- All docs in one file: https://bytesms.com/llms-full.txt · OpenAPI 3.1: https://bytesms.com/openapi.json

Create, list and delete Bytesms API keys programmatically, including sending-only and domain-scoped keys.

Manage the workspace's API keys with a `full_access` key. Permissions are explained in [Authentication](https://bytesms.com/docs/authentication#permissions).

## Create an API key

`POST https://api.bytesms.com/api/v1/api-keys`

**Body**

- `name` (string, required): A name to recognise the key by (1–200 characters).
- `permission` ("full_access" | "sending_access", optional, default `full_access`): `sending_access` keys can only send emails. Defaults to `sending_access` when `domain_id` is set.
- `domain_id` (string, optional): Restrict a `sending_access` key to one domain of the workspace. Can't be combined with `full_access`.

**cURL**

```bash
# Create a sending key
curl -X POST 'https://api.bytesms.com/api/v1/api-keys' \
  -H 'Authorization: Bearer tp_live_xxxxxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{"name":"Production server","permission":"sending_access","domain_id":"cmg4jz1pb0000l8v9a6c3e2kf"}'
```

**Node.js**

```js
// Create a sending key
const res = await fetch("https://api.bytesms.com/api/v1/api-keys", {
  method: "POST",
  headers: {
    Authorization: "Bearer tp_live_xxxxxxxxx",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "name": "Production server",
    "permission": "sending_access",
    "domain_id": "cmg4jz1pb0000l8v9a6c3e2kf"
  }),
});
console.log(await res.json());
```

**Python**

```python
import requests

# Create a sending key
res = requests.post(
    "https://api.bytesms.com/api/v1/api-keys",
    headers={"Authorization": "Bearer tp_live_xxxxxxxxx"},
    json={
        "name": "Production server",
        "permission": "sending_access",
        "domain_id": "cmg4jz1pb0000l8v9a6c3e2kf"
    },
)
print(res.json())
```

**Response**

```json
{
  "id": "cmg4m9t2c0004l8v9r5x1k7wd",
  "token": "tp_live_3f9c1a7e5b2d4f60a8c9e1b3d5f7a9c2e4b6d8f0a1c3e5b7c9d1e3f5a7b9c1d3"
}
```

> **Warning**
>
> `token` is the only time the full key is returned. Store it securely. Your plan may cap the number of keys (`403 plan_limit_exceeded`, `code: api_key_limit_reached`).

## List API keys

`GET https://api.bytesms.com/api/v1/api-keys`

**cURL**

```bash
# List API keys
curl -X GET 'https://api.bytesms.com/api/v1/api-keys' \
  -H 'Authorization: Bearer tp_live_xxxxxxxxx'
```

**Node.js**

```js
// List API keys
const res = await fetch("https://api.bytesms.com/api/v1/api-keys", {
  method: "GET",
  headers: {
    Authorization: "Bearer tp_live_xxxxxxxxx",
  },
});
console.log(await res.json());
```

**Python**

```python
import requests

# List API keys
res = requests.get(
    "https://api.bytesms.com/api/v1/api-keys",
    headers={"Authorization": "Bearer tp_live_xxxxxxxxx"},
)
print(res.json())
```

**Response**

```json
{
  "object": "list",
  "has_more": false,
  "data": [
    {
      "id": "cmg4m9t2c0004l8v9r5x1k7wd",
      "name": "Production server",
      "permission": "sending_access",
      "domain_id": "cmg4jz1pb0000l8v9a6c3e2kf",
      "created_at": "2026-09-28T08:30:00.000Z",
      "last_used_at": "2026-09-28T09:12:44.000Z"
    }
  ]
}
```

## Delete an API key

`DELETE https://api.bytesms.com/api/v1/api-keys/{api_key_id}`

Revokes the key immediately. Requests made with it afterwards get `401`.

**cURL**

```bash
# Delete an API key
curl -X DELETE 'https://api.bytesms.com/api/v1/api-keys/cmg4m9t2c0004l8v9r5x1k7wd' \
  -H 'Authorization: Bearer tp_live_xxxxxxxxx'
```

**Node.js**

```js
// Delete an API key
const res = await fetch("https://api.bytesms.com/api/v1/api-keys/cmg4m9t2c0004l8v9r5x1k7wd", {
  method: "DELETE",
  headers: {
    Authorization: "Bearer tp_live_xxxxxxxxx",
  },
});
console.log(await res.json());
```

**Python**

```python
import requests

# Delete an API key
res = requests.delete(
    "https://api.bytesms.com/api/v1/api-keys/cmg4m9t2c0004l8v9r5x1k7wd",
    headers={"Authorization": "Bearer tp_live_xxxxxxxxx"},
)
print(res.json())
```

**Response**

```json
{
  "object": "api_key",
  "id": "cmg4m9t2c0004l8v9r5x1k7wd",
  "deleted": true
}
```
