Skip to main content
PUT
/
api
/
token
Update Token
curl --request PUT \
  --url https://api.example.com/api/token/ \
  --header 'Content-Type: application/json' \
  --data '
{
  "id": 123,
  "name": "<string>",
  "remain_quota": 123,
  "unlimited_quota": true,
  "expired_time": 123,
  "model_limits_enabled": true,
  "model_limits": "<string>",
  "status": 123,
  "allow_ips": "<string>",
  "group": "<string>"
}
'

Overview

Modify the name, quota, expiration time, model permissions, and other settings of an existing token.
The /api/token/* endpoints are mainly for Crazyrouter dashboard automation around API key management. They require a user access token plus the New-Api-User header, and are not the normal interface for sk-xxx model calls.

Authentication

Use user-side authentication with these headers:
Authorization: Bearer your_access_token
New-Api-User: 1

Request Parameters

id
integer
required
Token ID
name
string
Token name
remain_quota
integer
Remaining quota
unlimited_quota
boolean
Whether quota is unlimited
expired_time
integer
Expiration timestamp, -1 means never expires
model_limits_enabled
boolean
Whether to enable the model whitelist
model_limits
string
Model restriction config string, for example ["gpt-5.4","claude-sonnet-4-6"]
status
integer
Status: 1=enabled, 2=disabled
allow_ips
string
IP whitelist string
group
string
Group

Response Format

The current endpoint returns the updated token object:
{
  "success": true,
  "message": "",
  "data": {
    "id": 10,
    "name": "Production-Updated",
    "status": 1,
    "remain_quota": 200000,
    "unlimited_quota": false,
    "model_limits_enabled": true,
    "model_limits": "[\"gpt-5.4\",\"claude-sonnet-4-6\"]",
    "allow_ips": "203.0.113.10",
    "group": "default"
  }
}

Code Examples

import json
import requests

headers = {
    "Authorization": "Bearer your_access_token",
    "New-Api-User": "1",
    "Content-Type": "application/json",
    "User-Agent": "Mozilla/5.0"
}

response = requests.put(
    "https://crazyrouter.com/api/token/",
    headers=headers,
    json={
        "id": 10,
        "name": "Production-Updated",
        "remain_quota": 200000,
        "model_limits_enabled": True,
        "model_limits": json.dumps(["gpt-5.4", "claude-sonnet-4-6"])
    }
)

print(response.json())
Updating a token does not regenerate the API key. If you need a new key, delete the token and create a new one.