> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apitraffic.io/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP Tokens

> Manage MCP tokens for AI assistant access to your ApiTraffic data

## List MCP Tokens

<api-endpoint method="GET" url="https://api.apitraffic.io/v1/accounts/{accountSid}/mcpTokens" />

Retrieve all MCP tokens associated with an account.

### Path Parameters

<ParamField path="accountSid" type="string" required>
  Account identifier (format: `acc_` followed by 27 alphanumeric characters)
</ParamField>

### Headers

<ParamField header="Authorization" type="string" required>
  Bearer token for authentication
</ParamField>

### Response

<ResponseField name="hasMore" type="boolean">
  Indicates if there are more records to paginate through
</ResponseField>

<ResponseField name="records" type="array">
  <Expandable title="MCP Token Objects">
    <ResponseField name="sid" type="string">
      Unique MCP token identifier (format: `mcp_` prefix)
    </ResponseField>

    <ResponseField name="accountSid" type="string">
      Account identifier this token belongs to
    </ResponseField>

    <ResponseField name="environmentSid" type="string">
      Environment this token is scoped to
    </ResponseField>

    <ResponseField name="bucketSids" type="array">
      Array of bucket SIDs this token can access. Empty array means all buckets in the environment.
    </ResponseField>

    <ResponseField name="name" type="string">
      Name of the MCP token
    </ResponseField>

    <ResponseField name="token" type="string">
      Masked token value (full value only shown on creation)
    </ResponseField>

    <ResponseField name="isRevoked" type="boolean">
      Whether this token has been revoked
    </ResponseField>

    <ResponseField name="lastUsedAt" type="string">
      ISO 8601 timestamp of last token usage (nullable)
    </ResponseField>

    <ResponseField name="createdAt" type="string">
      ISO 8601 timestamp of token creation
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X GET "https://api.apitraffic.io/v1/accounts/acc_abc123def456ghi789jkl012/mcpTokens" \
    -H "Authorization: Bearer your-jwt-token"
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://api.apitraffic.io/v1/accounts/acc_abc123def456ghi789jkl012/mcpTokens', {
    headers: {
      'Authorization': 'Bearer your-jwt-token'
    }
  });

  const tokens = await response.json();
  console.log(tokens);
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "hasMore": false,
    "records": [
      {
        "sid": "mcp_abc123def456ghi789jkl012",
        "accountSid": "acc_abc123def456ghi789jkl012",
        "environmentSid": "prod01",
        "bucketSids": [],
        "name": "Claude Desktop - Production",
        "token": "mcp_2abc1*******ef789",
        "isRevoked": false,
        "lastUsedAt": "2025-03-15T14:30:00.000Z",
        "createdAt": "2025-03-15T10:30:00.000Z",
        "updatedAt": "2025-03-15T10:30:00.000Z",
        "revokedAt": null
      }
    ]
  }
  ```
</ResponseExample>

***

## Create MCP Token

<api-endpoint method="POST" url="https://api.apitraffic.io/v1/accounts/{accountSid}/mcpTokens" />

Create a new MCP token for AI assistant access. MCP tokens are read-only and scoped to a specific environment and set of buckets.

### Path Parameters

<ParamField path="accountSid" type="string" required>
  Account identifier
</ParamField>

### Headers

<ParamField header="Authorization" type="string" required>
  Bearer token for authentication
</ParamField>

### Request Body

<ParamField body="name" type="string" required>
  A descriptive name for the MCP token (e.g. "Claude Desktop - Production")
</ParamField>

<ParamField body="environmentSid" type="string" required>
  The environment SID this token should be scoped to
</ParamField>

<ParamField body="bucketSids" type="array">
  Array of bucket SIDs to restrict access to. Leave empty or omit to grant access to all buckets in the environment.
</ParamField>

### Response

Returns the created MCP token with the **full token value** (only shown once).

<Warning>
  The token value is only returned once during creation. Store it securely as it cannot be retrieved again.
</Warning>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.apitraffic.io/v1/accounts/acc_abc123def456ghi789jkl012/mcpTokens" \
    -H "Authorization: Bearer your-jwt-token" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Claude Desktop - Production",
      "environmentSid": "prod01",
      "bucketSids": []
    }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://api.apitraffic.io/v1/accounts/acc_abc123def456ghi789jkl012/mcpTokens', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer your-jwt-token',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      name: 'Claude Desktop - Production',
      environmentSid: 'prod01',
      bucketSids: []
    })
  });

  const token = await response.json();
  console.log(token);
  // Store token.token securely!
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "sid": "mcp_abc123def456ghi789jkl012",
    "accountSid": "acc_abc123def456ghi789jkl012",
    "environmentSid": "prod01",
    "bucketSids": [],
    "name": "Claude Desktop - Production",
    "token": "mcp_2abc1d3e4f5g6h7i8j9k0l1m2n3o4p5q6r7s8t9u0v1w2x3y4z",
    "isRevoked": false,
    "lastUsedAt": null,
    "createdAt": "2025-03-15T10:30:00.000Z",
    "updatedAt": "2025-03-15T10:30:00.000Z",
    "revokedAt": null
  }
  ```
</ResponseExample>

***

## Update MCP Token

<api-endpoint method="PUT" url="https://api.apitraffic.io/v1/accounts/{accountSid}/mcpTokens/{mcpTokenSid}" />

Update an existing MCP token's name or bucket scope.

### Path Parameters

<ParamField path="accountSid" type="string" required>
  Account identifier
</ParamField>

<ParamField path="mcpTokenSid" type="string" required>
  MCP token identifier
</ParamField>

### Headers

<ParamField header="Authorization" type="string" required>
  Bearer token for authentication
</ParamField>

### Request Body

<ParamField body="name" type="string">
  Updated name for the token
</ParamField>

<ParamField body="bucketSids" type="array">
  Updated array of bucket SIDs (empty = all buckets in environment)
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X PUT "https://api.apitraffic.io/v1/accounts/acc_abc123def456ghi789jkl012/mcpTokens/mcp_abc123def456ghi789jkl012" \
    -H "Authorization: Bearer your-jwt-token" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Claude Desktop - Staging",
      "bucketSids": ["abc1234", "def5678"]
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "sid": "mcp_abc123def456ghi789jkl012",
    "accountSid": "acc_abc123def456ghi789jkl012",
    "environmentSid": "prod01",
    "bucketSids": ["abc1234", "def5678"],
    "name": "Claude Desktop - Staging",
    "token": "mcp_2abc1*******ef789",
    "isRevoked": false,
    "lastUsedAt": "2025-03-15T14:30:00.000Z",
    "createdAt": "2025-03-15T10:30:00.000Z",
    "updatedAt": "2025-03-15T15:00:00.000Z",
    "revokedAt": null
  }
  ```
</ResponseExample>

***

## Revoke MCP Token

<api-endpoint method="DELETE" url="https://api.apitraffic.io/v1/accounts/{accountSid}/mcpTokens/{mcpTokenSid}" />

Revoke an MCP token, immediately terminating access for any AI assistants using it.

<Warning>
  This action is immediate. Any AI assistants using this token will lose access instantly.
</Warning>

### Path Parameters

<ParamField path="accountSid" type="string" required>
  Account identifier
</ParamField>

<ParamField path="mcpTokenSid" type="string" required>
  MCP token identifier
</ParamField>

### Headers

<ParamField header="Authorization" type="string" required>
  Bearer token for authentication
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X DELETE "https://api.apitraffic.io/v1/accounts/acc_abc123def456ghi789jkl012/mcpTokens/mcp_abc123def456ghi789jkl012" \
    -H "Authorization: Bearer your-jwt-token"
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://api.apitraffic.io/v1/accounts/acc_abc123def456ghi789jkl012/mcpTokens/mcp_abc123def456ghi789jkl012', {
    method: 'DELETE',
    headers: {
      'Authorization': 'Bearer your-jwt-token'
    }
  });

  const result = await response.json();
  console.log(result);
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "sid": "mcp_abc123def456ghi789jkl012",
    "deleted": true
  }
  ```
</ResponseExample>
