# Создать API-ключ

> Создание ключа. Токен возвращается один раз.

`POST /api-keys`

Returns the key and its `token`. The token is never shown again, store it right away.

## Параметры тела

- `name` (string, required): Метка, до 50 символов.
- `permission` (string): `sending` (по умолчанию) или `full`.

## Example

cURL

```
curl -X POST 'https://sendtern.com/api-keys' \
  -H 'Authorization: Bearer st_your_api_key' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "production-web",
  "permission": "sending"
}'
```

Node.js

```
const res = await fetch("https://sendtern.com/api-keys", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.SENDTERN_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "name": "production-web",
    "permission": "sending"
  }),
});

const data = await res.json();
```

Python

```
import os
import requests

res = requests.post(
    "https://sendtern.com/api-keys",
    headers={"Authorization": f"Bearer {os.environ['SENDTERN_API_KEY']}"},
    json={
      "name": "production-web",
      "permission": "sending"
    },
)

print(res.json())
```

## Response

```json
{
  "key": {
    "id": "key_3nQe8",
    "name": "production-web",
    "permission": "sending",
    "created_at": "2026-11-21T09:30:00.000Z",
    "last_used_at": null
  },
  "token": "st_live_9f2kq1Hc7Zp0aR4mVx8sB3yT"
}
```
