Appearance
Content API
Content instances are created from components and stored within documents. Each content instance must reference both a document and a component.
Create Content
Create a new content instance in a document.
Endpoint: POST /api/v1/content
Request Body:
json
{
"DocumentId": 123,
"ComponentId": 456,
"position": "first",
"data": <value>
}The data field should match the schema defined by the component. Examples:
String Content
json
{
"DocumentId": 123,
"ComponentId": 456,
"position": "first",
"data": "based"
}Integer Content
json
{
"DocumentId": 123,
"ComponentId": 456,
"position": "first",
"data": 150
}Array Content
json
{
"DocumentId": 123,
"ComponentId": 456,
"position": "first",
"data": [
"eins",
"zwei",
"drei"
]
}Array of Arrays
json
{
"DocumentId": 123,
"ComponentId": 456,
"position": "first",
"data": [
["a", "b", "c"],
["1", "2", "3"]
]
}Object Content
json
{
"DocumentId": 123,
"ComponentId": 456,
"position": "first",
"data": {
"firstName": "Chuck",
"helpText": null
}
}Nested Array of Objects
json
{
"DocumentId": 123,
"ComponentId": 456,
"position": "first",
"data": [
[
{
"firstName": "Chuck",
"helpText": null
},
{
"firstName": "André",
"helpText": null
}
],
[
{
"firstName": "Wheeler",
"helpText": null
}
]
]
}Content with Slots (Parent Parameter)
To add content to a slot, include a parent parameter:
json
{
"DocumentId": 123,
"ComponentId": 789,
"parent": {
"HostContentId": "550e8400-e29b-41d4-a716-446655440000",
"Slot": "items"
},
"position": "first",
"data": {
"title": "Slot Item Title",
"description": "Slot Item Description"
}
}Parameters:
parent.HostContentId- UUID of the content instance containing the slotparent.Slot- Name of the slot (must match the$refin the component schema)
For detailed information on slots and references, see the Slots & References documentation.
Example Request:
bash
curl -X POST "https://access.flatnode.io/api/v1/content" \
-H "Authorization: Bearer your-token-here" \
-H "Content-Type: application/json" \
-d '{
"DocumentId": 123,
"ComponentId": 456,
"position": "first",
"data": ["eins", "zwei", "drei"]
}'Response: 201 Created
json
{
"data": {
"Id": 789,
"Uuid": "550e8400-e29b-41d4-a716-446655440000"
}
}Get Content
Retrieve a content instance by ID.
Endpoint: GET /api/v1/content/{id}
Example Request:
bash
curl -X GET "https://access.flatnode.io/api/v1/content/789" \
-H "Authorization: Bearer your-token-here"Response: 200 OK
Returns the content data and metadata.
Update Content
Update an existing content instance using its UUID.
Endpoint: PATCH /api/v1/content/{uuid}
Request Body:
The request body should contain the fields to update. Use _value to update the main content value:
Update String Value
json
{
"_value": "updated text"
}Update Integer Value
json
{
"_value": 75
}Update Array Value
json
{
"_value": [
"updated",
"version"
]
}Update Nested Array
json
{
"_value": [
[
"updated version"
]
]
}Example Request:
bash
curl -X PATCH "https://access.flatnode.io/api/v1/content/550e8400-e29b-41d4-a716-446655440000" \
-H "Authorization: Bearer your-token-here" \
-H "Content-Type: application/json" \
-d '{
"_value": 75
}'Response: 200 OK
Delete Content
Delete a content instance.
Endpoint: DELETE /api/v1/content/{id}
Example Request:
bash
curl -X DELETE "https://access.flatnode.io/api/v1/content/789" \
-H "Authorization: Bearer your-token-here"Response: 200 OK or 204 No Content
Validation
Content is validated against the component schema when created or updated. Common validation errors:
Array Without Item Type
json
{
"message": "The given data was invalid.",
"errors": {
"data": [
"an array without item type is not supported"
]
}
}Array Length Constraints
If an array component has minItems: 2 and maxItems: 3:
- Too few items:
[1]→422 Unprocessable Entity - Too many items:
[1, 2, 3, 4]→422 Unprocessable Entity - Valid:
[1, 2, 3]→201 Created
Object Additional Properties
If an object component has additionalProperties: false:
json
{
"type": "object",
"properties": {
"foo": { "type": "integer" }
},
"additionalProperties": false
}- Invalid:
{"foo": 1, "bar": "nope"}→422 Unprocessable Entity - Valid:
{"foo": 2}→201 Created
Object Property Count
If an object component has minProperties: 1 and maxProperties: 2:
- Too few:
{}→422 Unprocessable Entity - Too many:
{"first": "a", "second": "b", "third": "c"}→422 Unprocessable Entity - Valid:
{"first": "a", "second": "b"}→201 Created
String Validation
For strings with pattern and enum:
json
{
"type": "string",
"pattern": "^[a-z]+$",
"enum": ["ok", "good", "fine"]
}- Invalid pattern:
"ABC"→422 Unprocessable Entity - Invalid enum:
"almost"→422 Unprocessable Entity - Valid:
"good"→201 Created
Position Parameter
The position parameter determines where the content is placed in the document:
"first"- Add at the beginning"last"- Add at the end- Other positions may be supported (check implementation)
Slots and References
For advanced content structures using slots and schema references, see the Slots & References documentation. This includes:
- Creating content with slots (dynamic, user-added content areas)
- Using schema references (
$ref) for reusable components - Stacking multiple schemas together
- Nested slot hierarchies