Skip to content

Documents API

Documents are the top-level containers for content in the CMS. Each document can contain multiple content instances.

Create a Document

Create a new document.

Endpoint: POST /api/v1/document

Request Body:

json
{
  "title": "My Document Title"
}

Example Request:

bash
curl -X POST "https://access.flatnode.io/api/v1/document" \
  -H "Authorization: Bearer your-token-here" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "motorhead"
  }'

Response: 201 Created

json
{
  "document": {
    "Id": 123
  }
}

Get a Document

Retrieve a document by ID. The response includes the document structure with all content.

Endpoint: GET /api/v1/document/{id}

Example Request:

bash
curl -X GET "https://access.flatnode.io/api/v1/document/123" \
  -H "Authorization: Bearer your-token-here"

Response: 200 OK

The response structure depends on the content within the document. For a simple document with a single string value:

json
{
  "_value": "based",
  "_uuid": "550e8400-e29b-41d4-a716-446655440000"
}

For a document with an array:

json
{
  "_value": [
    "eins",
    "zwei",
    "drei"
  ],
  "_uuid": "550e8400-e29b-41d4-a716-446655440000"
}

For nested structures:

json
{
  "_value": [
    ["a", "b", "c"],
    ["1", "2", "3"]
  ],
  "_uuid": "550e8400-e29b-41d4-a716-446655440000"
}

Get Document Tree

Retrieve a document and its nested structure as a tree.

Endpoint: GET /api/v1/tree/{id}

Example Request:

bash
curl -X GET "https://access.flatnode.io/api/v1/tree/123" \
  -H "Authorization: Bearer your-token-here"

Response: 200 OK

Returns the document structure in a tree format.

Update a Document

Update an existing document. You can update the title and move a node within the document tree.

Endpoint: PATCH /api/v1/document/{id} or PUT /api/v1/document/{id}

Request Body:

json
{
  "title": "Updated Document Title"
}

Move a Document Node

Move a document within the tree. You can either move it under a parent or relative to a sibling.

Move to the first or last child of a parent:

json
{
  "parent": 10,
  "position": "first"
}
json
{
  "parent": 10,
  "position": "last"
}

Move relative to a sibling:

json
{
  "insertBefore": 42
}
json
{
  "insertAfter": 42
}

Notes:

  • position is only valid when parent is provided.
  • insertBefore and insertAfter cannot be used together or with parent.

Example Request:

bash
curl -X PATCH "https://access.flatnode.io/api/v1/document/123" \
  -H "Authorization: Bearer your-token-here" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Updated Title"
  }'

Response: 200 OK

Delete a Document

Delete a document.

Endpoint: DELETE /api/v1/document/{id}

Example Request:

bash
curl -X DELETE "https://access.flatnode.io/api/v1/document/123" \
  -H "Authorization: Bearer your-token-here"

Response: 200 OK or 204 No Content