Mojimoto Docs
Start free
Docs API reference Authentication

Authentication

How API tokens work - where to create one, how to send it, what each ability allows and what you get back when a token is refused.

Every request to the Mojimoto API carries an API token. A token belongs to one project and has abilities that say what it may do there: read published content, read drafts, or write. You send it in the Authorization header.

terminal
curl https://mojimoto.com/api/v1/acme/documents \
  -H "Authorization: Bearer mjmt_your_read_token"

The same tokens work on the Content Delivery API, the Content Management API and the MCP server.

Send a token

Put the token in the Authorization header as a Bearer token:

text
Authorization: Bearer mjmt_your_read_token

The header is the only place a token is read from. A token in the query string, or sent as HTTP Basic auth, is not seen, and the request is answered as if it had no token:

Response 401
{ "message": "Missing API token. Provide it as a Bearer token in the Authorization header." }

A token is mjmt_ followed by 48 letters and digits. Mojimoto stores only a hash of it, so a token cannot be shown again after it is created.

Create a token

Tokens are made in the dashboard, by a project admin or owner.

  1. Open the project and choose API keys in the sidebar, under Developer.
  2. Under Custom tokens, give the token a name. Tick preview or write if it needs more than reading.
  3. Choose Create token and copy the token straight away. It is shown once.

A few things to know:

  • Name a token after what will use it, such as Production site or Import script. Everything a token writes is recorded under that name.
  • A project can hold 20 custom tokens on the Free, Starter and Pro plans. Enterprise has no limit.
  • The bin icon next to a token revokes it. A revoked token gets Invalid API token.
  • The page shows each token's abilities, any limits on it, who created it and when it was last used. Last use is recorded at most once a minute.

The public read token

Every project comes with a public read token. It has the read ability and nothing else, it is shown in full on the API keys page whenever you need it, it cannot be revoked, and it does not count towards the 20.

Use it for a website or build that only reads published content. The MCP server does not accept it.

Abilities

An ability is what a token is allowed to do. Every token can read. preview and write are added on top when you create it.

Ability What it allows
read The whole Content Delivery API: published entries, content types, the media library and generated TypeScript types.
preview Drafts on the Delivery API, by adding ref=preview to a request.
write The Content Management API, which is every path under /manage, and the write tools of the MCP server.

write does not include preview. A token needs the preview ability itself to read drafts with ref=preview.

Asking for ref=preview with a token that cannot preview is not an error. You get published content with a 200, and this response header tells you why. See the preview reference.

text
X-Mojimoto-Preview: denied - token lacks the "preview" ability, serving published content

Calling an endpoint without the ability it needs is a 403:

terminal
curl -X POST https://mojimoto.com/api/v1/acme/manage/documents \
  -H "Authorization: Bearer mjmt_your_read_token" \
  -H "Content-Type: application/json" \
  -d '{"type": "post", "uid": "hello-world"}'
Response 403
{ "message": "Token lacks the \"write\" ability." }

Limit what a write token can do

When you tick write, the form shows What it can do, with five operations. All five are ticked to begin with. Untick the ones the token should not have.

Operation Label in the dashboard Endpoints it covers
draft Create and edit drafts Create an entry, save a draft
publish Publish and unpublish Publish an entry, unpublish an entry
delete Delete entries Delete an entry
upload Upload media Upload an asset
model Change content models Create, update and delete a content type. Add, update and remove a field.

Listing content types and listing entries need only the write ability.

A request for an operation the token does not have is a 403 that names it:

Response 403
{ "message": "This token isn't allowed to publish and unpublish. Ask a project admin for a token with that permission." }

A token that can save drafts but not publish suits an import script or an AI agent whose work a person should check first.

Limit a token to content types

The same form has a Content types list for a write token. Tick the types the token may work with. Leave them all unticked and it can work with every type.

A token limited to post behaves like this:

Request Result
Management API: write to an entry, a field or a content type other than post, or create a new content type 403 with This token can only work with these content types: post.
Management API: list content types or entries Only post and its entries are returned.
Management API: upload an asset Allowed.
Delivery API: list entries Entries of other types are left out.
Delivery API: one entry or one content type of another type 404
Delivery API: the media library 403. Media used in post entries still comes with those entries.

Delivery responses to a limited token are marked private and no-store in Cache-Control, so a shared cache never hands them to another caller.

When a token is refused

A request is checked in this order, and the first check that fails decides the answer.

Check Status Message
The project in the path does not exist 404 No query results for model [App\Models\Project] nope
No Bearer token in the Authorization header 401 Missing API token. Provide it as a Bearer token in the Authorization header.
Too many wrong tokens from your IP address 429 Too many failed authentication attempts. Try again later.
The token is not one Mojimoto knows, or it was revoked 401 Invalid API token.
The token belongs to a different project from the one in the path 403 Token does not belong to this project.
The token lacks the ability the endpoint needs 403 Token lacks the "write" ability.
The project's subscription ended and its 30-day grace period has passed 402 Subscription required. The project's subscription ended and its 30-day grace period has passed - renew it to restore API access.
The token is limited, and the operation or content type is outside its limits 403 See the two sections above.

Every one of these is JSON with a single message key. Errors covers the format and every other status.

Too many wrong tokens

After 30 requests with an unknown token from one IP address inside a minute, every request that carries a token from that address gets a 429, valid tokens included, until the minute is over. A request with a valid token resets the count before it gets that far.

If you see this, something is sending a wrong or revoked token in a loop. Fix the token, then wait a minute.

A token for the wrong project

A token only works on the project it was made in. The project in the URL has to be that project, by its slug or its id. A token from one project sent to another gets a 403 and nothing is read or written, so a script that works across several projects needs one token per project.

Keep write tokens out of browsers

The API answers requests from any website, so the token is the only thing between a caller and your content. Anything in browser code can be read by whoever opens the page.

  • A read token reaches published entries, the content model and the media library, and nothing else. Treat all of that as public. A read token is fine in a front end, and the public read token exists for that.
  • A write token can change and delete content. A preview token can read drafts nobody has approved. Keep both on a server: in an environment variable, read by a build script, a server route or a job.
  • Do not put a write or preview token in client-side JavaScript, in a mobile app bundle or in a repository.
.env
MOJIMOTO_WRITE_TOKEN=mjmt_your_write_token

Three habits limit the damage if a token does leak:

  1. Give each script, site and agent its own token, so you can revoke one without breaking the rest.
  2. Give a write token only the operations and content types it needs.
  3. Revoke a token you suspect has leaked, then create a new one. A revoked write or preview token is refused from its next request.

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

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