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

# Delete Tokenset

> Permanently delete a tokenset and all its data

# Delete Tokenset

Permanently deletes a tokenset and all its associated modes and tokens. This action cannot be undone.

<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

```
DELETE /tokensets/{id}
```

## 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      | Tokenset ID |

## Response

### Success Response

**Status:** `200 OK`

```json theme={null}
{
  "message": "Tokenset deleted successfully"
}
```

## Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X DELETE https://app.tokencraft.dev/api/v1/tokensets/tokenset-123 \
    -H "Authorization: Bearer tkc_your_token_here"
  ```

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

  const response = await fetch(
    `https://app.tokencraft.dev/api/v1/tokensets/${tokensetId}`,
    {
      method: 'DELETE',
      headers: {
        'Authorization': 'Bearer tkc_your_token_here'
      }
    }
  );

  const result = await response.json();
  console.log(result.message);
  ```

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

  response = requests.delete(
      f'https://app.tokencraft.dev/api/v1/tokensets/{tokenset_id}',
      headers={'Authorization': 'Bearer tkc_your_token_here'}
  )

  result = response.json()
  print(result['message'])
  ```
</CodeGroup>

## Error Responses

### 404 Not Found

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

## Cascade Deletion

When a tokenset is deleted, the following are also deleted:

* ✅ All modes in the tokenset
* ✅ All tokens in those modes

<Warning>
  This operation is **irreversible**. All data will be permanently deleted. Make sure to export your tokens before deletion if you need a backup.
</Warning>

## Best Practices

### Export Before Deletion

```javascript theme={null}
async function safeDeleteTokenset(tokensetId) {
  // Export all modes first
  const modes = await getModes(tokensetId);
  
  for (const mode of modes) {
    await exportMode(tokensetId, mode.id, 'json');
  }
  
  // Then delete
  await deleteTokenset(tokensetId);
}
```

## Next Steps

<CardGroup cols={2}>
  <Card title="Export Tokenset" icon="download" href="/api-reference/export/tokenset">
    Export before deletion
  </Card>

  <Card title="Create Tokenset" icon="plus" href="/api-reference/tokensets/create">
    Create a new tokenset
  </Card>
</CardGroup>
