Настройка лимита ключа
PUT /v1/key-limits
PUT /v1/key-limits
Владельцы и администраторы управляют всеми ключами. Разработчики с apiKey:update могут ограничивать собственные ключи, но не отменять правило администратора. Все периоды и правила пространства применяются совместно. calls=0 блокирует вызовы; budget=0 блокирует платные вызовы. Оба лимита null удаляют только выбранный период. Правило custom блокирует ключ вне интервала [starts_at, ends_at); reset_interval_seconds задаёт повторяющиеся окна от начала интервала. Отдельное задание сброса и денежное начисление не выполняются.
Доступ
Требуется bearer-авторизация. Описание операции задаёт дополнительные права, роли и ограничения для сессий кабинета. Сам по себе API-ключ их не предоставляет.
Тело запроса
| Поле | Тип | Обязательно | Описание |
|---|---|---|---|
key_id | string | да | |
period | "daily" ∣ "weekly" ∣ "monthly" ∣ "custom" | да | |
calls | integer ∣ null | да | |
budget_microusd | integer ∣ null | да | |
starts_at | string ∣ null | нет | Включающая нижняя граница периода: ISO-время UTC с окончанием Z. |
ends_at | string ∣ null | нет | Исключающая верхняя граница периода: ISO-время UTC с окончанием Z. После неё вызовы заблокированы до удаления правила. |
reset_interval_seconds | integer ∣ null | нет | Длительность повторяющегося окна от starts_at; null означает одно фиксированное окно. Для календарного периода произвольные даты и интервалы не допускаются. |
Полная схема: KeyLimitInput
{
"properties": {
"key_id": {
"type": "string",
"maxLength": 256,
"minLength": 1,
"title": "Key Id"
},
"period": {
"type": "string",
"enum": [
"daily",
"weekly",
"monthly",
"custom"
],
"title": "Period"
},
"calls": {
"anyOf": [
{
"type": "integer",
"maximum": 9007199254740991,
"minimum": 0
},
{
"type": "null"
}
],
"title": "Calls"
},
"budget_microusd": {
"anyOf": [
{
"type": "integer",
"maximum": 9007199254740991,
"minimum": 0
},
{
"type": "null"
}
],
"title": "Budget Microusd"
},
"starts_at": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Starts At",
"description": "Custom active start, inclusive UTC ISO instant ending Z."
},
"ends_at": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Ends At",
"description": "Custom active end, exclusive UTC ISO instant ending Z. Calls remain blocked after this instant until the policy is removed."
},
"reset_interval_seconds": {
"anyOf": [
{
"type": "integer",
"maximum": 31622400,
"minimum": 60
},
{
"type": "null"
}
],
"title": "Reset Interval Seconds",
"description": "Custom bucket length anchored to starts_at; null means one fixed window. Calendar periods reject custom dates/intervals."
}
},
"additionalProperties": false,
"type": "object",
"required": [
"key_id",
"period",
"calls",
"budget_microusd"
],
"title": "KeyLimitInput"
}Ответы
| HTTP | Описание | Тип |
|---|---|---|
| 200 | Успешный ответ | application/json: KeyLimitList |
| 401 | Требуется авторизация | application/problem+json: ProblemDetails |
| 403 | Доступ запрещён | application/problem+json: ProblemDetails |
| 404 | Не найдено | application/problem+json: ProblemDetails |
| 422 | Ошибка входных данных | application/problem+json: ProblemDetails |
Ответ: KeyLimitList
| Поле | Тип | Обязательно | Описание |
|---|---|---|---|
items | KeyLimitStatus[] | да | |
timezone | string | да | |
currency | string | да | |
microusd_per_usd | integer | да |
Полная схема
{
"properties": {
"items": {
"items": {
"$ref": "#/components/schemas/KeyLimitStatus"
},
"type": "array",
"title": "Items"
},
"timezone": {
"type": "string",
"const": "UTC",
"title": "Timezone"
},
"currency": {
"type": "string",
"const": "USD",
"title": "Currency"
},
"microusd_per_usd": {
"type": "integer",
"const": 1000000,
"title": "Microusd Per Usd"
}
},
"type": "object",
"required": [
"items",
"timezone",
"currency",
"microusd_per_usd"
],
"title": "KeyLimitList"
}Эта страница генерируется из OpenAPI. Примеры показывают схемы, а не вымышленные успешные ответы.