Перейти к содержимому

POST /api/v1/auth/agent-token

Статус: GA Доступ: по токену контракт API: 0.3.0 · capability 2026-09-03.1 Открыть как Markdown Открыть в Claude Открыть в ChatGPT

Mint Agent Token

mint (or rotate) a scoped AGENT token + its contract grants.

Superuser-only. Creates (or reuses) the agent identity and REPLACES its grant pool with body.grants (default-deny — a contract not listed is inaccessible). Changing the pool or capabilities later is a grant edit, no re-mint needed. publish is granted only when listed explicitly: withhold on prod contracts by default).

Авторизация: нужен Authorization: Bearer <token>

Окно терминала
curl -sS -X POST "https://entherium.duckdns.org:8443/api/v1/auth/agent-token" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{"email":"agent@entherium.dev","expires_days":90,"full_name":"Partner agent","grants":[{"capabilities":["submit","launch","cancel","edit_config"],"salescontract":40}],"revoke_prior":true}'
{
"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_tokenstring
api_scopestring
emailstring
expires_ininteger
token_typestring (opt.)
user_guidinteger
ПараметрГдеОбязателенТипПо умолчаниюОграниченияОписание
Idempotency-Keyheaderнетstring—uuidOptional.
ПолеТипОбязательноОписание
emailstringнет
expires_daysintegerнет
full_namestring | nullнет
grantsмассив AgentGrantSpecда
revoke_priorbooleanнет

Пример:

{
"email": "agent@entherium.dev",
"expires_days": 90,
"full_name": "Partner agent",
"grants": [
{
"capabilities": [
"submit",
"launch",
"cancel",
"edit_config"
],
"salescontract": 40
}
],
"revoke_prior": true
}
КодСмыслТело
401Missing or invalid authentication credentialsErrorResponse
409The e-mail belongs to a non-agent user; refusing to convertErrorResponse
422Validation ErrorHTTPValidationError

Тело любой ошибки — {detail, code?, request_id, doc_url}: request_id — что цитировать, doc_url ведёт в Справочник ошибок.