# Delete an agent

`DELETE /agents/{agent_name}`

Deletes an agent. For hosted agents, if any version has active sessions, the request
is rejected with HTTP 409 unless `force` is set to true. When force is true, all
associated sessions are cascade-deleted along with the agent and its versions.

## Parameters

### Path parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `agent_name` | `string` | Yes | The name of the agent to delete. |

### Query parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `force` | `boolean` | No | For Hosted Agents, if `true`, force-deletes the agent even if its versions have active sessions, cascading deletion to all associated sessions. The service defaults to `false` if a value is not specified by the caller. This value is not relevant for other Agent types. _Default:_ `false` |
| `api-version` | `string` | Yes | The API version to use for this operation. |

## Responses

### 200 — The request has succeeded.

Content-Type: `application/json`

A deleted agent Object

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `object` | `enum` | Yes | The object type. Always 'agent.deleted'. _Constant:_ `agent.deleted` |
| `name` | `string` | Yes | The name of the agent. |
| `deleted` | `boolean` | Yes | Whether the agent was successfully deleted. |

### 4XX — Client error

Content-Type: `application/json`

Error response for API failures.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `error` | `OpenAI.Error` | Yes |  |

#### `error` — `OpenAI.Error`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `code` | `string \| null` | Yes |  |
| `message` | `string` | Yes |  |
| `param` | `string \| null` | No |  |
| `type` | `string` | No |  |
| `details` | `OpenAI.Error[]` | No |  |
| `additionalInfo` | `object` | No |  |
| `debugInfo` | `object` | No |  |

### 5XX — Server error

Content-Type: `application/json`

Error response for API failures.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `error` | `OpenAI.Error` | Yes |  |

#### `error` — `OpenAI.Error`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `code` | `string \| null` | Yes |  |
| `message` | `string` | Yes |  |
| `param` | `string \| null` | No |  |
| `type` | `string` | No |  |
| `details` | `OpenAI.Error[]` | No |  |
| `additionalInfo` | `object` | No |  |
| `debugInfo` | `object` | No |  |
