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

# Get Token

> Get a specific token by ID

# Get Token

Retrieves a specific design token by its unique identifier within a mode.

## Endpoint

```
GET /tokensets/{id}/modes/{modeId}/tokens/{tokenId}
```

## Request

### Path Parameters

| Parameter | Type   | Required | Description                                    |
| --------- | ------ | -------- | ---------------------------------------------- |
| `id`      | string | Yes      | Tokenset ID                                    |
| `modeId`  | string | Yes      | Mode ID                                        |
| `tokenId` | string | Yes      | Token ID returned by the list tokens endpoints |

<Note>
  To look up a `tokenId`, call [List Tokens](/api-reference/tokens/list) or [Get Tokenset Tokens](/api-reference/tokensets/tokens) and use the `id` field from the response.
</Note>

## Response

**Status:** `200 OK`

```json theme={null}
{
  "id": "token-1",
  "tokenset_id": "tokenset-123",
  "mode_id": "mode-light",
  "name": "colors.primary.500",
  "type": "color",
  "value": "#3b82f6",
  "description": "Primary brand color",
  "alias_to": null,
  "resolved_value": "#3b82f6",
  "created_at": "2025-01-15T10:00:00Z",
  "updated_at": "2025-01-15T10:00:00Z"
}
```

### Special Fields

| Field            | Description                                                  |
| ---------------- | ------------------------------------------------------------ |
| `resolved_value` | If token is an alias, this contains the final resolved value |
| `alias_to`       | If set, this token references another token                  |

## Token with Alias

```json theme={null}
{
  "name": "colors.button.primary",
  "type": "color",
  "value": null,
  "alias_to": "colors.primary.500",
  "resolved_value": "#3b82f6"
}
```

## Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -H "Authorization: Bearer tkc_your_token_here" \
    "https://app.tokencraft.dev/api/v1/tokensets/tokenset-123/modes/mode-light/tokens/token-1"
  ```

  ```javascript JavaScript theme={null}
  const tokensetId = 'tokenset-123';
  const modeId = 'mode-light';
  const tokenId = 'token-1';

  const response = await fetch(
    `https://app.tokencraft.dev/api/v1/tokensets/${tokensetId}/modes/${modeId}/tokens/${tokenId}`,
    {
      headers: {
        'Authorization': `Bearer ${process.env.TOKENCRAFT_TOKEN}`
      }
    }
  );

  const token = await response.json();
  console.log(`${token.name}: ${token.resolved_value || token.value}`);
  ```

  ```python Python theme={null}
  import requests

  tokenset_id = 'tokenset-123'
  mode_id = 'mode-light'
  token_id = 'token-1'

  response = requests.get(
      f'https://app.tokencraft.dev/api/v1/tokensets/{tokenset_id}/modes/{mode_id}/tokens/{token_id}',
      headers={'Authorization': f'Bearer {token}'}
  )

  token = response.json()
  print(f"{token['name']}: {token.get('resolved_value', token['value'])}")
  ```
</CodeGroup>

## Error Responses

### 404 Not Found

```json theme={null}
{
  "error": "Token not found"
}
```

**Causes:**

* Token ID doesn't exist in this mode
* Token was deleted
* Token belongs to a different tokenset or mode

## Use Cases

### 1. Token Details View

Show full token information:

```javascript theme={null}
async function TokenDetails({ tokensetId, modeId, tokenId }) {
  const token = await getToken(tokensetId, modeId, tokenId);
  
  return (
    <div>
      <h2>{token.name}</h2>
      <p>Type: {token.type}</p>
      <p>Value: {token.resolved_value || token.value}</p>
      {token.description && <p>{token.description}</p>}
      {token.alias_to && <p>References: {token.alias_to}</p>}
    </div>
  );
}
```

### 2. Token Validation

Check if token exists:

```javascript theme={null}
async function tokenExists(tokensetId, modeId, tokenId) {
  try {
    await getToken(tokensetId, modeId, tokenId);
    return true;
  } catch (error) {
    if (error.status === 404) return false;
    throw error;
  }
}
```

### 3. Resolve Alias Chain

Follow alias references:

```javascript theme={null}
async function resolveToken(tokensetId, modeId, tokenId) {
  const token = await getToken(tokensetId, modeId, tokenId);
  return token.resolved_value || token.value;
}
```

## Next Steps

<CardGroup cols={2}>
  <Card title="List All Tokens" icon="list" href="/api-reference/tokens/list">
    Get all tokens in a mode
  </Card>

  <Card title="Export Tokens" icon="file-export" href="/api-reference/export/mode">
    Export in multiple formats
  </Card>
</CardGroup>
