Перейти к содержанию

Create an API key

POSThttps://my.neuronai.uz/api/v1/api-keys

Creates an API key and returns its secret, which is shown only this once.

A key cannot get more than the key that creates it: no higher permissions, no later expiry, no higher spend limit and no wider IP allowlist. A key made this way keeps working after the key that made it is revoked.

Нужен API-ключ с api_keys:write.

Тело запроса

application/json

JSON-объект.

  • namestringОбязательно

    Мин. длина: 1 · Макс. длина: 80

  • descriptionstring | nullНеобязательный

    Макс. длина: 500

  • accessstringОбязательно

    How much a key may do. A full key holds every product at its highest level, products added later included, but never api_keys, which is only ever granted explicitly. A restricted key holds exactly the levels in its permissions map.

    Допустимые значения:fullrestricted

  • permissionsobjectНеобязательный

    Levels by product, such as {"tts": "write"}. On a restricted key a product left out is none. A full key already holds every other product at its highest level, so its map may name only api_keys.

  • expires_atstring | nullНеобязательный

    Формат: date-time

  • monthly_spend_limitnumber | nullНеобязательный

    In credits per calendar month (UTC), from 0 to 999999999999.99 with at most two decimals. Leave it out, or send null, for no limit.

  • allowed_ipsarray | nullНеобязательный

Ответ

201application/json

Created.

  • dataobjectОбязательно
  • request_idstringОбязательно

    Формат: uuid

Заголовки

  • Cache-ControlstringНеобязательный

    Includes no-store: the answer holds the new key's secret, so no cache may keep a copy.

  • X-Request-IdstringНеобязательный

    Identifies this request. A JSON body carries it as request_id too; quote it to support.

    Формат: uuid

  • X-RateLimit-LimitintegerНеобязательный

    The requests a minute the rate limit on this endpoint allows. Sent once the limit has counted the request, so not when the key itself is refused.

  • X-RateLimit-RemainingintegerНеобязательный

    How many of them are left this minute.

Ошибки

  • 401

    The API key is missing or not recognized (invalid_api_key), revoked (api_key_revoked), disabled (api_key_disabled) or expired (api_key_expired).

  • 403

    The key lacks the permission (insufficient_permissions), the IP is not allowed (ip_not_allowed), or the new key would exceed the calling key's own access or limits (insufficient_permissions).

  • 422

    The request failed validation (invalid_request). error.fields names each invalid field.

  • 429

    A rate or concurrency limit was reached (rate_limit_exceeded, concurrency_limit_exceeded). Retry after Retry-After seconds.

  • default

    Any other error, in the same shape, such as server_error (500) or service_unavailable (503).