---
title: "Delete an end user's or an agent's data"
method: POST
path: "/v1/data_deletions"
tags: ["Data deletions"]
---

# Delete an end user's or an agent's data

`POST /v1/data_deletions`

## Request

- Base URL: `https://api.dexto.ai`
- URL: `https://api.dexto.ai/v1/data_deletions`
- Auth: HTTP bearer

Delete data in the background. With user, deletes every session labelled with that end user in this key's Cloud project (or one agent), and every automation whose sessions carry the label. With only agent_id, archives the agent at once, pauses its automations, then deletes its sessions, automations, firings and versions; usage and spend keep its id and name. Usage and billing records are never deleted. While a user deletion is queued or running, new sessions for that user are refused with 409. A deletion that keeps failing ends failed with an error; requesting it again resumes it. At most 10 deletions per project are queued or running at once.

## Request body

- object
  - `agent_id` string, uuid, nullable: Without user: the agent whose data to delete. With user: only that agent's sessions of the end user; null for every agent of this key's Cloud project.
  - `user` string, nullable: The end-user label whose sessions to delete, as you passed it when creating them. Never returned.

## Response `202`

Accepted.

- object
  - `completed_at` string, date-time, nullable, required: When it completed or failed; null while it is queued or running.
  - `created_at` string, date-time, required
  - `created_by` union, required: The API key that asked for it, or the person through an OAuth token.
    - object
      - `api_key_id` string, uuid, required: The API key that asked for it.
      - `type` 'api_key', required
    - object
      - `type` 'user', required
      - `user_id` string, required: The person who created it through an OAuth token, or whose key was since deleted.
  - `deleted` object, required: What it deleted so far.
    - `automations` integer, required
    - `sessions` integer, required
  - `error` object, nullable, required: Why the deletion failed; null unless status is failed. What it deleted stays deleted, an agent it was deleting stays archived, and requesting the same deletion again resumes it.
    - `code` 'deletion_failed', required
    - `message` string, required
  - `id` string, uuid, required
  - `object` 'data_deletion', required
  - `scope` object, required
    - `agent_id` string, uuid, nullable, required: The agent, or null for a user deletion across the project.
    - `type` 'agent' | 'user', required: user: one end user's sessions and the automations that write to them. agent: everything of one agent.
  - `status` 'queued' | 'running' | 'completed' | 'failed', required

## Other responses

- `400`: Invalid JSON or request fields.
- `401`: Missing or invalid API key.
- `402`: The account has insufficient credits.
- `403`: The account cannot perform this operation.
- `404`: The requested resource was not found.
- `409`: The request conflicts with existing resource state.
- `429`: The account exceeded this operation's request rate.
- `500`: Unexpected Dexto failure.
- `502`: The upstream model provider failed.
- `503`: A required Dexto service is temporarily unavailable.

---

[API](https://skmtc.dev/dexto/apis/dexto-api.md) - [All operations](https://skmtc.dev/dexto/apis/dexto-api/llms.txt) - [OpenAPI document](https://skmtc.dev/dexto/apis/dexto-api/revisions/47eb880cffa5?raw)
