Entries and publishing
The life of an entry - its uid, drafts and versions, publishing and what is checked, unpublishing, scheduled publishing and deleting.
An entry is one piece of content: one post, one author, the site settings. The API calls it a document.
You create an entry, save drafts as often as you like, and publish when it is ready. Only published content is on the read API, and field rules are checked when you publish.
/api/v1/{project}/manage/documents/api/v1/{project}/manage/documents/{id}/api/v1/{project}/manage/documents/{id}/publish/api/v1/{project}/manage/documents/{id}/unpublish/api/v1/{project}/manage/documents/{id}All five need a write token, which can be limited to drafts, publishing or deleting. See Authentication.
Create an entry
curl -X POST https://mojimoto.com/api/v1/acme/manage/documents \
-H "Authorization: Bearer mjmt_your_write_token" \
-H "Content-Type: application/json" \
-d '{"type": "post", "uid": "hello-world", "data": {"title": "Hello world", "slug": "hello-world"}}'{ "id": 42, "uid": "hello-world", "version_id": 118 }id is the entry's permanent number, used by every later call. data is optional and is saved as the first draft.
Note: An entry created without
datahas no content yet. The read API answers404for it, even under preview, until a draft is saved.
The uid
The uid is an entry's slug: the readable handle your site puts in a URL and fetches with ?type=post&uid=hello-world.
| Format | uid |
|---|---|
page (collection) |
Required when the entry is created. Unique within the content type. |
single, component |
Always null. A uid you send is ignored. |
Creating a collection entry without a uid, or with one that is taken, is a 422.
No call sets uid after creation. A slug field does it instead: saving or publishing with a new value in the field moves the uid to match.
Drafts and versions
An entry keeps its content in versions. A version belongs to one locale and is either a draft or published. The read API serves the newest published version in the locale you ask for. Preview serves the newest version of either kind.
curl -X PUT https://mojimoto.com/api/v1/acme/manage/documents/42 \
-H "Authorization: Bearer mjmt_your_write_token" \
-H "Content-Type: application/json" \
-d '{"data": {"title": "Hello again", "slug": "hello-world"}}'{ "version_id": 119, "status": "draft" }When you save a draft:
datais the whole entry, not a patch. A field you leave out is gone from the new draft.- Each
PUTadds a new draft version. The app's editor saves as you type into one working draft between publishes. - Field rules such as
requiredare not checked. A draft is still refused for alangthe project does not have, a slug another entry is using, or a media value in the wrong shape.
Saving a draft over a published entry changes nothing on the read API. The app marks the entry "Unpublished changes" until you publish, and Discard changes goes back to the published version.
To read drafts back, use preview on the read API, or GET /api/v1/{project}/manage/documents, which lists every entry with its working draft.
Add "lang": "fr-fr" to any of these calls to work on another locale. Each locale is drafted and published on its own.
Publish
curl -X POST https://mojimoto.com/api/v1/acme/manage/documents/42/publish \
-H "Authorization: Bearer mjmt_your_write_token"With no body, this publishes the newest draft. Send data to publish that content in one step instead. The response is the published entry exactly as the read API returns it.
Publishing fires the document.published webhook. Published responses are cached at the edge for 60 seconds, so a site can be that far behind. See HTTP details.
In the app the button is Publish to site, and it offers to publish linked entries that are not live at the same time.
What is checked at publish
If any field breaks a rule in its config, nothing is published and the response is a 422 naming each field.
{
"message": "Title is required.",
"errors": {
"title": ["Title is required."]
}
}| Check | Field types | Message |
|---|---|---|
required |
All | Title is required. |
min, max length |
symbol, text, slug, select |
Title must be at most 80 characters. |
pattern |
symbol, text, slug, select |
Code is not in the expected format. |
min, max value |
number |
Price must be at least 0. |
| The linked entry exists in this project | reference, references |
Author references an entry that does not exist in this project. |
| The file exists in this project | media |
Cover links to a file that does not exist in this project. |
| Block count, block types and each block's fields | blocks |
Sections, block 2 (Hero): Heading is required. |
An empty field is checked for required and nothing else. null, an empty string and an empty array are empty. false and 0 are not.
When a locale falls back to another, a required field counts as filled if the fallback locale has published a value for it.
Unpublish
Unpublishing takes one locale of an entry off the read API and keeps its content as a draft.
curl -X POST https://mojimoto.com/api/v1/acme/manage/documents/42/unpublish \
-H "Authorization: Bearer mjmt_your_write_token"{ "unpublished": true, "id": 42, "lang": "en-gb" }After this the read API answers 404 for the entry in that locale, and a link to it from another entry comes back as a stub without data. The document.unpublished webhook fires. Unpublishing a locale that is not published is a 422.
Unpublish is on the API and the MCP server only.
Schedule a publish
Scheduling is done in the app. Pick a date and time in the entry editor and choose Schedule publish.
- The entry is checked when you schedule it and again when the time comes. If it is no longer valid then, nothing is published and the schedule is marked failed with the reason.
- What goes live is the newest draft at that moment, so you can keep editing.
- An entry has one pending schedule per locale. Scheduling again replaces it, and Cancel schedule removes it.
- Linked entries that are not live can be scheduled with it. They move and cancel with it.
Due schedules are picked up once a minute. There is no API endpoint or MCP tool for scheduling.
Delete
curl -X DELETE https://mojimoto.com/api/v1/acme/manage/documents/42 \
-H "Authorization: Bearer mjmt_your_write_token"{ "deleted": 42 }Deleting removes the entry, every version in every locale and any pending schedule. It cannot be undone. Links that pointed at the entry come back as null, or drop out of a list. If the entry was published, the document.deleted webhook fires.
Something wrong or missing on this page? Tell us and we will fix it.