# Documents

Pages in a workspace: a tree of documents, each with a title, typed properties (frontmatter) and a Markdown body.

## Endpoints

- [Create a document](https://developers.lydie.co/api/documents/create-a-document.md): `POST /v1/documents`
- [Get a document](https://developers.lydie.co/api/documents/get-a-document.md): `GET /v1/documents/{id}`
- [Delete a document](https://developers.lydie.co/api/documents/delete-a-document.md): `DELETE /v1/documents/{id}`
- [List backlinks](https://developers.lydie.co/api/documents/list-backlinks.md): `GET /v1/documents/{id}/backlinks`
- [List backlinks to a block](https://developers.lydie.co/api/documents/list-backlinks-to-a-block.md): `GET /v1/documents/{id}/blocks/{blockId}/backlinks`
- [Update a document body](https://developers.lydie.co/api/documents/update-a-document-body.md): `PATCH /v1/documents/{id}/body`
- [List outgoing links](https://developers.lydie.co/api/documents/list-outgoing-links.md): `GET /v1/documents/{id}/links`
- [Move a document](https://developers.lydie.co/api/documents/move-a-document.md): `POST /v1/documents/{id}/move`
- [Set document properties](https://developers.lydie.co/api/documents/set-document-properties.md): `PATCH /v1/documents/{id}/properties`
- [Permanently delete a document](https://developers.lydie.co/api/documents/permanently-delete-a-document.md): `POST /v1/documents/{id}/purge`
- [Rename a document](https://developers.lydie.co/api/documents/rename-a-document.md): `POST /v1/documents/{id}/rename`
- [Restore a deleted document](https://developers.lydie.co/api/documents/restore-a-deleted-document.md): `POST /v1/documents/{id}/restore`
- [Move a page to another teamspace or to Private](https://developers.lydie.co/api/documents/move-a-page-to-another-teamspace-or-to-private.md): `POST /v1/documents/{id}/space`
- [List unlinked mentions](https://developers.lydie.co/api/documents/list-unlinked-mentions.md): `GET /v1/documents/{id}/unlinked-mentions`
- [List a document's versions](https://developers.lydie.co/api/documents/list-a-documents-versions.md): `GET /v1/documents/{id}/versions`
- [Get a document version](https://developers.lydie.co/api/documents/get-a-document-version.md): `GET /v1/documents/{id}/versions/{versionId}`
- [Restore a document version](https://developers.lydie.co/api/documents/restore-a-document-version.md): `POST /v1/documents/{id}/versions/{versionId}/restore`
- [List a document's children](https://developers.lydie.co/api/documents/list-a-documents-children.md): `GET /v1/workspaces/{workspaceId}/children`
- [Search documents](https://developers.lydie.co/api/documents/search-documents.md): `GET /v1/workspaces/{workspaceId}/search`
- [List the document tree](https://developers.lydie.co/api/documents/list-the-document-tree.md): `GET /v1/workspaces/{workspaceId}/tree`
- [List unresolved links](https://developers.lydie.co/api/documents/list-unresolved-links.md): `GET /v1/workspaces/{workspaceId}/unresolved-links`

## The Document object

- `id` (ULID, required)
- `workspaceId` (string, required): (1–64 chars)
- `parentId` (ULID, required, nullable)
- `title` (string, required): (1–255 chars)
- `sortKey` (string, required): (1–256 chars)
- `properties` (object, 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",
  "parentId": null,
  "title": "Meeting notes",
  "sortKey": "a0",
  "properties": {
    "status": "draft"
  },
  "createdAt": "2026-11-12T09:30:00.000Z",
  "updatedAt": "2026-11-12T09:30:00.000Z",
  "deletedAt": null,
  "createdBy": null,
  "updatedBy": null
}
```
