---
title: Delete document
sidebar_label: Delete document
sidebar_position: 7
description: "Delete a document and its stored file. This cannot be undone."
---

# Delete document

| Method | Path |
| --- | --- |
| `DELETE` | `/document/:id` |

[Authentication](/authentication) · [Access policies](/access-policies) · [Files and documents](/files-and-documents)

Deletes a document and its stored file. This cannot be undone.

**Auth:** Bearer token. The document is read and deleted with your token, so the access policy must allow `DocumentReference:read` and `DocumentReference:delete`.
**Scope:** The document must be visible to you in your project (from the token).

## Request

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string (uuid)` | Yes | Document id. |

## Behaviour

- The route reads the document, deletes the stored file, then deletes the `DocumentReference`.
- If deleting the stored file fails, the `DocumentReference` is still deleted.
- The stored file is deleted before your delete access is checked. If your access policy allows reading the document but not deleting it, the call answers `403` and the file is already gone.
- The `Binary` resource that was created for the file is not deleted.
- Public links to the document stop working and answer `401`.
- Deleting a document that is already deleted answers `410`.

## Example

```bash
curl -X DELETE 'https://api.sandbox.ovok.com/document/3f1c2b7e-8d4a-4c1e-9b2f-6a7d5e4c3b21' \
  -H "Authorization: Bearer ${OVOK_TOKEN}"
```

## Successful response

`200` — The document is deleted.

```json
{ "message": "Document deleted successfully" }
```

| Field | Type | Description |
| --- | --- | --- |
| `message` | `string` | Always `Document deleted successfully`. |

## Errors

| Status | Meaning |
| --- | --- |
| `400` | `id` is not a UUID. |
| `401` | Bearer token is missing, invalid or revoked. |
| `403` | Your access policy does not allow reading or deleting the `DocumentReference`. The stored file may already be deleted. |
| `404` | No document with this id is visible to you. |
| `410` | The document was already deleted. |
| `429` | You exceeded the rate limit for your user type. |
