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

# Update Tokenset

> Update tokenset details

# Update Tokenset

Updates an existing tokenset. Only provided fields will be updated.

<Note>
  **Write access policy** - This endpoint requires the `write:tokens` scope.

  * TEAM-owned workspace: `owner`, `admin`, `editor` can write; `viewer` is blocked (`403`).
  * Non-TEAM workspace: only the workspace owner can write.
  * If the workspace owner plan has no API write access (for example FREE), write is blocked.
</Note>

## Endpoint

```
PATCH /tokensets/{id}
```

## Authentication

Requires a valid API token in the Authorization header.

## Request

### Headers

| Header          | Value            | Required |
| --------------- | ---------------- | -------- |
| `Authorization` | Bearer token     | Yes      |
| `Content-Type`  | application/json | Yes      |

### Path Parameters

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

### Body Parameters

| Parameter     | Type   | Required | Description                            |
| ------------- | ------ | -------- | -------------------------------------- |
| `name`        | string | No       | New tokenset name (max 255 characters) |
| `description` | string | No       | New description (null to remove)       |

<Note>
  All body parameters are optional. Only provided fields will be updated.
</Note>

### Request Body

```json theme={null}
{
  "name": "Brand Colors",
  "description": "Updated description"
}
```

## Response

### Success Response

**Status:** `200 OK`

```json theme={null}
{
  "id": "tokenset-123",
  "workspace_id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "Brand Colors",
  "description": "Updated description",
  "created_at": "2025-01-15T10:00:00Z",
  "updated_at": "2025-01-15T14:30:00Z"
}
```

## Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X PATCH https://app.tokencraft.dev/api/v1/tokensets/tokenset-123 \
    -H "Authorization: Bearer tkc_your_token_here" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Brand Colors",
      "description": "Primary brand color palette"
    }'
  ```

  ```javascript JavaScript theme={null}
  const tokensetId = 'tokenset-123';

  const response = await fetch(
    `https://app.tokencraft.dev/api/v1/tokensets/${tokensetId}`,
    {
      method: 'PATCH',
      headers: {
        'Authorization': 'Bearer tkc_your_token_here',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        name: 'Brand Colors',
        description: 'Primary brand color palette'
      })
    }
  );

  const tokenset = await response.json();
  ```

  ```python Python theme={null}
  tokenset_id = 'tokenset-123'

  response = requests.patch(
      f'https://app.tokencraft.dev/api/v1/tokensets/{tokenset_id}',
      headers={
          'Authorization': 'Bearer tkc_your_token_here',
          'Content-Type': 'application/json'
      },
      json={
          'name': 'Brand Colors',
          'description': 'Primary brand color palette'
      }
  )

  tokenset = response.json()
  ```
</CodeGroup>

## Error Responses

### 400 Bad Request

```json theme={null}
{
  "error": "Name must be a non-empty string"
}
```

### 404 Not Found

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

## Next Steps

<CardGroup cols={2}>
  <Card title="Delete Tokenset" icon="trash" href="/api-reference/tokensets/delete">
    Permanently delete a tokenset
  </Card>

  <Card title="List Modes" icon="moon" href="/api-reference/tokensets/modes">
    View tokenset modes
  </Card>
</CardGroup>
