Content model
How a project's content is structured - content types and their formats, groups of fields, the schema JSON, API ids and what a schema change does to entries.
A content model is the set of content types in a project. A content type describes one kind of entry: a blog post, an author, the site settings. It names the fields an entry has and what each field holds.
You build the model under Content model in the app, or over the write API or the MCP server. A change takes effect as soon as it is saved.
Read the model
The read API returns the model to any token. A token limited to certain content types sees only those.
/api/v1/{project}/content-typescurl https://mojimoto.com/api/v1/acme/content-types \
-H "Authorization: Bearer mjmt_your_read_token"{
"content_types": [
{
"api_id": "post",
"label": "Post",
"format": "page",
"repeatable": true,
"schema": {
"Main": {
"title": { "type": "symbol", "config": { "label": "Title", "required": true } },
"slug": { "type": "slug", "config": { "label": "Slug" } },
"body": { "type": "rich_text", "config": { "label": "Body" } }
},
"SEO": {
"meta_description": { "type": "text", "config": { "label": "Meta description", "max": 160 } }
}
}
}
]
}GET /api/v1/{project}/content-types/post returns one content type as the same object.
| Field | Description |
|---|---|
api_id |
The type's name in the API. It is the type of every entry. |
label |
The name people see in the app. |
format |
page, single or component. See the next part. |
repeatable |
An older flag. It decides nothing. Use format. |
schema |
The fields, arranged in groups. |
Collection, single or component
Every content type has a format. It decides how many entries the type can have and whether they have a uid.
format |
Name in the app | Entries | uid |
|---|---|---|---|
page |
Collection | Many | Required, and unique within the type |
single |
Single | Exactly one | Always null |
component |
Component | Many | Always null |
A collection is for content you list and address by slug: posts, pages, team members. It is the default.
A single is the one thing of its kind: navigation, site settings. A second entry is refused with This single entry already exists.
A component is a building block other entries link to, such as a call to action shared by several pages. Its entries are hidden from the main content list in the app and reached through the entries that link to them.
You can change a format later. Changing to single is refused while the type has more than one entry, and changing to page is refused while any entry has no uid.
Groups of fields
The top level of schema is a list of groups, called tabs in the API. A group is a heading in the entry editor and nothing more. An entry's data is flat, so a field id has to be unique across the whole content type.
A new content type has one empty group called Main. Adding a field with a tab that does not exist yet creates that group. Reordering fields and moving them between groups is done in the app.
Note: A group with no fields in it comes back as an empty array (
"Main": []), not an empty object.
Fields
Each field is a definition with two keys.
{ "type": "symbol", "config": { "label": "Title", "required": true, "max": 80 } }type is one of the fourteen field types. config holds the label, validation rules and options. Two types build structure: reference fields link to other entries, and a blocks field holds ordered sections inside the entry.
API ids
Content type ids, field ids and block type ids all follow one rule: lower case letters, digits and underscores, starting with a letter. blog_post and hero_image_2 are valid. blogPost, blog-post and 2col are not.
An id is permanent: a content type's api_id cannot be changed and a field cannot be renamed. Removing a field and adding one with a new id gives you a new, empty field. In the app, a field's id is made from its label, so "Hero image" becomes hero_image.
Change the model over the API
Model changes need a token with the write ability. They are made one field at a time, so a script cannot overwrite a field somebody else added a moment ago.
/api/v1/{project}/manage/content-types/api/v1/{project}/manage/content-types/{type}/api/v1/{project}/manage/content-types/{type}/api/v1/{project}/manage/content-types/{type}/fields/api/v1/{project}/manage/content-types/{type}/fields/{field}/api/v1/{project}/manage/content-types/{type}/fields/{field}Create a content type, then add a field to it:
curl -X POST https://mojimoto.com/api/v1/acme/manage/content-types \
-H "Authorization: Bearer mjmt_your_write_token" \
-H "Content-Type: application/json" \
-d '{"api_id": "author", "label": "Author", "format": "page"}'{ "api_id": "author", "schema": { "Main": [] } }curl -X POST https://mojimoto.com/api/v1/acme/manage/content-types/author/fields \
-H "Authorization: Bearer mjmt_your_write_token" \
-H "Content-Type: application/json" \
-d '{"field": "name", "definition": {"type": "symbol", "config": {"label": "Name", "required": true}}}'The response is the api_id and the whole schema after the change. Adding a field that already exists is a 422. PUT on a field replaces its whole definition, so send the complete config. A change that would make the schema invalid is refused with a 422 that says why. See the management API reference.
How a schema change affects entries
Changing the model never rewrites existing entries. Stored values stay as they are, and the read API shapes them with the schema as it stands at the time of the request.
| Change | What happens to existing entries |
|---|---|
| Add a field | A media or reference field is null and a references or blocks field is []. A field of any other type is missing from data until the entry is saved with it. |
Make a field required, or add min, max or pattern |
Published entries stay published. The rule is checked the next time each entry is published. |
| Remove a field | The stored value stays and is still returned in data as stored: a reference as a bare id, media as { "asset_id": 7, "fit": "cover" }. To clear it, save the entry over the write API without that key. |
| Change a field's type | Stored values are not converted. Rewrite the entries that need it. |
| Remove a block type from a blocks field | Blocks of that type are still returned, as stored. The entry cannot be published again until they are removed. |
| Change which content types a reference allows | Existing links stay. |
| Delete a content type | Refused with a 422 while the type has any entries. Delete the entries first. |
So treat a missing key as an empty field in your front end, and generate your TypeScript types again after a model change.
Something wrong or missing on this page? Tell us and we will fix it.