> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.getraya.app/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.getraya.app/_mcp/server.

# Delete agent

DELETE https://v1.getraya.app/api/agent/{id}

Deletes an agent. This permanently removes the agent and all associated data: all calls and call history, all batches and contacts, and all other related data for this agent. This action cannot be undone. If the agent has an active batch, the API returns 400 with a message to stop that batch first.

Reference: https://docs.getraya.app/api-reference/agents/delete-agent

## Authentication

- `X-API-Key` header (required) — API key for authentication. Example: raya_ABCD1234567890abcdef

## Request

### Path parameters

- `id` (string, required) — The UUID of the agent to delete

## Response

### 200

Agent deleted successfully

- `message` (string, optional)
- `id` (string, optional) — Deleted agent UUID

## Errors

### 400 Bad Request Error

Cannot delete: agent has an active batch. Stop the batch first (e.g. Stop your batch (id) before deleting).

- `error` (string, optional)

### 401 Unauthorized Error

Unauthorized - Invalid or missing API key

- `error` (string, optional)
- `message` (string, optional)

### 404 Not Found Error

Agent not found

- `error` (string, optional)
- `message` (string, optional)

### 500 Internal Server Error

Internal server error

- `error` (string, optional)
- `message` (string, optional)

## Examples

**Response**

```json
{
  "message": "Agent deleted successfully",
  "id": "string"
}
```

**SDK Code**

```python
import requests

url = "https://v1.getraya.app/api/agent/123e4567-e89b-12d3-a456-426614174000"

headers = {"X-API-Key": "<apiKey>"}

response = requests.delete(url, headers=headers)

print(response.json())
```

```javascript
const url = 'https://v1.getraya.app/api/agent/123e4567-e89b-12d3-a456-426614174000';
const options = {method: 'DELETE', headers: {'X-API-Key': '<apiKey>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

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

func main() {

	url := "https://v1.getraya.app/api/agent/123e4567-e89b-12d3-a456-426614174000"

	req, _ := http.NewRequest("DELETE", url, nil)

	req.Header.Add("X-API-Key", "<apiKey>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://v1.getraya.app/api/agent/123e4567-e89b-12d3-a456-426614174000")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Delete.new(url)
request["X-API-Key"] = '<apiKey>'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.delete("https://v1.getraya.app/api/agent/123e4567-e89b-12d3-a456-426614174000")
  .header("X-API-Key", "<apiKey>")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('DELETE', 'https://v1.getraya.app/api/agent/123e4567-e89b-12d3-a456-426614174000', [
  'headers' => [
    'X-API-Key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://v1.getraya.app/api/agent/123e4567-e89b-12d3-a456-426614174000");
var request = new RestRequest(Method.DELETE);
request.AddHeader("X-API-Key", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["X-API-Key": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://v1.getraya.app/api/agent/123e4567-e89b-12d3-a456-426614174000")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "DELETE"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```