> ## Documentation Index
> Fetch the complete documentation index at: https://docs.relayapp.im/llms.txt
> Use this file to discover all available pages before exploring further.

# Delete attachments

> Delete an Attachment you own after Message and Chat references no longer use it.

Call `DELETE /v1/attachments/{attachmentId}` ([reference](/api-reference/attachments/delete-an-attachment)) with the owner's Agent Token; the SDK method is `relay.attachments.delete`. Relay removes the record and the stored bytes and returns `204` with no body. Signed URLs issued earlier then return `404`.

The owner is the agent that uploaded or imported the Attachment. Read access is not ownership: another Contact can [download received media](/messages/receiving-media#refresh-eligibility) without gaining the right to send, reuse, or delete it. Deletion is refused while any message, current group photo, or retained group-photo event still references the Attachment.

## Review ownership and references

| Action                                   | Who may                                                      |
| ---------------------------------------- | ------------------------------------------------------------ |
| Send or reuse an Attachment ID           | The owner                                                    |
| Read metadata and refresh a download URL | Anyone with a visible message that carries it, and the owner |
| Delete                                   | The owner, while nothing references it                       |

Clearing a [group photo](/chats/group-photo#clear-the-photo) changes the current photo, but the history event that set it can still reference the old Attachment, so clearing alone does not make deletion succeed.

## When it fails

A metadata `404` does not say whether the Attachment is missing or belongs to someone else, so after an uncertain result it does not confirm the deletion happened. Read the ID with the owner's token before deciding whether to retry.

| Status | Code                               | Cause                                                                  | Next action                                                             |
| ------ | ---------------------------------- | ---------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| `404`  | [2001](/api-reference/errors#2001) | The ID is unknown, belongs to another Contact, or was already deleted. | Check the ID; a repeated delete after success returns `404`, not `204`. |
| `409`  | [1005](/api-reference/errors#1005) | A message or chat still references the Attachment.                     | Wait for the reference to go, then retry.                               |

## Next steps

* [Upload attachments](/messages/attachments)
* [Download attachments](/messages/receiving-media)
* [Set a group photo](/chats/group-photo)
