إدارة المفاتيح (واجهة API المتقدمة)

Use your Account Permission Key to programmatically manage your personal API tokens: list and inspect tokens, create new tokens, update quota/call count/expiration/model/IP limits, toggle status, reset used quota, and delete tokens.

[!IMPORTANT]

  • Base URL: https://ai.artsmcp.com/api/open/v1
  • Auth Header (Choose One): Authorization: Bearer <your_account_key>, X-Account-Api-Key: <your_account_key>, or X-Api-Key: <your_account_key>
  • Token Identifier & Masking: Every token is addressed by its unique kid (e.g., 086421); the full plaintext token_key is returned once upon creation, while all other endpoints return a masked value (e.g., sk-9xA2****kP8Q)
  • Time & Rate Limits: Timestamps use the site operating timezone; requests exceeding rate/concurrency limits return HTTP 429

1. List Tokens

Retrieve all personal API tokens under the current account, including real-time period usage, call counts, and unavailable reasons, matching Console Token Management.

  • Path: GET /api/open/v1/tokens
  • Query Parameters:
ParameterTypeDefaultDescription
include_playground_2026integer1Include system-dedicated tokens (1 include, 0 regular tokens only)
kidstringNoneExact filter by token kid (e.g., 086421)
is_activeintegerAllFilter by status: 1 active, 0 disabled, 2 disabled with account, 3 auto-disabled after 30 days idle
keywordstringNoneFuzzy filter by token name or kid
  • Example (Curl):
curl -s "https://ai.artsmcp.com/api/open/v1/tokens?is_active=1" \
  -H "Authorization: Bearer <your_account_key>"
  • Response Example:
{
  "data": [
    {
      "team_id": 0,
      "kid": "086421",
      "name": "production-app",
      "token_key": "sk-9xA2****kP8Q",
      "quota_limit": 500.0,
      "quota_used": 12.45,
      "daily_quota_limit": 50.0,
      "daily_quota_used": 1.8,
      "current_daily_quota_used": 1.8,
      "weekly_quota_limit": -1.0,
      "weekly_quota_used": 6.2,
      "current_weekly_quota_used": 6.2,
      "monthly_quota_limit": 200.0,
      "monthly_quota_used": 12.45,
      "current_monthly_quota_used": 12.45,
      "usage_limit": 10000,
      "usage_used": 318,
      "rps_limit": 10,
      "rpm_limit": 300,
      "allowed_models": "[\"gpt-4o\",\"claude-sonnet-4-6\"]",
      "allowed_ips": "192.168.1.0/24",
      "only_playground": 0,
      "only_playground_2026": 0,
      "high_availability": 1,
      "is_active": 1,
      "unavailable_reason": null,
      "last_reset_day": "2026-11-15",
      "last_reset_week": "2026-46",
      "last_reset_month": "2026-11",
      "expires_at": "2026-12-31 23:59:59 (UTC+8)",
      "last_used_at": "2026-11-15 10:12:00 (UTC+8)",
      "created_at": "2026-11-10 16:00:00 (UTC+8)",
      "updated_at": "2026-11-15 09:30:00 (UTC+8)"
    }
  ],
  "total": 1
}
  • Response Fields:
FieldTypeDescription
dataarrayList of token objects (detail/create/update/status/reset endpoints return a single token object)
kidstringUnique token identifier (e.g., 086421), used as {kid} in single-token routes
namestringToken name
token_keystringMasked key string (full plaintext returned only once on creation)
quota_limit / quota_usednumberTotal quota limit (-1 unlimited) and cumulative quota used
daily_quota_limit / weekly_quota_limit / monthly_quota_limitnumberDaily/weekly/monthly quota limits (-1 unlimited)
current_daily_quota_used / current_weekly_quota_used / current_monthly_quota_usednumberReal-time usage in the current calendar day/week/month (auto-resets each period)
usage_limit / usage_usedintegerTotal call count limit (-1 unlimited) and cumulative calls used
rps_limit / rpm_limitintegerRequests-per-second / requests-per-minute limits (0 unlimited)
allowed_modelsstringAllowed model IDs as a JSON array string (empty string means unlimited)
allowed_ipsstringAllowed source IPs / CIDRs (comma-separated; empty string means unlimited)
high_availabilityintegerHigh-availability toggle (1 enabled, 0 disabled)
is_activeintegerToken status (1 active, 0 disabled, 2 disabled with account, 3 auto-disabled idle)
unavailable_reasonstring | nullReason if enabled but currently blocked (arrears / no_funds / expired / quota_total / quota_daily / quota_weekly / quota_monthly / quota_count), or null when usable
expires_at / last_used_at / created_at / updated_atstring | nullExpiration, last used, created, and updated timestamps in site operating timezone
totalintegerTotal matching tokens

2. Get Single Token Detail

Retrieve configuration, real-time period usage, and call counts for a single token by kid (response matches a single token object from Section 1).

  • Path: GET /api/open/v1/tokens/{kid}
  • Path Parameter: kid — Unique token identifier (e.g., 086421)
  • Example (Curl):
curl -s "https://ai.artsmcp.com/api/open/v1/tokens/086421" \
  -H "Authorization: Bearer <your_account_key>"

3. Create Token

Create a new personal API token. On success, token_key contains the full plaintext key (shown only once—store it securely).

  • Path: POST /api/open/v1/tokens
  • Request Body (JSON):
FieldTypeRequiredDescription
namestringNoToken name (defaults to default, up to 24 chars: letters, digits, spaces, _, -)
quota_limitnumber | nullNoTotal quota limit (-1, null, or omitted = unlimited)
daily_quota_limitnumber | nullNoDaily quota limit (-1 or null = unlimited)
weekly_quota_limitnumber | nullNoWeekly quota limit (-1 or null = unlimited)
monthly_quota_limitnumber | nullNoMonthly quota limit (-1 or null = unlimited)
usage_limitinteger | nullNoTotal call count limit (-1 or null = unlimited)
rps_limitinteger | nullNoRequests-per-second limit (0 or null = unlimited)
rpm_limitinteger | nullNoRequests-per-minute limit (0 or null = unlimited)
allowed_modelsstring[] | nullNoAllowed model IDs (empty or null = unlimited)
allowed_ipsstring | nullNoAllowed source IPs / CIDRs (comma-separated)
expires_atstring | nullNoAbsolute expiration (YYYY-MM-DD HH:mm:ss, YYYY-MM-DD, or ISO 8601; "" = never expires)
expire_daysintegerNoValid days from now (e.g., 30; do not combine with non-empty expires_at)
high_availabilityintegerNoHigh-availability toggle: 1 enabled (default), 0 disabled
is_activeintegerNoInitial status: 1 active (default), 0 disabled
  • Example (Curl):
curl -s -X POST "https://ai.artsmcp.com/api/open/v1/tokens" \
  -H "Authorization: Bearer <your_account_key>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "backend-worker-01",
    "quota_limit": 200.0,
    "daily_quota_limit": 25.0,
    "weekly_quota_limit": 100.0,
    "monthly_quota_limit": 200.0,
    "usage_limit": 5000,
    "rps_limit": 5,
    "rpm_limit": 120,
    "allowed_models": ["gpt-4o", "gemini-2.5-flash"],
    "allowed_ips": "203.0.113.10,10.0.0.0/8",
    "expire_days": 30,
    "is_active": 1
  }'

4. Update Token

Incrementally update an existing token (omit fields to leave them unchanged; token_key in the response remains masked).

  • Path: PUT /api/open/v1/tokens/{kid} or PATCH /api/open/v1/tokens/{kid}
  • Path Parameter: kid — Unique token identifier
  • Request Body (JSON):
FieldTypeRequiredDescription
namestringNoToken name (up to 24 chars)
quota_limitnumber | nullNoTotal quota limit; pass -1 or null to remove limit
daily_quota_limitnumber | nullNoDaily quota limit; pass -1 or null to remove limit
weekly_quota_limitnumber | nullNoWeekly quota limit; pass -1 or null to remove limit
monthly_quota_limitnumber | nullNoMonthly quota limit; pass -1 or null to remove limit
usage_limitinteger | nullNoCall count limit; pass -1 or null to remove limit
rps_limitinteger | nullNoRPS limit; pass 0 or null to remove limit
rpm_limitinteger | nullNoRPM limit; pass 0 or null to remove limit
allowed_modelsstring[]NoAllowed model IDs; pass [] to allow all models
allowed_ipsstringNoAllowed IPs / CIDRs (comma-separated); pass "" to clear
expires_atstring | nullNoAbsolute expiration; pass "", null, or "permanent" for no expiration
expire_daysintegerNoValid days from now (1..36500; do not combine with non-empty expires_at)
high_availabilityintegerNoHigh-availability toggle: 1 enabled, 0 disabled
is_activeintegerNoActive status: 1 active, 0 disabled (the only editable field on system-locked tokens)
  • Example (Curl):
curl -s -X PATCH "https://ai.artsmcp.com/api/open/v1/tokens/086421" \
  -H "Authorization: Bearer <your_account_key>" \
  -H "Content-Type: application/json" \
  -d '{
    "quota_limit": 1000.0,
    "daily_quota_limit": 80.0,
    "weekly_quota_limit": 300.0,
    "monthly_quota_limit": null,
    "usage_limit": 5000,
    "expires_at": "2027-06-30 23:59:59"
  }'

5. Toggle Token Status

Quickly enable or disable a token without sending a full configuration payload.

  • Path: PATCH /api/open/v1/tokens/{kid}/status or POST /api/open/v1/tokens/{kid}/status
  • Path Parameter: kid — Unique token identifier
  • Request Body (JSON):
FieldTypeRequiredDescription
is_activeintegerNo1 enable, 0 disable (provide either is_active or enabled)
enabledbooleanNotrue enable, false disable (provide either is_active or enabled)
  • Example (Curl):
curl -s -X PATCH "https://ai.artsmcp.com/api/open/v1/tokens/086421/status" \
  -H "Authorization: Bearer <your_account_key>" \
  -H "Content-Type: application/json" \
  -d '{"is_active": 0}'

6. Reset Token Usage

Reset the token's used quota or call count counters along the specified scope (does not affect actual wallet billing records).

  • Path: POST /api/open/v1/tokens/{kid}/reset-usage
  • Path Parameter: kid — Unique token identifier
  • Request Body (JSON):
FieldTypeRequiredDescription
targetstringNoScope to reset: all (default), total, daily, weekly, monthly, usage_count (also accepted as a query parameter)
  • Example (Curl):
curl -s -X POST "https://ai.artsmcp.com/api/open/v1/tokens/086421/reset-usage" \
  -H "Authorization: Bearer <your_account_key>" \
  -H "Content-Type: application/json" \
  -d '{"target": "daily"}'

7. Delete Token

Permanently delete a personal API token (immediately invalidated and irreversible; system-locked tokens cannot be deleted).

  • Path: DELETE /api/open/v1/tokens/{kid}
  • Path Parameter: kid — Unique token identifier
  • Example (Curl):
curl -s -X DELETE "https://ai.artsmcp.com/api/open/v1/tokens/086421" \
  -H "Authorization: Bearer <your_account_key>"
  • Response Example:
{
  "success": true,
  "kid": "086421",
  "message": "Token deleted successfully"
}
  • Response Fields:
FieldTypeDescription
successbooleanWhether deletion succeeded
kidstringIdentifier of the deleted token
messagestringResult message

Raw Markdown (.md) · llms.txt