---
docId: doc_62955b26aa3f4676a2a91726277a25cb
title: Delete an agent
description: Deletes an agent. It can't be undone; its files are disconnected and stay in the workspace.
api:
  group: agentes
  auth: bearer
  operations:
    - operationId: deleteAgent
      method: DELETE
      path: '/v1/agents/{agentId}'
      postmanName: Delete an agent
---

<script>
  import { Ways, Note, Collapsible } from '$lib/components';
</script>

# Delete an agent

Delete an agent to stop it replying and remove it from lists. Before deleting it, check whether other agents use it as a subagent.

<Note type="warning">

Deleting an agent can't be undone: the API has no operation to recover it. If you only want it to stop answering, deactivate it with [Update an agent](/api-reference/agents/update) (`"status": "inactive"`).

</Note>

## If it is another agent's subagent

<Collapsible summary="Unlink it from parent agents before deleting it">

Deleting an agent doesn't remove the links other agents have to it. Each parent's published version still names it, but no longer hands it conversations or consults it.

The parent's draft can still be edited. What you can't do until you remove the link is publish that version, roll back, restore or copy a version that has it: they answer `422` with `details.code: "INVALID_SUBAGENT_LINK"` and the message says which agent was deleted.

Before deleting it, [unlink it](/api-reference/agents/subagents/unlink) from each parent and publish those parents. If you already deleted it, unlink it from the parent's draft and publish.

</Collapsible>

## Example

<Ways tabs="api,sdk">
<Ways.Way name="api">

```bash
curl -X DELETE https://api.platic.ai/v1/agents/$AGENT_ID \
  -H "Authorization: Bearer $PLATIC_API_KEY"
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
await platic.agents.delete("agent_123");
```

</Ways.Way>
</Ways>

## Path parameters

| Parameter | Type | Description | Required |
|-----------|------|-------------|----------|
| `agentId` | string | Agent id | ✓ |

## Query parameters

| Parameter | Type | Description | Required |
|-----------|------|-------------|----------|
| `workspace` | string | Only if the credential has access to several workspaces | - |

## Response

`200 OK`. The response confirms the deletion:

```json
{
  "status": "success",
  "message": "Agent deleted successfully",
  "data": { "id": "Xq8mTe2LwP4kZ1aB9cDf", "deleted": true }
}
```

| Field | Description |
|-------|-------------|
| `data.id` | Id of the deleted agent |
| `data.deleted` | `true` |
| `message` | Fixed text that confirms the deletion |

## Errors

| Status | `details.code` | When |
|--------|----------------|------|
| `400` | `INVALID_REQUEST` | The credential covers several workspaces and `workspace` is missing, or isn't one of its own |
| `403` | `FORBIDDEN` | The credential can't edit this agent |
| `404` | `AGENT_NOT_FOUND` | The agent doesn't exist in the workspace |
| `503` | `TEMPORARILY_UNAVAILABLE` | The deletion couldn't be finished. Repeat the same request: it continues where it left off |

## What happens to its files

Before deleting the agent, the API disconnects all of its files. Only the connections are removed: the files stay in the workspace and remain connected to the other agents that use them. To delete a file, use [Delete a file](/api-reference/files/delete).

## Notes

- If disconnecting the files fails, the agent isn't deleted. Repeating the request picks it up again.
- After deleting it, [Get an agent](/api-reference/agents/get) answers `404` and the agent no longer appears in [List agents](/api-reference/agents/list).
