POST /api/v1/auth/service-token
Mint Service Token
Mint (or rotate) a long-lived READ-ONLY access token for an external agent.
Superuser-only. The endpoint can only create/serve users with read-only agent scope — it is structurally unable to hand out full-access tokens. Re-minting reactivates a previously revoked user.
Авторизация: нужен Authorization: Bearer <token>
curl -sS -X POST "https://entherium.duckdns.org:8443/api/v1/auth/service-token" \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{"email":"<email>","expires_days":"<expires_days>","full_name":"<full_name>","revoke_prior":"<revoke_prior>"}'Ответ 200
Заголовок раздела «Ответ 200»{ "access_token": "eyJhbGciOiJIUzI1NiJ9.<payload>.<signature>", "api_scope": "agent", "email": "agent@entherium.dev", "expires_in": 7776000, "token_type": "bearer", "user_guid": 5}Возвращает
Заголовок раздела «Возвращает»ServiceTokenResponse — Successful Response
| Поле | Тип | Описание |
|---|---|---|
access_token | string | |
api_scope | string | |
email | string | |
expires_in | integer | |
token_type | string (opt.) | |
user_guid | integer |
Параметры
Заголовок раздела «Параметры»| Параметр | Где | Обязателен | Тип | По умолчанию | Ограничения | Описание |
|---|---|---|---|---|---|---|
Idempotency-Key | header | нет | string | — | uuid | Optional. |
Тело запроса
Заголовок раздела «Тело запроса»| Поле | Тип | Обязательно | Описание |
|---|---|---|---|
email | string | нет | |
expires_days | integer | нет | |
full_name | string | null | нет | |
revoke_prior | boolean | нет |
| Код | Смысл | Тело |
|---|---|---|
401 | Missing or invalid authentication credentials | ErrorResponse |
409 | The e-mail belongs to an existing non-read-only user; refusing to convert | ErrorResponse |
422 | Validation Error | HTTPValidationError |
Тело любой ошибки — {detail, code?, request_id, doc_url}: request_id — что цитировать, doc_url ведёт в Справочник ошибок.