Mojimoto Docs
Start free
Docs AI agents Content modelling guide for agents

Content modelling guide for agents

The rules to follow before creating a schema - formats, blocks for page sections, references for shared content and the mistakes to avoid.

Read this before you create or change a schema. It is written for coding agents, and for people who want the rules without the tour.

Every content type is a set of typed fields. Page sections go in a blocks field: an ordered list of typed sections stored inside the entry. Content shared between entries is linked with reference fields that point at other entries. There are no nested groups.

The requests on this page use the Content Management API. Its base is https://mojimoto.com/api/v1/{project}/manage, and every request carries Authorization: Bearer mjmt_your_write_token. The same operations exist as tools on the MCP server.

The rules in short

  1. Read the existing content model before you change it. Never guess a field id.
  2. Give every content type the right format: page, single or component.
  3. Put page sections in a blocks field.
  4. Put content that is shared between entries in its own entries, and link them with reference or references fields.
  5. Do not serialise a page structure, such as a Prismic slice zone, into a json field. It gets no validation, no editor UI and no media handling.
  6. Write every api id in snake_case.
  7. Upload a file before you write it into a media field.
  8. Saving is not publishing. Publish with a separate call, and expect field rules to be checked then.

Read the model first

Any of these returns the current model:

GET/api/v1/{project}/content-types
GET/api/v1/{project}/types

Over MCP, read the mojimoto://content-model resource or call list-content-types-tool.

Creating is never an overwrite. Creating a content type whose api_id is taken fails, and so does adding a field that already exists. That protects what a person set up by hand, so check what is there and work with it.

Choose a format for every content type

Every content type has a format. It decides how many entries the type has and whether they have a uid.

format What it is uid Entries
page A collection: many entries, browsed as a list. The default. Required, and unique within the type. It is the entry's URL slug. Many
single One entry, such as navigation or site settings. Forced to null. One. Creating a second is rejected.
component A building block edited inside its parent, such as a shared page section or a nav item. Hidden from the main content list and reached only through the entry that references it. Forced to null. Many
POST/api/v1/{project}/manage/content-types
json
{ "api_id": "site_settings", "label": "Site settings", "format": "single" }

Rules:

  • The legacy repeatable boolean does not control this. Setting repeatable: false alone does not make a single. Use format.
  • There is no kind or singleton parameter. Unknown parameters are rejected with a 422: Unknown parameter(s): kind. Accepted: api_id, label, format ("page" | "single" | "component"), icon.
  • A page type refuses an entry without a uid: A URL slug is required - "page" is a collection (format "page"), so each entry is addressed by uid. Only types with format "single" or "component" omit it.
  • A single type refuses a second entry: This single entry already exists.
  • Give a page type one slug field. Saving a value in it sets the entry's uid, so write the same string in both.

To fix a type made with the wrong format, send PUT /content-types/{type} with the new format. A type can become single only while it has at most one entry, and page only when every entry has a uid. A type's api_id cannot be changed: delete the type with DELETE /content-types/{type}, which is allowed only while it has no entries, and create it again.

Name everything in snake_case

Content type api ids, field ids, block type ids and the field ids inside blocks must all match ^[a-z][a-z0-9_]*$: a lowercase letter, then lowercase letters, digits and underscores. blog_post is valid. blogPost, blog-post and 2col are refused, for example with The api_id "blog-post" must be snake_case.

Always send a label in a field's config. It is what editors see.

Decide where each piece of content goes

The content Model it as
Many things of one kind, each with its own URL: pages, posts, products A page type. One entry each, with a uid.
One of something for the whole site: settings, navigation, footer A single type.
The sections of one page, in an order the editor chooses A blocks field on the page type.
A section or item reused on several pages: a shared call to action, a testimonial A component type, linked from a references field.
One thing an entry points at: a post's author, a product's category A reference field that allows the other content type.
A repeating group of fields A blocks field with one block type. There are no nested groups.
Data with no fixed shape that no editor will touch A json field. An escape hatch only.

Page sections with a blocks field

This is the page → sections pattern, and the default way to build a page. Model the page as a page type with a blocks field. The field's config.blocks maps each block type's api id to its label and fields.

Create the type:

POST/api/v1/{project}/manage/content-types
json
{ "api_id": "page", "label": "Page", "format": "page" }

Add the blocks field. This one has two block types, hero and quote:

POST/api/v1/{project}/manage/content-types/page/fields
json
{
  "field": "sections",
  "definition": {
    "type": "blocks",
    "config": {
      "label": "Sections",
      "blocks": {
        "hero": {
          "label": "Hero",
          "fields": {
            "heading": { "type": "symbol", "config": { "label": "Heading", "required": true } },
            "image": { "type": "media", "config": { "label": "Image" } }
          }
        },
        "quote": {
          "label": "Quote",
          "fields": {
            "text": { "type": "text", "config": { "label": "Text" } }
          }
        }
      }
    }
  }
}

Create an entry. The value of a blocks field is an ordered array of {"type", "data"}:

POST/api/v1/{project}/manage/documents
json
{
  "type": "page",
  "uid": "home",
  "data": {
    "sections": [
      { "type": "hero", "data": { "heading": "Welcome", "image": { "asset_id": 7, "fit": "cover" } } },
      { "type": "quote", "data": { "text": "The best bread in town." } }
    ]
  }
}

That answers 201 with {"id": 12, "uid": "home", "version_id": 31} and saves data as a draft. Publish it:

POST/api/v1/{project}/manage/documents/12/publish

The delivery API then returns each block as {"id", "type", "data"}, in order, with media expanded to the full asset:

json
{
  "id": 12,
  "uid": "home",
  "type": "page",
  "lang": "en-gb",
  "status": "published",
  "published_at": "2026-11-26T09:15:02+00:00",
  "updated_at": "2026-11-26T09:15:02+00:00",
  "data": {
    "sections": [
      {
        "id": "1d7f277f3b",
        "type": "hero",
        "data": {
          "heading": "Welcome",
          "image": {
            "id": 7,
            "url": "https://…/hero.jpg",
            "alt": "A loaf on a wooden board",
            "width": 2400,
            "height": 1200,
            "content_type": "image/jpeg",
            "fit": "cover"
          }
        }
      },
      {
        "id": "2aa9b6fea1",
        "type": "quote",
        "data": { "text": "The best bread in town." }
      }
    ]
  }
}

Rules for blocks

  • Field types. A block's fields may be symbol, text, rich_text, number, boolean, date, select, media, location or json. No references inside blocks yet, and no blocks inside blocks. A block that needs to point at another entry is a job for a references field on the page.
  • config.blocks is required. It is a map keyed by block type api id, never a list, and each block type needs at least one field.
  • min and max in the field's config limit how many blocks an entry may have. They are checked on publish.
  • Block data uses the same write formats as top-level fields. A media field in a block takes {"asset_id": 7, "fit": "cover"}, and a rich_text field takes a block array or an HTML string.
  • id is the render key. Send an id (any string) with a block to keep its key stable across edits. If you leave it out, one is derived from the block's position and content, so it can change when you rewrite the entry.
  • Changing the field replaces all of it. PUT /content-types/{type}/fields/{field} takes a whole new definition. To add one block type, send every existing block type as well.

What publishing checks in a blocks field

Publish errors name the block. The key is the block's position and the message is written for a person:

json
{
  "message": "Sections, block 1 (Hero): Heading is required.",
  "errors": {
    "sections.0.data.heading": ["Sections, block 1 (Hero): Heading is required."]
  }
}

A block of a type the field does not have fails under the key sections.0, with Sections, block 1: unknown block type. Use one of: hero, quote.

Shared sections with references

When a section is reused across pages, make it an entry of a component type and link it with an ordered references field. This is a different model from the one above, not a further step: here the page's sections field is a references field.

1. The section type. A component has no uid and is edited inside its parent.

POST/api/v1/{project}/manage/content-types
json
{ "api_id": "hero_section", "label": "Hero", "format": "component" }
POST/api/v1/{project}/manage/content-types/hero_section/fields
json
{ "field": "heading", "definition": { "type": "symbol", "config": { "label": "Heading" } } }
json
{ "field": "image", "definition": { "type": "media", "config": { "label": "Image" } } }

Fields are added one request at a time, so those are two requests to the same address.

2. The page type, a collection with an ordered sections field. content_types is the allow-list of types the field may link to.

POST/api/v1/{project}/manage/content-types
json
{ "api_id": "page", "label": "Page", "format": "page" }
POST/api/v1/{project}/manage/content-types/page/fields
json
{
  "field": "sections",
  "definition": {
    "type": "references",
    "config": { "label": "Sections", "content_types": ["hero_section"] }
  }
}

3. The content. Create and publish a section, then the page that references it.

POST/api/v1/{project}/manage/documents
json
{ "type": "hero_section" }

That answers {"id": 11, "uid": null}. Publish it with its content:

POST/api/v1/{project}/manage/documents/11/publish
json
{ "data": { "heading": "Welcome", "image": { "asset_id": 7, "fit": "cover" } } }

Now the page. Creating it answers {"id": 12, "uid": "home"}:

POST/api/v1/{project}/manage/documents
json
{ "type": "page", "uid": "home" }
POST/api/v1/{project}/manage/documents/12/publish
json
{ "data": { "sections": [11] } }

4. Delivery resolves the references, in order.

GET/api/v1/{project}/documents?type=page&uid=home&depth=2
json
{
  "results": [
    {
      "id": 12,
      "uid": "home",
      "type": "page",
      "lang": "en-gb",
      "status": "published",
      "published_at": "2026-11-26T09:15:02+00:00",
      "updated_at": "2026-11-26T09:15:02+00:00",
      "data": {
        "sections": [
          {
            "id": 11,
            "uid": null,
            "type": "hero_section",
            "lang": "en-gb",
            "status": "published",
            "published_at": "2026-11-26T09:14:40+00:00",
            "updated_at": "2026-11-26T09:14:40+00:00",
            "data": {
              "heading": "Welcome",
              "image": {
                "id": 7,
                "url": "https://…/hero.jpg",
                "alt": "A loaf on a wooden board",
                "width": 2400,
                "height": 1200,
                "content_type": "image/jpeg",
                "fit": "cover"
              }
            }
          }
        ]
      }
    }
  ],
  "page": 1,
  "per_page": 20,
  "total_results": 1,
  "total_pages": 1,
  "lang": "en-gb",
  "ref": "published"
}

Rules for reference fields

  • content_types is required on reference and references fields. Every type it lists must already exist in the project, so create the component type before the field that points at it.
  • The value is an entry id. A reference takes one id, such as 42. A references field takes an ordered array, such as [11, 12, 13]. The order is kept and is the render order.
  • Ids are checked on publish. Every entry must exist in the same project, or the publish fails with Sections references an entry that does not exist in this project. The entry's type is not checked against content_types, so link the right kind of entry yourself.
  • depth sets how far links are followed. It defaults to 1 and is clamped to 1 to 3. depth=1 resolves the sections themselves. Use depth=2 when sections have references of their own. media fields resolve to full asset objects at any depth.
  • Beyond the depth, a link collapses to a stub: {"id": 11, "type": "hero_section", "uid": null}.
  • A linked entry is only included when it has something to serve. Published content resolves published entries, and ref=preview resolves drafts too. If a reference comes back as a stub or with empty data, check that the linked entry was published and not only created.
  • Deleting a linked entry makes a reference to it resolve to null, and drops it from a references list.

Mistakes the API will not catch

These are accepted without an error, so they are yours to avoid.

  • A misspelt field id in data. A key that is not a field of the content type is stored and delivered as written, and the real field stays empty. Use the exact ids from the model.
  • Sending only the fields you changed. PUT /documents/{id} saves a new draft that is exactly the data you send. Fields you leave out are not carried over from the last draft, so send them all.
  • Expecting a draft to be checked. Field rules such as required, min, max and pattern are not enforced when you save a draft. They are enforced on publish, which answers 422 with an error for each field that fails.
  • An entry created without data. It has no versions yet. It is a 404 on the delivery API, and a reference to it resolves to a bare {"id", "type", "uid"} stub, until content is saved and published.
  • A page structure in a json field. It is accepted, and then has no validation, no editor UI and no media handling. Use a blocks field.

Before you write content

  • The write format of every field type is on the Field types page. The ones that catch agents out: a media field takes {"asset_id": 7, "fit": "cover"} after you upload the file, a raw image object is refused, and rich_text takes an array of blocks.
  • lang on a write has to be one of the project's locales. It defaults to the project's default locale. Naming a locale the project does not have is a 422 that lists the ones it has.
  • Every endpoint used here, with its parameters and responses, is in the Content Management API reference.
  • How blocks look in the editor and render on a site is on the Blocks page. How references resolve is on the Links page.
  • Moving a Prismic repository over has its own page: Importing from Prismic.

Something wrong or missing on this page? Tell us and we will fix it.

© 2026 Your Ikigai Ltd · Registered in England & Wales, no. 15274889 文 · モジモト