> ## 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.

# List Workspace Tokensets

> Get all tokensets in a workspace

# List Workspace Tokensets

Retrieves all tokensets within a specific workspace.

Access follows workspace membership rules:

* TEAM-owned workspace: all members can read.
* Non-TEAM workspace: owner-only read.

## Endpoint

```
GET /workspaces/{id}/tokensets
```

## Authentication

Requires a valid API token in the Authorization header.

## Request

### Headers

| Header          | Value        | Required |
| --------------- | ------------ | -------- |
| `Authorization` | Bearer token | Yes      |

### Path Parameters

| Parameter | Type   | Required | Description  |
| --------- | ------ | -------- | ------------ |
| `id`      | string | Yes      | Workspace ID |

## Response

### Success Response

**Status:** `200 OK`

```json theme={null}
{
  "tokensets": [
    {
      "id": "tokenset-123",
      "workspace_id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "Colors",
      "description": "Color tokens for the design system",
      "created_at": "2025-01-15T10:00:00Z",
      "updated_at": "2025-01-15T10:00:00Z"
    },
    {
      "id": "tokenset-456",
      "workspace_id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "Typography",
      "description": "Font and text tokens",
      "created_at": "2025-01-15T10:05:00Z",
      "updated_at": "2025-01-16T14:30:00Z"
    }
  ],
  "total": 2
}
```

### Response Fields

| Field       | Type   | Description               |
| ----------- | ------ | ------------------------- |
| `tokensets` | array  | Array of tokenset objects |
| `total`     | number | Total number of tokensets |

### Tokenset Object

| Field          | Type         | Description                |
| -------------- | ------------ | -------------------------- |
| `id`           | string       | Unique tokenset identifier |
| `workspace_id` | string       | Parent workspace ID        |
| `name`         | string       | Tokenset name              |
| `description`  | string\|null | Optional description       |
| `created_at`   | string       | ISO 8601 timestamp         |
| `updated_at`   | string       | ISO 8601 timestamp         |

## Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -H "Authorization: Bearer tkc_your_token_here" \
    https://app.tokencraft.dev/api/v1/workspaces/550e8400-e29b-41d4-a716-446655440000/tokensets
  ```

  ```javascript JavaScript theme={null}
  const workspaceId = '550e8400-e29b-41d4-a716-446655440000';
  const token = 'tkc_your_token_here';

  const response = await fetch(
    `https://app.tokencraft.dev/api/v1/workspaces/${workspaceId}/tokensets`,
    {
      headers: {
        'Authorization': `Bearer ${token}`
      }
    }
  );

  const data = await response.json();
  console.log(data.tokensets);
  ```

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

  workspace_id = '550e8400-e29b-41d4-a716-446655440000'
  token = 'tkc_your_token_here'

  response = requests.get(
      f'https://app.tokencraft.dev/api/v1/workspaces/{workspace_id}/tokensets',
      headers={'Authorization': f'Bearer {token}'}
  )

  data = response.json()
  print(data['tokensets'])
  ```
</CodeGroup>

## Error Responses

### 401 Unauthorized

```json theme={null}
{
  "error": "Invalid API token"
}
```

### 404 Not Found

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

### 500 Internal Server Error

```json theme={null}
{
  "error": "Internal server error"
}
```

## Use Cases

### 1. Build Navigation

Create a navigation menu:

```javascript theme={null}
async function buildTokensetsNav(workspaceId) {
  const { tokensets } = await getWorkspaceTokensets(workspaceId);
  
  return tokensets.map(ts => ({
    label: ts.name,
    href: `/tokensets/${ts.id}`,
    icon: getIconForTokenset(ts.name)
  }));
}
```

### 2. Export All Tokensets

Download all tokensets in a workspace:

```javascript theme={null}
async function exportWorkspace(workspaceId) {
  const { tokensets } = await getWorkspaceTokensets(workspaceId);
  
  for (const tokenset of tokensets) {
    const tokens = await exportTokenset(tokenset.id);
    saveToFile(`${tokenset.name}.json`, tokens);
  }
}
```

### 3. Analytics

Track tokenset count:

```javascript theme={null}
const { total } = await getWorkspaceTokensets(workspaceId);
console.log(`Workspace has ${total} tokensets`);
```

## Next Steps

<CardGroup cols={2}>
  <Card title="Get Tokenset" icon="layer-group" href="/api-reference/tokensets/get">
    Get details of a specific tokenset
  </Card>

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