Appearance
Components API
Components define the schema/structure for content. They use JSON Schema format to describe the data structure.
Create a Component
Create a new component with a JSON Schema definition.
Endpoint: POST /api/v1/component
Request Body:
The request body should contain a valid JSON Schema. Examples:
Simple String Component
json
{
"title": "A single string",
"type": "string"
}Simple Integer Component
json
{
"title": "A single integer",
"type": "integer"
}Array of Strings
json
{
"title": "A list of strings",
"type": "array",
"items": {
"type": "string",
"default": "bazinga"
}
}Array with Constraints
json
{
"type": "array",
"minItems": 2,
"maxItems": 3,
"items": {
"type": "integer"
}
}Object Component
json
{
"title": "Null field example",
"description": "A short form with a null field",
"type": "object",
"required": ["firstName"],
"properties": {
"helpText": {
"title": "A null field",
"description": "Null fields like this are great for adding extra information",
"type": "null"
},
"firstName": {
"type": "string",
"title": "A regular string field",
"default": "Chuck"
}
}
}Nested Array of Arrays
json
{
"type": "array",
"title": "array of array of string",
"items": {
"type": "array",
"items": {
"type": "string",
"default": "bingo"
}
}
}Example Request:
bash
curl -X POST "https://admin.flatnode.net/api/v1/component" \
-H "Authorization: Bearer your-token-here" \
-H "Content-Type: application/json" \
-d '{
"title": "A single string",
"type": "string"
}'Response: 201 Created
json
{
"message": "Component created.",
"data": {
"_uuid": "660e8400-e29b-41d4-a716-446655440001",
"title": "A single string",
"handle": null,
"isGroup": false,
"publishedVersion": 1,
"version": 1,
"createdAt": "2026-11-08T09:12:44+00:00",
"updatedAt": "2026-11-08T09:12:44+00:00"
}
}_uuid is the component's identifier everywhere else in the API, including in a $ref (http://access.flatnode.net/uuid/<uuid>).
The schema you just posted is not echoed back. To read it, call Get a Component, which serves the bare JSON Schema document.
title is required (rejected with 422 if blank) and must be unique within the project - creating a second component with a title already in use by another component in the same project is also rejected with 422.
Get a Component
Retrieve a component by ID.
Endpoint: GET /api/v1/component/{uuid}
Example Request:
bash
curl -X GET "https://admin.flatnode.net/api/v1/component/660e8400-e29b-41d4-a716-446655440001" \
-H "Authorization: Bearer your-token-here"Response: 200 OK
Returns the component resource with its published schema under schema
- the same
dataevery other component endpoint answers, plus the schema document.
json
{
"message": "component found.",
"data": {
"_uuid": "1efb2c3a-...",
"title": "Press teaser",
"handle": "press-teaser",
"isGroup": false,
"publishedVersion": 2,
"version": 3,
"createdAt": "2026-11-01T12:00:00+00:00",
"updatedAt": "2026-11-20T09:30:00+00:00",
"schema": {
"$id": "/uuid/1efb2c3a-...",
"title": "Press teaser",
"type": "object",
"properties": { "...": "..." }
}
}
}data.schema is the component's published JSON Schema document verbatim (plus a $id naming the component), so it can be sent straight back to PATCH /component/{uuid} or as configuration to POST /validation. The handle, version counters and timestamps sit beside it rather than inside it because a schema is closed to keys it does not declare - see "Handles" below. GET /component lists every component in this same shape, so a listing is enough to pick a component by handle and read its fields.
Handles
A handle is an optional, stable identifier you give a component so your frontend can decide how to render it:
js
switch (block._handle) {
case 'hero-banner': return <HeroBanner {...block._value} />
case 'press-teaser': return <PressTeaser {...block._value} />
default: return <Generic {...block._value} />
}Every rendered component block carries it as _handle alongside _uuid/_type/_component (see Content), and it is omitted entirely when the component has no handle - so a handle-less block never shows up as "_handle": null.
Rules:
- Lowercase letters, digits and single hyphens, starting with a letter:
^[a-z][a-z0-9]*(-[a-z0-9]+)*$, max 64 characters.press-teaseris fine,Press_Teaserand-teaserare not. - Unique within the project. A second component claiming a handle already in use is rejected with
422. - Optional. Send
""to clear it. - Never derived from the title. Renaming a component does not touch its handle, by design: a handle is a contract with your frontend, and it must only ever change because someone meant to change it.
Set it with PATCH /component/{uuid}/metadata (below).
Versioning
Editing a component's schema is versioned: every component has a published version (what every editor and every existing piece of content built from it actually uses right now) and, separately, a draft (your in-progress edit, invisible to everyone else until you explicitly publish it). This means changing a schema can never retroactively reshape or invalidate content that already exists under it - existing content stays pinned to whichever version it was created under, even after you publish a new one.
Renaming a component (title/description) and setting its handle are the one exception: since neither can change how data is stored or validated, they apply immediately to the live, published component - there's no draft step for them.
Where a component is used
Endpoint: GET /api/v1/component/{uuid}/usage
json
{
"data": {
"inUse": true,
"blockCount": 7,
"usages": [
{ "kind": "content", "documentUuid": "...", "documentTitle": "Home", "blockCount": 5 },
{ "kind": "libraryEntry", "libraryUuid": "...", "libraryTitle": "People", "entryCount": 2 }
],
"libraries": [{ "uuid": "...", "title": "People" }],
"referencedBy": [{ "uuid": "...", "title": "Person" }]
}
}A component is in use when content has been authored from it in any version, when a library is built on it, or when another component's schema references it by uuid. The last counts because a referencing component resolves this one as it looked when its own content was created, so its schema must not change underneath.
Save and Publish
Saves the schema and makes it live in one call. What that means depends on whether the component is in use:
- Not in use: the schema is written in place over the one published version, and the version counter does not move. A component being built from scratch stays at version 1 for as long as nothing is pinned to it.
- In use: a draft save followed by a publish - a new version, published, with existing content pinned to its own (see below).
Endpoint: POST /api/v1/component/{uuid}/publish
Request Body: the full JSON Schema, same shape as POST /component.
Response: 200 OK
json
{
"message": "version 1 saved in place.",
"data": { "version": 1, "publishedVersion": 1, "mode": "replaced" }
}mode is replaced, versioned, or unchanged when the body is already the published schema of a component in use - a snapshot is only taken of a change, so nothing was published. The verdict is taken when the call arrives, so an editor open in one tab follows a block created in another. Refused with 422 like a draft save, and when the title would collide with another component's.
Save a Draft
Saves a new draft snapshot of the component's schema. Never touches the live, published schema - existing content and every other editor are completely unaffected until you publish this version (see below). Every call here that actually changes something creates a new, listable version (see "List Versions").
Endpoint: PATCH /api/v1/component/{uuid} or PUT /api/v1/component/{uuid}
Request Body: the full JSON Schema, same shape as POST /component.
bash
curl -X PATCH "https://admin.flatnode.net/api/v1/component/660e8400-e29b-41d4-a716-446655440001" \
-H "Authorization: Bearer your-token-here" \
-H "Content-Type: application/json" \
-d '{
"title": "A single string",
"type": "string",
"minLength": 1
}'Response: 200 OK
json
{
"message": "draft saved.",
"data": { "version": 3, "publishedVersion": 1 }
}Update Title, Description & Handle
Renames a component, sets its description, and/or sets its handle. Applies immediately to the live, published component (and to any in-progress draft, so a later publish can't revert the rename) - no draft/publish step, since none of this can reshape stored data.
Endpoint: PATCH /api/v1/component/{uuid}/metadata
Request Body:
json
{
"title": "A better title",
"description": "Optional description text.",
"handle": "press-teaser"
}title- required, still must be unique within the project.description- optional.handle- optional; omit the key to leave the current handle alone, or send""to clear it. See "Handles" above for the format and uniqueness rules.
Response: 200 OK, the component in the same shape as Get a Component: data.handle and data.title carry the new values, and data.schema is the schema document with the new title and description written into it.
json
{
"message": "component updated.",
"data": {
"_uuid": "1efb2c3a-...",
"title": "A better title",
"handle": "press-teaser",
"...": "...",
"schema": { "$id": "/uuid/1efb2c3a-...", "title": "A better title", "type": "object", "properties": { "...": "..." } }
}
}Returns 422 if the handle is malformed or already taken by another component in the project.
List Versions
Lists every version ever saved for this component, in order.
Endpoint: GET /api/v1/component/{uuid}/versions
Response: 200 OK
json
{
"data": [
{
"version": 1,
"isPublished": true,
"title": "A single string",
"description": null,
"savedAt": "2026-10-20 10:00:00",
"usageCount": 4
},
{
"version": 2,
"isPublished": false,
"title": "A single string",
"description": null,
"savedAt": "2026-10-26 09:00:00",
"usageCount": 0
}
]
}savedAt is UTC, in YYYY-MM-DD HH:MM:SS with no offset - the one datetime in this API that is not RFC 3339.
usageCount is how many existing content items were created under that specific version - see "Delete a Version" below for why that matters.
Publish or Restore a Version
Makes the given version the live, published one. The same action whether the version is newer than the currently published one ("publish this draft") or older ("roll back to this version") - there's no separate rollback endpoint.
Endpoint: POST /api/v1/component/{uuid}/versions/{version}/publish
Response: 200 OK
json
{
"message": "version 2 published.",
"data": { "publishedVersion": 2 }
}Returns 422 if that version's schema fails validation or its title collides with another component's title.
Delete a Version
Deletes a saved version - e.g. an in-between draft you ended up not wanting. The currently published version can never be deleted (422). Deleting a version that existing content still references (usageCount > 0 in the listing above) requires an explicit "confirm": true in the request body, since that content will no longer be able to resolve its own schema afterwards.
Endpoint: DELETE /api/v1/component/{uuid}/versions/{version}
Request Body (only needed if the version is in use):
json
{ "confirm": true }Response: 200 OK, or 409 Conflict with {"data": {"usageCount": N}} if the version is in use and confirm wasn't sent.
Delete a Component
Delete a component.
Endpoint: DELETE /api/v1/component/{uuid}
Example Request:
bash
curl -X DELETE "https://admin.flatnode.net/api/v1/component/660e8400-e29b-41d4-a716-446655440001" \
-H "Authorization: Bearer your-token-here"Response: 200 OK or 204 No Content
Supported JSON Schema Types
The API supports the following JSON Schema types and constraints:
string - Text values, up to 255 characters
minLength,maxLength- neither may exceed 255; a schema that declares more is refused when you save it, because the value would not fit (see Text fields and their length below)pattern- Regular expression patternenum- Allowed valuesformat- Format validation (e.g.,date-time,email,uri), and also how Flatnode spells its own field kinds (see Field kinds written withformatbelow)
integer - Whole numbers
minimum,maximumexclusiveMinimum,exclusiveMaximummultipleOf
number - Decimal numbers
- Same constraints as integer
boolean - True/false values
array - Lists of items
items- Schema for array items (required)minItems,maxItemsuniqueItems
object - Key-value pairs
properties- Property definitionsrequired- Array of required property namesadditionalProperties- Allow/disallow extra propertiesminProperties,maxProperties
null - Null values
Field kinds written with format
Several of Flatnode's field kinds are not JSON Schema types of their own. JSON Schema has seven types and a validator rejects anything outside them, so these kinds are written as a standard type plus a format:
| Kind | Schema | Stored as | Notes |
|---|---|---|---|
| Text | {"type": "string"} | varchar(255) | The only text kind that can be a filterable field |
| Long text | {"type": "string", "format": "text"} | unbounded text | Plain text, edited in a plain text box |
| Rich text | {"type": "string", "format": "richtext"} | unbounded text | Formatted body copy, as a structured document |
| Date & time | {"type": "string", "format": "date-time"} | timestamp | "date" for a date alone |
| Link | {"type": "object", "format": "link"} | reference | See Slots and refs |
| File | {"type": "object", "format": "file"} | reference | An attachment or download - which one? |
| Image | {"type": "object", "format": "image"} | reference | A picture, and the only kind that can hold a crop - which one? |
| Library entry | {"type": "object", "format": "libraryEntry"} | reference | One entry, picked by an editor - when, how |
| Library query | {"type": "object", "format": "libraryQuery"} | reference | Whichever entries match a query the editor authors - when, how |
A format Flatnode does not recognise is left alone: {"type": "string", "format": "email"} is an ordinary Text field whose value is checked as an email address.
Text fields and their length
There are three text kinds, and the one you pick decides how much the field holds:
- Text (
{"type": "string"}) holds up to 255 characters. It is the only text kind a library can filter or sort on, which is what the limit buys: a filterable field becomes a real indexed column, and an index needs a bounded one. - Long text (
{"type": "string", "format": "text"}) holds text of any length. Use it for anything longer than a line that is not formatted body copy. - Rich text (
{"type": "string", "format": "richtext"}) holds formatted body copy of any length, as a structured document rather than a string - see Rich text values. The admin UI edits it in a rich text editor.
Writing more than 255 characters to a Text field is refused with a 422 naming the field:
json
{
"message": "body is 1434 characters. A Text field holds up to 255; for longer values declare the field as Long text (\"format\": \"text\") or Rich text (\"format\": \"richtext\")."
}maxLength does not raise this limit. It is an upper bound that is checked against the value, not a declaration of how wide the field is, so {"type": "string", "maxLength": 20000} promises something the field cannot hold. A component declaring that is refused when you save it, rather than when the first long value arrives:
json
{
"message": "data invalid.",
"data": "body declares maxLength: 20000, but a Text field holds up to 255 characters. For longer values declare the field as Long text (\"format\": \"text\") or Rich text (\"format\": \"richtext\")."
}The limit is per value, not per field. An array of Text items holds 255 characters per item, so a list of ten 200-character strings is fine.
Changing a field from Text to Long text is a schema change like any other: publish a new version of the component. Content already stored stays readable, and the next write to that field uses the wider column.
Rich text values
A Rich text field's value is a document: a JSON tree of blocks and marks, in the shape the ProseMirror family of editors produces. It is never a string of HTML or Markdown; writing one is refused.
json
{
"type": "doc",
"content": [
{
"type": "heading",
"attrs": { "level": 2 },
"content": [{ "type": "text", "text": "Opening hours" }]
},
{
"type": "paragraph",
"content": [
{ "type": "text", "text": "We are open " },
{ "type": "text", "text": "daily", "marks": [{ "type": "bold" }] },
{ "type": "text", "text": ", see the " },
{
"type": "text",
"text": "calendar",
"marks": [{ "type": "link", "attrs": { "href": "https://example.org/calendar" } }]
}
]
},
{
"type": "bulletList",
"content": [
{ "type": "listItem", "content": [{ "type": "paragraph", "content": [{ "type": "text", "text": "Mondays: closed" }] }] }
]
}
]
}The rules, which are checked on every write and by POST /validation:
- The root is
{"type": "doc"}with an optionalcontentlist. It carries notextormarks. - A node is an object with a
type. A block node may carryattrs(an object) andcontent(a list of nodes). A text node has"type": "text", a non-emptytext, and optionallymarks, a list of{"type": ..., "attrs": {...}}. Nothing else is allowed on a node or a mark. - An empty string is accepted and stored as the empty document
{"type": "doc", "content": []}. minLengthandmaxLengthon a Rich text field measure the document's plain text - the text nodes joined by a space - not its JSON.
What a field may contain
The block and mark types are a closed set: paragraphs and hard breaks always; heading (with attrs.level), bulletList, orderedList with listItem, blockquote, codeBlock and horizontalRule as blocks; bold, italic, underline, strike, code and link (with attrs.href) as marks.
Which of them a field accepts is decided in two places. The project-wide default is set under Settings → Rich text editor, and out of the box it is every mark, every block, and headings 2 and 3. A field overrides it with a richtext keyword beside format: "richtext":
json
{
"type": "string",
"format": "richtext",
"richtext": {
"marks": ["bold", "italic", "link"],
"blocks": [],
"headingLevels": [2, 3]
}
}Each key is optional and replaces the project's list for that key alone; a key you leave out falls through to the project default. So {"blocks": []} is a marks-only field that still follows the project's choice of marks. Paragraphs, hard breaks and the listItem inside an allowed list are always allowed.
The set is enforced, not just reflected in the editor's toolbar. A write carrying a block, a mark or a heading level the field does not allow is a 422 naming it, and POST /validation gives the same verdict:
json
{
"message": "teaser: content[1] is a \"heading\" block, which this field does not allow; it allows paragraphs only.",
"errors": { "data": ["teaser: content[1] is a \"heading\" block, which this field does not allow; it allows paragraphs only."] }
}The keyword is part of the schema, so it is versioned with the component like any other keyword; the project default is live settings and applies to every field without an override on that field's next write. Narrowing either leaves existing content readable as it is, but that content cannot be saved again until the formatting it no longer may use is removed.
A richtext keyword on a field that is not format: "richtext", or naming an id outside the set above, is refused when the component is saved, not when content arrives.
Links inside a document
A link mark targets exactly one of three things, and its attrs say which:
json
{ "type": "link", "attrs": { "href": "https://example.org/calendar" } }
{ "type": "link", "attrs": { "node": "550e8400-e29b-41d4-a716-446655440000" } }
{ "type": "link", "attrs": { "file": "770e8400-e29b-41d4-a716-446655440002" } }hrefis an address: http, https, mailto, tel, or a relative path such as/impressum.javascript:and the like are refused, as on a link field.nodeis a page of this project, by uuid.fileis a file of this project, by uuid. A uuid that names nothing in the project is a422, and so is a mark with no target or two.
What is stored is exactly that: the address, or the uuid. What is read back is more, resolved on every read the way a link field's url and published are:
json
{ "type": "link", "attrs": {
"node": "550e8400-…", "href": "telescopes/the-aurora-array",
"title": "The Aurora Array", "published": true } }A page link gains href (its path from the project root, kept current when the page is re-slugged or moved; "" for the root), title and published. A file link gains href (the API's own download of the original, /file/{uuid}/original), title and published: true. A target that has since been deleted reads back with href: null and published: false. Send any of that back unchanged on a write; the derived keys are dropped and the uuid is kept, as are an editor's target, rel and class and any null-valued key - a link is stored as its target and nothing else.
published is the signal not to ship a dead link: a page that has no live root version is false, so a renderer drops the anchor and keeps the text. The HTML rendering (?richtext=html) does exactly that, and renders a file link's anchor against the API, which a site serving files from a CDN rewrites.
A string of markup is refused with a 422 naming the field:
json
{
"message": "body is a string. A Rich text value is a document - {\"type\": \"doc\", \"content\": [...]} - never a string of HTML or Markdown (ADR 0026). Declare the field as Long text (\"format\": \"text\") if it should hold plain text."
}and a malformed document names the node that is wrong, by its path inside the document:
json
{
"message": "body is not a well-formed Rich text document: content[1].content[0].marks[0] carries an unknown key \"href\"; a mark has type and attrs only."
}A frontend renders a document block by block, the way it renders slot children: one component per node type, text nodes with their marks. Tiptap and ProseMirror ship serializers that turn the same tree into HTML in the browser or in Node, if that is all a page needs.
Asking for HTML or plain text
A page that would rather not carry a renderer adds ?richtext=html to a read - GET /document/{uuid}, GET /content/{uuid}, and a library's entry listings - and every Rich text value in the response is its HTML rendering instead of the tree:
json
{
"_value": {
"title": "Hours",
"body": "<h2>Opening hours</h2><p>We are open <strong>daily</strong>, see the <a href=\"https://example.org/calendar\">calendar</a></p><ul><li><p>Mondays: closed</p></li></ul>"
}
}?richtext=text serves the plain text instead - the text nodes joined by a space, which is also what minLength/maxLength measure. ?richtext=document is the default, spelled out. Anything else is a 422 naming the three. Only Rich text values change; a Long text value, and a Rich text value written before documents existed, are strings and are served as they are.
The HTML is produced server-side by Tiptap's own PHP serializer with the same extension set the admin UI's editor can produce, so a block the editor can make is a block the rendering knows. Links render as a bare <a href>; what a site does with a link is the site's decision.
A Rich text value written before documents existed is a plain string, and reads back as that string. Nothing migrates it; the admin UI's editor parses it on first open and saves it as a document, and an API client that reads one back should do the same, because writing the string back is refused.
Schema Validation Rules
- Arrays must have an
itemsdefinition (empty arrays without item type are not supported) - Objects can restrict additional properties with
additionalProperties: false - Required fields are enforced when creating content
- Min/max constraints are validated
- A Text field's value may not exceed 255 characters; longer values belong in a Long text or Rich text field
- A Rich text field's value is a well-formed document, never a string
One kind per field
A field has exactly one storage kind - one of JSON Schema's seven types - because every value lands in one typed column. Every JSON Schema keyword is accepted; what a schema may not do is leave a field's kind undecided between two. The rule, applied to each field when the component is saved:
| You write | Flatnode stores it as |
|---|---|
{"type": "string"} | a string |
{"type": ["string", "null"]} | a string that may also be null |
{"type": ["integer", "number"]} | a number |
{"const": "card"} or {"enum": ["s", "m", "l"]} with no type | the kind of the values |
{"type": "string", "oneOf": [...]}, allOf, anyOf or not beside a type | that type; the combinator is a constraint the validator enforces |
{"oneOf": [{"type": "string", ...}, {"type": "string", ...}]} | a string; the validator picks the branch |
{"allOf": [{"properties": {...}}, {"properties": {...}}]} | one object with every branch's properties and the union of their required |
if / then / else on an object | the object; the conditional is enforced on every write |
Refused when the component is saved, with a 422 naming the field by JSON pointer:
{"oneOf": [{"type": "string"}, {"type": "integer"}]},{"type": ["string", "integer"]}or any other combination whose branches have different kinds. The message says which kinds, and that a choice between shapes is a slot - each shape its own component, composed in with a$ref, with its own versions.anyOforoneOfwith two object branches. Same reason: two shapes, one node.- A
constorenumwhose values are objects or lists, with notypebeside it. allOfwith a$refbranch. Extending another component inline is not supported yet; declare the properties.itemsas a list of positional schemas. A list holds entries of one kind.
json
{
"message": "data invalid.",
"data": {
"/properties/size": ["/properties/size stores one kind, but its oneOf branches are integer and string."]
}
}POST /validation refuses the same configurations the same way, keyed configuration.
The schema builder authors "may be empty" (a null beside the kind) and an enum list, and shows a field whose kind comes from a combinator's branches locked rather than editable - it is preserved as written, and edited on the JSON tab.
Null, absent and empty
A null written to a nullable field means the same as leaving the key out: the field is not set, and reads back as null. This is also what every optional field does, nullable or not.
An empty string is neither: it is a present value, and required is satisfied by it. A rule that means "if this field has text" is written with minLength, not required alone:
json
{
"if": { "properties": { "ctaLabel": { "minLength": 1 } }, "required": ["ctaLabel"] },
"then": { "required": ["ctaTarget"] }
}The admin's editor leaves a field it never saved out of a create, so an input typed into and cleared again is absent rather than ""; on an update "" is sent, because that is how a Text field is cleared.