# Attachments

Files attached to a workspace or a document, stored by their SHA-256 hash. Upload the bytes first, then record the attachment.

## Endpoints

- [Add an attachment](https://developers.lydie.co/api/attachments/add-an-attachment.md): `POST /v1/attachments`
- [Get an upload URL for a file](https://developers.lydie.co/api/attachments/get-an-upload-url-for-a-file.md): `POST /v1/attachments/uploads`
- [Get an attachment](https://developers.lydie.co/api/attachments/get-an-attachment.md): `GET /v1/attachments/{id}`
- [Delete an attachment](https://developers.lydie.co/api/attachments/delete-an-attachment.md): `DELETE /v1/attachments/{id}`
- [Get a download URL for an attachment](https://developers.lydie.co/api/attachments/get-a-download-url-for-an-attachment.md): `GET /v1/attachments/{id}/download-url`
- [Permanently delete an attachment](https://developers.lydie.co/api/attachments/permanently-delete-an-attachment.md): `POST /v1/attachments/{id}/purge`
- [Restore an attachment](https://developers.lydie.co/api/attachments/restore-an-attachment.md): `POST /v1/attachments/{id}/restore`
- [List attachments](https://developers.lydie.co/api/attachments/list-attachments.md): `GET /v1/workspaces/{workspaceId}/attachments`

## The Attachment object

- `id` (ULID, required)
- `workspaceId` (string, required): (1–64 chars)
- `documentId` (ULID, required, nullable): The document it belongs to; null for workspace files.
- `filename` (string, required): (1–255 chars)
- `contentType` (string, required): (1–255 chars)
- `size` (integer, required)
- `sha256` (string, required)
- `createdAt` (timestamp, required)
- `updatedAt` (timestamp, required)
- `deletedAt` (timestamp, required, nullable)
- `createdBy` (string, optional, nullable): (≥ 1 chars)
- `updatedBy` (string, optional, nullable): (≥ 1 chars)

```json
{
  "id": "01JCQ3V5MZ8G4ZK2X7T9R6N1PB",
  "workspaceId": "01JCQ3TZ0WJ8K4M2X7T9R6N1PA",
  "documentId": null,
  "filename": "string",
  "contentType": "string",
  "size": 0,
  "sha256": "string",
  "createdAt": "2026-11-12T09:30:00.000Z",
  "updatedAt": "2026-11-12T09:30:00.000Z",
  "deletedAt": null,
  "createdBy": null,
  "updatedBy": null
}
```
