# Delete an assistant

Source: [Delete an assistant](<https://docs.gptunnel.ru/en/api/assistants/delete/>)

<a id="_top"></a>
[Get an API key](<https://docs.gptunnel.ru/en/#get-an-api-key>) to send requests.

<a id="request"></a>
## Request

`POST https://gptunnel.ru/v1/assistant/delete`

Deletes an assistant created by the API key owner. The assistant disappears from the catalog and stops responding in chat.

### Request headers

| Parameter | Type | Description |
| --- | --- | --- |
| `Authorization` (required) | `string` | API key |

### Request body

| Parameter | Type | Description |
| --- | --- | --- |
| `id` (required) | `string` | Assistant ID from the /v1/assistant/create or /v1/assistant/list response |

After deletion, the assistant also disappears from the [assistant list](<https://docs.gptunnel.ru/en/api/assistants/list/>). A second delete request with the same `id` returns HTTP `404`.

<a id="example-request"></a>
### Example request

Set `GPTUNNEL_API_KEY` to your API key and `GPTUNNEL_ASSISTANT_ID` to the `id` of your own test assistant that you want to delete.

<a id="tab-panel-0-0"></a>
**Python**

```python
import json
import os
from urllib.request import Request, urlopen

body = {
  "id": os.environ['GPTUNNEL_ASSISTANT_ID']
}
request = Request(
    'https://gptunnel.ru/v1/assistant/delete',
    headers={
        'Authorization': os.environ['GPTUNNEL_API_KEY'],
        'Content-Type': 'application/json',
    },
    data=json.dumps(body).encode('utf-8'),
)
with urlopen(request, timeout=60) as response:
    print(json.load(response))
```

<a id="tab-panel-0-1"></a>
**cURL**

```bash
curl --request POST \
  --url 'https://gptunnel.ru/v1/assistant/delete' \
  --header "Authorization: ${GPTUNNEL_API_KEY:?Set GPTUNNEL_API_KEY}" \
  --header 'Content-Type: application/json' \
  --data '{
  "id": "'"${GPTUNNEL_ASSISTANT_ID:?Set GPTUNNEL_ASSISTANT_ID}"'"
}'
```

<a id="tab-panel-0-2"></a>
**JavaScript (Node.js)**

```javascript
const response = await fetch('https://gptunnel.ru/v1/assistant/delete', {
  method: 'POST',
  headers: {
    Authorization: process.env.GPTUNNEL_API_KEY,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "id": process.env.GPTUNNEL_ASSISTANT_ID
  }),
})
if (!response.ok) throw new Error(await response.text())
console.log(await response.json())
```

<a id="example-response"></a>
### Example response

<a id="tab-panel-1-0"></a>
**200 OK**

```json
{
  "object": "assistant.deleted",
  "id": "68c9b2d1e4b0a2d3c4f5e6b8",
  "deleted": true
}
```

<a id="tab-panel-1-1"></a>
**404 Not Found**

The assistant does not exist, has already been deleted, or belongs to another user.

```json
{
  "error": {
    "message": "Assistant not found",
    "type": "invalid_request_error",
    "param": null,
    "code": null
  }
}
```
