# Delete document

Canonical page: https://docs.ovok.com/files-and-documents/delete-document

| Method | Path |
| --- | --- |
| `DELETE` | `/v1/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 [#request]

### Path parameters [#path-parameters]

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

## Behaviour [#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 [#example]

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

## Successful response [#successful-response]

`200` — The document is deleted.

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

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

## Errors [#errors]

| Status | Meaning |
| --- | --- |
| [`422`](/errors/validation-failed) | `id` is not a UUID. |
| [`401`](/errors/unauthenticated) | Bearer token is missing, invalid or revoked. |
| [`403`](/errors/forbidden) | Your access policy does not allow reading or deleting the `DocumentReference`. The stored file may already be deleted. |
| [`404`](/errors/not-found) | No document with this id is visible to you. |
| [`410`](/errors/gone) | The document was already deleted. |
| [`429`](/errors/too-many-requests) | You exceeded the rate limit for your user type. |
