curl -X GET "https://api.apitraffic.io/v1/accounts/acc_abc123def456ghi789jkl012/apiTokens" \
  -H "Authorization: Bearer your-jwt-token"
{
  "hasMore": false,
  "records": [
    {
      "sid": "tok_abc123def456ghi789jkl012",
      "accountSid": "acc_abc123def456ghi789jkl012",
      "name": "Production API Token",
      "description": "Token for production monitoring integration",
      "scopes": ["buckets:read", "requests:read", "metrics:read"],
      "lastUsedAt": "2023-12-01T14:30:00.000Z",
      "expiresAt": "2024-12-01T00:00:00.000Z",
      "isActive": true,
      "createdAt": "2023-12-01T10:30:00.000Z"
    },
    {
      "sid": "tok_xyz789uvw012rst345abc",
      "accountSid": "acc_abc123def456ghi789jkl012",
      "name": "CI/CD Token",
      "description": "Token for automated testing and deployment",
      "scopes": ["buckets:read", "buckets:write"],
      "lastUsedAt": null,
      "expiresAt": null,
      "isActive": true,
      "createdAt": "2023-11-15T09:15:00.000Z"
    }
  ]
}

List API Tokens

Retrieve all API tokens associated with an account.

Path Parameters

accountSid
string
required
Account identifier (format: acc_ followed by 27 alphanumeric characters)

Headers

Authorization
string
required
Bearer token for authentication

Response

hasMore
boolean
Indicates if there are more records to paginate through
records
array
curl -X GET "https://api.apitraffic.io/v1/accounts/acc_abc123def456ghi789jkl012/apiTokens" \
  -H "Authorization: Bearer your-jwt-token"
{
  "hasMore": false,
  "records": [
    {
      "sid": "tok_abc123def456ghi789jkl012",
      "accountSid": "acc_abc123def456ghi789jkl012",
      "name": "Production API Token",
      "description": "Token for production monitoring integration",
      "scopes": ["buckets:read", "requests:read", "metrics:read"],
      "lastUsedAt": "2023-12-01T14:30:00.000Z",
      "expiresAt": "2024-12-01T00:00:00.000Z",
      "isActive": true,
      "createdAt": "2023-12-01T10:30:00.000Z"
    },
    {
      "sid": "tok_xyz789uvw012rst345abc",
      "accountSid": "acc_abc123def456ghi789jkl012",
      "name": "CI/CD Token",
      "description": "Token for automated testing and deployment",
      "scopes": ["buckets:read", "buckets:write"],
      "lastUsedAt": null,
      "expiresAt": null,
      "isActive": true,
      "createdAt": "2023-11-15T09:15:00.000Z"
    }
  ]
}

Get API Token

Retrieve details of a specific API token.

Path Parameters

accountSid
string
required
Account identifier
apiTokenSid
string
required
API token identifier

Headers

Authorization
string
required
Bearer token for authentication

Response

Returns a single API token object with the same structure as described in the List API Tokens response.
curl -X GET "https://api.apitraffic.io/v1/accounts/acc_abc123def456ghi789jkl012/apiTokens/tok_abc123def456ghi789jkl012" \
  -H "Authorization: Bearer your-jwt-token"
{
  "sid": "tok_abc123def456ghi789jkl012",
  "accountSid": "acc_abc123def456ghi789jkl012",
  "name": "Production API Token",
  "description": "Token for production monitoring integration",
  "scopes": ["buckets:read", "requests:read", "metrics:read"],
  "lastUsedAt": "2023-12-01T14:30:00.000Z",
  "expiresAt": "2024-12-01T00:00:00.000Z",
  "isActive": true,
  "createdAt": "2023-12-01T10:30:00.000Z"
}

Create API Token

Create a new API token for programmatic access.

Path Parameters

accountSid
string
required
Account identifier

Headers

Authorization
string
required
Bearer token for authentication

Request Body

name
string
required
Name of the API token
description
string
Description of the token’s purpose
scopes
array
required
Array of permission scopes to grant to this token
expiresAt
string
ISO 8601 timestamp when token should expire (optional, null for no expiration)

Response

sid
string
Unique API token identifier
token
string
The actual API token value (only returned on creation)
accountSid
string
Account identifier
name
string
Name of the API token
description
string
Description of the token
scopes
array
Array of granted permission scopes
expiresAt
string
Expiration timestamp (nullable)
isActive
boolean
Whether the token is active
createdAt
string
ISO 8601 timestamp of creation
The token value is only returned once during creation. Store it securely as it cannot be retrieved again.
curl -X POST "https://api.apitraffic.io/v1/accounts/acc_abc123def456ghi789jkl012/apiTokens" \
  -H "Authorization: Bearer your-jwt-token" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Analytics Token",
    "description": "Token for analytics dashboard integration",
    "scopes": ["metrics:read", "buckets:read"],
    "expiresAt": "2024-12-31T23:59:59.000Z"
  }'
{
  "sid": "tok_new789uvw012rst345def",
  "token": "at_live_1234567890abcdef...",
  "accountSid": "acc_abc123def456ghi789jkl012",
  "name": "Analytics Token",
  "description": "Token for analytics dashboard integration",
  "scopes": ["metrics:read", "buckets:read"],
  "expiresAt": "2024-12-31T23:59:59.000Z",
  "isActive": true,
  "createdAt": "2023-12-01T15:45:00.000Z"
}

Update API Token

Update an existing API token’s metadata.
You cannot update the token value itself or its scopes. To change scopes, create a new token and delete the old one.

Path Parameters

accountSid
string
required
Account identifier
apiTokenSid
string
required
API token identifier

Headers

Authorization
string
required
Bearer token for authentication

Request Body

name
string
required
Name of the API token
description
string
Description of the token’s purpose
isActive
boolean
required
Whether this token should be active

Response

Returns the updated API token object (without the token value).
curl -X PUT "https://api.apitraffic.io/v1/accounts/acc_abc123def456ghi789jkl012/apiTokens/tok_abc123def456ghi789jkl012" \
  -H "Authorization: Bearer your-jwt-token" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Updated Production Token",
    "description": "Updated description for production monitoring",
    "isActive": false
  }'
{
  "sid": "tok_abc123def456ghi789jkl012",
  "accountSid": "acc_abc123def456ghi789jkl012",
  "name": "Updated Production Token",
  "description": "Updated description for production monitoring",
  "scopes": ["buckets:read", "requests:read", "metrics:read"],
  "lastUsedAt": "2023-12-01T14:30:00.000Z",
  "expiresAt": "2024-12-01T00:00:00.000Z",
  "isActive": false,
  "createdAt": "2023-12-01T10:30:00.000Z"
}

Delete API Token

Delete an API token, immediately revoking access.
This action is irreversible. Any applications using this token will immediately lose access.

Path Parameters

accountSid
string
required
Account identifier
apiTokenSid
string
required
API token identifier

Headers

Authorization
string
required
Bearer token for authentication

Response

sid
string
ID of the deleted API token
deleted
boolean
Flag indicating the token was successfully deleted
curl -X DELETE "https://api.apitraffic.io/v1/accounts/acc_abc123def456ghi789jkl012/apiTokens/tok_abc123def456ghi789jkl012" \
  -H "Authorization: Bearer your-jwt-token"
{
  "sid": "tok_abc123def456ghi789jkl012",
  "deleted": true
}

Available Scopes

API tokens can be granted specific scopes to limit their access:

Bucket Scopes

  • buckets:read - View bucket information
  • buckets:write - Create and modify buckets
  • buckets:delete - Delete buckets

Request Scopes

  • requests:read - View request data
  • requests:write - Modify request metadata (notes, etc.)
  • requests:delete - Delete individual requests

Metrics Scopes

  • metrics:read - Access analytics and metrics data

Redaction Scopes

  • redactions:read - View redaction rules
  • redactions:write - Create and modify redaction rules
  • redactions:delete - Delete redaction rules

Exclusion Scopes

  • exclusions:read - View exclusion rules
  • exclusions:write - Create and modify exclusion rules
  • exclusions:delete - Delete exclusion rules

Workflow Scopes

  • workflows:read - View workflow configurations
  • workflows:write - Create and modify workflows
  • workflows:delete - Delete workflows

Token Management Scopes

  • tokens:read - View API token information
  • tokens:write - Create and modify API tokens
  • tokens:delete - Delete API tokens

Using API Tokens

Once created, use your API token in the Authorization header:
curl -H "Authorization: Bearer at_live_1234567890abcdef..." \
  https://api.apitraffic.io/v1/accounts/acc_abc123def456ghi789jkl012/buckets

Token Format

  • Live tokens: at_live_ followed by random characters
  • Test tokens: at_test_ followed by random characters

Best Practices

  1. Principle of Least Privilege: Only grant the minimum scopes required
  2. Regular Rotation: Rotate tokens periodically for security
  3. Secure Storage: Store tokens securely, never in plain text
  4. Monitor Usage: Check lastUsedAt to identify unused tokens
  5. Set Expiration: Use expiration dates for temporary access
  6. Environment Separation: Use different tokens for different environments