DocsRouterDocsRouter
Api

Management API

Manage API keys and retrieve usage data

Management API

These endpoints allow you to programmatically manage your API keys and retrieve usage statistics. All management endpoints require authentication.

Authentication

All management API requests require authentication via the Authorization header:

Authorization: Bearer YOUR_API_KEY

Management endpoints require an API key with admin permissions. Keys created via the API have limited permissions by default.

API Keys

List API Keys

Retrieve all API keys associated with your account.

Endpoint: GET https://api.docsrouter.com/v1/api-keys

Headers:

Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Response:

{
  "object": "list",
  "data": [
    {
      "id": "apk_...",
      "name": "Production Key",
      "prefix": "dr_sk_live_a...",
      "created_at": 1716300000,
      "last_used_at": 1716400000
    }
  ]
}

Create API Key

Create a new API key for your account.

Endpoint: POST https://api.docsrouter.com/v1/api-keys

Headers:

Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Request Body:

FieldTypeRequiredDescription
namestringYesA descriptive name for the key
permissionsarrayNoList of permissions (default: all)
expires_atnumberNoUnix timestamp for expiration (optional)
{
  "name": "Production API Key",
  "permissions": ["chat:write", "models:read"],
  "expires_at": 1735689600
}

Response:

The full API key is only returned once. Store it securely immediately after creation.

{
  "id": "apk_abc123",
  "name": "Production API Key",
  "key": "dr_sk_live_abc123xyz789...",
  "prefix": "dr_sk_live_abc...",
  "permissions": ["chat:write", "models:read"],
  "created_at": 1716300000,
  "expires_at": 1735689600
}

Revoke API Key

Immediately revoke an API key. This action cannot be undone.

Endpoint: DELETE https://api.docsrouter.com/v1/api-keys/:id

Headers:

Authorization: Bearer YOUR_API_KEY

Path Parameters:

ParameterDescription
idThe API key ID (e.g., apk_abc123)

Example:

curl -X DELETE https://api.docsrouter.com/v1/api-keys/apk_abc123 \
  -H "Authorization: Bearer YOUR_API_KEY"

Response:

{
  "id": "apk_abc123",
  "deleted": true
}

Update API Key

Update an existing API key's name or permissions.

Endpoint: PATCH https://api.docsrouter.com/v1/api-keys/:id

Headers:

Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Request Body:

{
  "name": "Updated Key Name"
}

Response:

{
  "id": "apk_abc123",
  "name": "Updated Key Name",
  "prefix": "dr_sk_live_abc...",
  "updated_at": 1716400000
}

Usage Analytics

Get Usage Logs

Retrieve detailed logs of every API request made with your keys.

Endpoint: GET https://api.docsrouter.com/v1/usage

Headers:

Authorization: Bearer YOUR_API_KEY

Query Parameters:

ParameterTypeDefaultDescription
start_datenumber7 days agoUnix timestamp for start of range
end_datenumbernowUnix timestamp for end of range
limitnumber50Number of logs to return (max 100)
offsetnumber0Pagination offset
statusstringallFilter by success or error
modelstringallFilter by model ID
api_key_idstringallFilter by specific API key

Example:

curl "https://api.docsrouter.com/v1/usage?limit=10&status=success" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response:

{
  "object": "list",
  "data": [
    {
      "id": "req_abc123",
      "created_at": 1716400000,
      "model": "google/gemini-2.0-flash-001",
      "status": "success",
      "tokens_used": 1250,
      "cost_cents": 1.5,
      "processing_time_ms": 1850,
      "api_key_id": "apk_xyz789"
    }
  ],
  "has_more": true,
  "total_count": 150
}

Get Usage Summary

Get aggregated usage statistics for a time period.

Endpoint: GET https://api.docsrouter.com/v1/usage/summary

Headers:

Authorization: Bearer YOUR_API_KEY

Query Parameters:

ParameterTypeDefaultDescription
start_datenumber30 days agoUnix timestamp for start of range
end_datenumbernowUnix timestamp for end of range
group_bystringnoneGroup by day, week, month, or model

Example:

curl "https://api.docsrouter.com/v1/usage/summary?group_by=day" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response:

{
  "total_requests": 150,
  "successful_requests": 148,
  "failed_requests": 2,
  "total_tokens_used": 250000,
  "total_pages_processed": 320,
  "cost": {
    "provider_cost_cents": 125,
    "platform_fee_cents": 42,
    "total_cents": 167,
    "total_usd": 1.67,
    "formatted": "$1.67"
  },
  "by_model": {
    "google/gemini-2.0-flash-001": {
      "requests": 120,
      "tokens": 180000,
      "cost_cents": 100
    },
    "openai/gpt-4o": {
      "requests": 30,
      "tokens": 70000,
      "cost_cents": 67
    }
  },
  "period": {
    "start": 1713708000,
    "end": 1716300000
  }
}

Account Information

Get Account Balance

Retrieve your current account balance and credit information.

Endpoint: GET https://api.docsrouter.com/v1/account/balance

Headers:

Authorization: Bearer YOUR_API_KEY

Response:

{
  "balance_cents": 5000,
  "balance_usd": 50.00,
  "formatted": "$50.00",
  "currency": "USD",
  "auto_recharge": {
    "enabled": true,
    "threshold_cents": 1000,
    "amount_cents": 5000
  }
}

Get Account Details

Retrieve account information and settings.

Endpoint: GET https://api.docsrouter.com/v1/account

Headers:

Authorization: Bearer YOUR_API_KEY

Response:

{
  "id": "acc_abc123",
  "email": "[email protected]",
  "name": "Acme Corp",
  "plan": "pro",
  "created_at": 1710000000,
  "rate_limits": {
    "requests_per_minute": 300,
    "requests_per_day": 10000
  }
}

On this page