# Remove the agent from an Instagram account

> DELETE https://api.nabrah.ai/api/ext/omni_v2/instagram/unassign_chatbot

Group: Instagram. Page: https://www.nabrah.ai/en/docs/api-reference/instagram/remove-the-agent-from-an-instagram-account

Remove the agent from one of the project's Instagram accounts, stopping automatic AI replies on that account. The agent keeps answering on its other accounts with their settings unchanged. The response is an object confirming the operation.

## Effect

After unassigning, incoming Instagram direct messages on that account are no longer answered automatically by an AI agent.

Check the current assignment first with GET /api/ext/omni_v2/instagram/get_chatbot, and re-attach later with POST /api/ext/omni_v2/instagram/assign_chatbot.

## Choosing the Instagram account

A project can connect more than one Instagram account. `inbox_id` selects the account this call works on.

- **One account**: `inbox_id` is optional; the project's only Instagram account is used.
- **More than one account**: `inbox_id` is required and the call returns 400 without it. An id that is not one of the project's Instagram accounts returns 404. Fields: `inbox_id`.

List the accounts and their ids with GET /api/ext/omni_v2/instagram/inboxes.

## Errors

- **409 Conflict**: Another change to the same account's agent is still being saved. Wait a moment, then try again; GET /api/ext/omni_v2/instagram/get_chatbot shows the result once it is saved.

## Authorization

- `X-API-Key` (string, header, required): your workspace API key.

## Query parameters

- `inbox_id` (string, optional): The `id` of the Instagram account to use, from GET /api/ext/omni_v2/instagram/inboxes. Use `inboxes[].id` (a UUID), not the numeric `inboxes[].inbox_id`. Optional while the project has one Instagram account; required once it has more than one.

## Response

### 200 Successful Response

Content type: `application/json`

```json
0
```

### 422 Validation Error

Content type: `application/json`

```json
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string"
    }
  ]
}
```

## Request examples

### cURL

```bash
curl --request DELETE \
  --url 'https://api.nabrah.ai/api/ext/omni_v2/instagram/unassign_chatbot' \
  --header 'X-API-Key: <your-api-key>'
```

### Python

```python
import requests

url = "https://api.nabrah.ai/api/ext/omni_v2/instagram/unassign_chatbot"
headers = {"X-API-Key": "<your-api-key>"}

response = requests.delete(url, headers=headers)
response.raise_for_status()
print(response.json())
```

### JavaScript

```javascript
const response = await fetch("https://api.nabrah.ai/api/ext/omni_v2/instagram/unassign_chatbot", {
  method: "DELETE",
  headers: { "X-API-Key": "<your-api-key>" },
});

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

### Go

```go
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	req, _ := http.NewRequest("DELETE", "https://api.nabrah.ai/api/ext/omni_v2/instagram/unassign_chatbot", nil)
	req.Header.Set("X-API-Key", "<your-api-key>")

	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()

	out, _ := io.ReadAll(res.Body)
	fmt.Println(string(out))
}
```
