# Stop a conversational AI agent (/en/api-reference/api-ref/conversational-ai/leave)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

Stops a specified Conversational AI agent instance.

- OpenAPI: /openapi/conversational-ai/rest-api.en.yaml
- Operation ID: stop-agent
- Method: POST
- Path: /v2/projects/{appid}/agents/{agentId}/leave
- Endpoint: https://api.agora.io/api/conversational-ai-agent/v2/projects/{appid}/agents/{agentId}/leave

## Servers

- https://api.agora.io/api/conversational-ai-agent

Use this endpoint to stop the specified Conversational AI agent instance.


## Authorization

This endpoint requires authentication.

- `tokenAuth`
- `basicAuth`

## Parameters

- `appid` (path, required, string) - The App ID of the project.
- `agentId` (path, required, string) - The agent instance ID you obtained after successfully calling `join` to [Start a conversational AI agent](/en/api-reference/api-ref/conversational-ai/join).

## Request body

No request body.

## Request examples

### curl

```bash
curl --request POST \
  --url https://api.agora.io/api/conversational-ai-agent/v2/projects/:appid/agents/:agentId/leave \
  --header 'Authorization: Basic <your_base64_encoded_credentials>'
```

### Python

```python
import requests

url = "https://api.agora.io/api/conversational-ai-agent/v2/projects/:appid/agents/:agentId/leave"

headers = {
    "Authorization": "Basic <your_base64_encoded_credentials>",
    "Content-Type": "application/json"
}

response = requests.post(url, headers=headers)
print(response.text)
```

### Node.js

```javascript
const url = 'https://api.agora.io/api/conversational-ai-agent/v2/projects/:appid/agents/:agentId/leave';

const options = {
  method: 'POST',
  headers: {
    'Authorization': 'Basic <your_base64_encoded_credentials>',
    'Content-Type': 'application/json'
  }
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```


### Response

- If the returned status code is `200`, the request was successful. The response body is empty.

- If the returned status code is not `200`, the request failed. The response body includes the error code and description. Refer to [status codes](/en/api-reference/api-ref/conversational-ai/status-codes) to understand the possible reasons for failure.


## Responses

### 200

The request was successful. The response body contains the result of the request.

No schema.
### default

The request failed. The response body includes the error details.

- `detail` (string) - Detailed error information.
- `reason` (string) - The reason for the failure.
