Skip to content

Set an overall limit

POSThttps://gptunnel.ru/api/v1/access/setGlobalLimit

Set a daily or monthly spending limit, or both, for each employee across all models. This limit takes priority over per-model limits. If the same login appears more than once in items, only the first entry for that login is applied.

Request parameters

ParameterTypeDescription
items*object[]Array of 1–25 items. Each item contains an employee login and limits: { login, dailyLimit?, monthlyLimit? }
items[].login*stringEmployee login
items[].dailyLimitnumberTotal daily limit in whole rubles (RUB), fractional value returns 400. 0 = no limit
items[].monthlyLimitnumberTotal monthly limit in whole rubles (RUB), fractional value returns 400. 0 = no limit

Supply at least one of dailyLimit and monthlyLimit. Only the fields you supply are updated.

The API checks the key creator’s current role:

  • The creator must be an owner, admin, or manager. Otherwise the entire request returns HTTP 403.
  • Owners and admins can update other employees whose role is equal to or below their own. Trying to update their own account or someone with a higher role returns forbidden for that login.
  • Managers can update only members of their own teams. They can set or lower a limit. Raising or removing it returns forbidden for that login.

Request headers

ParameterTypeDescription
Authorization*stringAPI key

The response counts successful updates in updated and failures in failed. Each entry in failedLogins identifies the login and explains the error.

Error reasons in failedLogins:

Error reasons

ParameterTypeDescription
not_foundstringNo employee in the organization has this login
forbiddenstringThe employee has a higher role or is the key creator. For a manager, the employee is not a member of their teams or the change weakens the organization’s restrictions.
errorstringAn unexpected error occurred while processing this employee

Set GPTUNNEL_API_KEY and replace the placeholders with values for your organization.

import json
import os
from urllib.request import Request, urlopen
key = os.environ.get("GPTUNNEL_API_KEY")
if not key:
raise SystemExit("Set GPTUNNEL_API_KEY")
body = {
"items": [
{
"login": "ivanov",
"dailyLimit": 1000,
"monthlyLimit": 20000
},
{
"login": "petrov",
"monthlyLimit": 5000
}
]
}
request = Request(
"https://gptunnel.ru/api/v1/access/setGlobalLimit",
method="POST",
headers={
"Authorization": key,
"Content-Type": "application/json",
},
data=json.dumps(body).encode("utf-8"),
)
with urlopen(request, timeout=30) as response:
print(json.load(response))
{
"code": 0,
"updated": 2,
"failed": 0,
"failedLogins": []
}