# Delete a saved agent.

`DELETE /o/{org}/agents/{agent}`

The agent starts no new session and is no longer listed or readable. Sessions already
started from it run to the end. `If-Match` is optional for an API key, as on an edit.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `org` | path | string | yes | The org's slug or id. A caller with no role in the org gets `404`. |
| `agent` | path | string | yes | The saved agent's id. |
| `If-Match` | header | string | no | The `ETag` of the revision you read; another revision is `412 STALE_ETAG`. |

## Example request

```bash
curl -X DELETE "https://api.prix.dev/o/$RUSH_ORG/agents/$AGENT" \
  -H "Authorization: Bearer $RUSH_TOKEN"
```

```typescript
const org = process.env.RUSH_ORG;
const agent = process.env.AGENT;

const res = await fetch(`https://api.prix.dev/o/${org}/agents/${agent}`, {
  method: "DELETE",
  headers: {
    Authorization: `Bearer ${process.env.RUSH_TOKEN}`,
  },
});

console.log(res.status, await res.json());
```

```python
import os

import requests

org = os.environ["RUSH_ORG"]
agent = os.environ["AGENT"]

res = requests.delete(
    f"https://api.prix.dev/o/{org}/agents/{agent}",
    headers={"Authorization": f"Bearer {os.environ['RUSH_TOKEN']}"},
)

print(res.status_code, res.json())
```

## Responses

### 200

The agent is deleted.

- `id` (string, required)
- `deleted` (boolean, required)

### 401

No bearer, an unknown, revoked or expired one, or an API key on a route keys cannot call.

### 404

No such agent of yours, or one already deleted (`NOT_FOUND`).

### 412

A concurrent edit won (`STALE_ETAG`); read the agent and delete it again.

### 428

A signed-in caller sent no `If-Match` (`IF_MATCH_REQUIRED`).

## Example response (200)

```json
{
  "id": "6244972a-14cc-4592-a0e3-c7a0ab45b07b",
  "deleted": true
}
```
