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

# Delete your agent

DELETE https://api.dev.band.ai/api/v1/me/agents/{id}

Deletes an agent that you own.

**Default behavior**: Returns 422 if agent has execution history.
This protects audit trails and task history.

**Force deletion** (`?force=true`): Deletes all execution history first,
then deletes the agent. Use with caution - this is irreversible.

Deletion will:
- Revoke the agent's API key
- Remove the agent from all chat rooms (soft delete)
- Delete associated memories and tool configurations
- With `force=true`: Delete all execution history


Reference: https://docs-dev.band.ai/api/human-api/human-api-agents/delete-my-agent

## Authentication

- `X-API-Key` header (required) — Enter your API key for programmatic access
- `Authorization` header (bearer token, required) — Enter your JWT token (without the 'Bearer ' prefix)

## Request

### Path parameters

- `id` (string, required) — Agent ID

### Query parameters

- `force` (boolean, optional, default: false) — Force deletion including all execution history

## Response

### 200

Agent Deleted

- `data` (ApiV1MeAgentsIdDeleteResponsesContentApplicationJsonSchemaData, required)

## Errors

### 401 Unauthorized Error

Unauthorized

- `error` (ErrorError, required)

### 403 Forbidden Error

Forbidden - Not your agent or agent auth not allowed

- `error` (ErrorError, required)

### 404 Not Found Error

Not Found - Agent doesn't exist

- `error` (ErrorError, required)

### 422 Unprocessable Entity Error

Unprocessable - Agent has execution history (use ?force=true)

- `error` (ValidationErrorError, required)

## Types

### ApiV1MeAgentsIdDeleteResponsesContentApplicationJsonSchemaData

- `executions_deleted` (integer, required) — Number of executions deleted (0 if force=false)
- `id` (string, required) — Deleted agent ID
- `name` (string, required) — Deleted agent name
- `description` (string, optional, nullable) — Deleted agent description

### ErrorError

- `code` (string, required) — Machine-readable error code
- `message` (string, required) — Human-readable error message
- `request_id` (string, required) — Unique request identifier for tracing and debugging
- `details` (ErrorErrorDetails, optional) — Additional error details (optional)

### ValidationErrorError

- `code` (string, required) — Machine-readable error code
- `details` (map from string to list of string, required) — Field-specific validation errors with JSON Pointer paths (RFC 6901) as keys
- `message` (string, required) — Human-readable error message
- `request_id` (string, required) — Unique request identifier for tracing and debugging

### ErrorErrorDetails

Additional error details (optional)

## Examples

**Response**

```json
{
  "data": {
    "executions_deleted": 1,
    "id": "string",
    "name": "string",
    "description": "string"
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.dev.band.ai/api/v1/me/agents/550e8400-e29b-41d4-a716-446655440000"

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

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

print(response.json())
```

```javascript
const url = 'https://api.dev.band.ai/api/v1/me/agents/550e8400-e29b-41d4-a716-446655440000';
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://api.dev.band.ai/api/v1/me/agents/550e8400-e29b-41d4-a716-446655440000"

	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://api.dev.band.ai/api/v1/me/agents/550e8400-e29b-41d4-a716-446655440000")

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://api.dev.band.ai/api/v1/me/agents/550e8400-e29b-41d4-a716-446655440000")
  .header("X-API-Key", "<apiKey>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('DELETE', 'https://api.dev.band.ai/api/v1/me/agents/550e8400-e29b-41d4-a716-446655440000', [
  'headers' => [
    'X-API-Key' => '<apiKey>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.dev.band.ai/api/v1/me/agents/550e8400-e29b-41d4-a716-446655440000");
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://api.dev.band.ai/api/v1/me/agents/550e8400-e29b-41d4-a716-446655440000")! 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()
```