HTTP details
Rate limits, caching, ETags, CORS, pagination and every header the Mojimoto API sends, with the exact values to expect.
This page covers what sits around the JSON: the headers the API sends, how responses are cached, how many requests you can make and how browsers are allowed to call it. Read it when you are putting a cache in front of the API, when a publish is not showing up, or when you get a 429.
Add -i to any curl request to see the headers:
curl -i "https://mojimoto.com/api/v1/acme/documents?type=tag" \
-H "Authorization: Bearer mjmt_your_read_token"Content-Type: application/json
Cache-Control: max-age=0, public, s-maxage=60, stale-while-revalidate=86400
ETag: "fd072ebcff9704da30d75cbcdbb1fd06"
X-Mojimoto-Content-Version: 11
X-RateLimit-Limit: 300
X-RateLimit-Remaining: 299
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: ETagThose are the headers the API sets on a published response. Your client will show a few more that are added on the way, such as Date.
Requests
The API is served over HTTPS at one base URL, with the version in the path:
https://mojimoto.com/api/v1/{project}- Send the token in the
Authorizationheader asBearer mjmt_.... It is not read from the query string. See Authentication. - The Content Delivery API answers
GETandHEAD. AHEADrequest returns the same status and headers as theGET, with no body. - A method an endpoint does not take is a
405whose message lists the ones it does:The POST method is not supported for route api/v1/acme/documents. Supported methods: GET, HEAD. - A read needs no request body and no
Acceptheader. - In a query string, write
+as%2B. Square brackets can be sent as they are or as%5Band%5D.
Content type
Responses are Content-Type: application/json, encoded as UTF-8. Errors are JSON too, whatever the request asked for:
{
"message": "Missing API token. Provide it as a Bearer token in the Authorization header."
}A 422 adds an errors object keyed by the parameter at fault. Errors lists every status.
One endpoint does not return JSON. GET /api/v1/{project}/types returns a TypeScript file:
Content-Type: application/typescript; charset=utf-8
Content-Disposition: attachment; filename="mojimoto.generated.ts"Timestamps that the API adds, such as published_at and updated_at, are ISO 8601 in UTC with a +00:00 offset: 2026-03-02T09:14:07+00:00.
Rate limits
Requests are counted per minute. The window starts with your first request and lasts 60 seconds.
| API | Paths | Requests per minute |
|---|---|---|
| Delivery and preview | /api/v1/{project}/documents, /content-types, /assets, /types |
300 |
| Write | /api/v1/{project}/manage/... |
60 |
The count is kept per client IP address. The two rows are counted separately, and all the delivery endpoints share one count.
Every request that reaches one of these endpoints counts, including one answered with a 304 and one refused for a bad token. A response served from a cache never reaches the API, so it does not count. Preview responses are never cached, so every preview request counts.
Rate limit headers
Every response from these endpoints says where you stand:
| Header | Value |
|---|---|
X-RateLimit-Limit |
The number of requests allowed in the window. |
X-RateLimit-Remaining |
How many are left in the current window. |
Read the limit from the header and do not hard-code it.
When you go over
The next request in the same window is a 429, with two more headers:
| Header | Value |
|---|---|
Retry-After |
Seconds until the window ends and requests are accepted again. |
X-RateLimit-Reset |
The same moment, as a Unix timestamp. |
X-RateLimit-Limit: 300
X-RateLimit-Remaining: 0
Retry-After: 60
X-RateLimit-Reset: 1795695553{
"message": "Too Many Attempts."
}Wait for the number of seconds in Retry-After and try again. Do not retry straight away: a request made while you are over the limit is refused as well.
Failed tokens
There is a second, smaller limit on wrong tokens. Requests with a token that is not valid are counted per IP address, for a minute from the first one. A request with a valid token clears the count. Once the count reaches 30, every request from that address is a 429 with a different message, valid token or not, until that minute is up:
{
"message": "Too many failed authentication attempts. Try again later."
}This response has no Retry-After header.
Caching
How a response may be cached depends on what it is.
| Response | Cache-Control |
ETag |
|---|---|---|
| Published entries, content types and assets | max-age=0, public, s-maxage=60, stale-while-revalidate=86400 |
Yes |
| Preview responses, and published content served because the token could not preview | no-store, private |
No |
| Entries and content types sent to a token that is limited to some content types | no-store, private |
No |
| Generated types, and every error | no-cache, private |
No |
What the published policy means
Cache-Control: max-age=0, public, s-maxage=60, stale-while-revalidate=86400| Part | Meaning |
|---|---|
max-age=0 |
A browser's own cache treats the response as out of date straight away, so it checks with the API instead of trusting its copy. |
public, s-maxage=60 |
A shared cache, such as a CDN, may serve the response to anyone for 60 seconds without asking the API. |
stale-while-revalidate=86400 |
A cache that supports this may answer with its out-of-date copy while it fetches a new one in the background, for up to a day after the copy went out of date. |
Three things follow from it:
- A publish can take up to 60 seconds to appear at a URL a shared cache already holds. Where a cache serves its old copy while it refreshes, one more request after that can still get the old response.
- A cached response is served without the token being checked. Shared caches store by URL, not by
Authorizationheader. Published content is treated as public, which is why the public read token is safe to ship. Anything that depends on the token is sentno-store. - The URL is the cache key. The same query with its parameters in another order is a different URL and is cached separately. Build your URLs the same way every time.
ETag and conditional requests
Cacheable responses carry an ETag. Send it back in If-None-Match to ask whether anything has changed:
curl -i "https://mojimoto.com/api/v1/acme/documents?type=tag" \
-H "Authorization: Bearer mjmt_your_read_token" \
-H 'If-None-Match: "fd072ebcff9704da30d75cbcdbb1fd06"'When nothing has changed the answer is 304 Not Modified, with the headers and no body:
Cache-Control: max-age=0, public, s-maxage=60, stale-while-revalidate=86400
ETag: "fd072ebcff9704da30d75cbcdbb1fd06"
X-Mojimoto-Content-Version: 11
X-RateLimit-Limit: 300
X-RateLimit-Remaining: 298Use the copy you already have. When something has changed you get a 200 with the new body and a new ETag. A 304 is quick, because the API answers it before it loads any content, but it still counts towards the rate limit.
If-None-Match also accepts a weak validator (W/"...") and a list of several values.
What changes an ETag
An ETag is made from two things: the request URL, exactly as it was sent, and a version of the data behind it. It does not depend on the token. The version is in the X-Mojimoto-Content-Version header:
| Endpoint | Version | Example | Moves when |
|---|---|---|---|
| Entries | The project's content version | 11 |
Anything in the project is published. |
| Entries, in a locale that has fallbacks | The content version and the fallback chain | 13:fr-fr>en-gb |
Anything is published, or the locale's fallbacks are changed. |
| Content types | The number of content types and the time of the newest change | model:6:2026-02-10 09:58:30 |
A content type is added, changed or removed. |
| Assets | The number of assets and the time of the newest change | assets:2:2026-02-27 16:45:12 |
An asset is uploaded, changed or removed. |
The content version belongs to the whole project. Publishing one entry changes the ETag of every entry URL in the project, because an entry can be included in the responses of the entries that link to it.
If a publish does not show up, compare X-Mojimoto-Content-Version between two requests. A number that has gone up means the API has the new content and a cache in between is still serving the old response.
Note: Only a publish is sure to move the content version. Unpublishing or deleting an entry, or changing the alt text of an asset an entry uses, can leave it where it was. A cache that revalidates with
If-None-Matchthen keeps getting a304for the old response until the next publish in the project.
CORS
Browsers can call the API from any origin.
| Header | Value | Meaning |
|---|---|---|
Access-Control-Allow-Origin |
* |
Any site may read the response. |
Access-Control-Expose-Headers |
ETag |
The only header beyond the standard set that browser JavaScript can read. |
Cookies are not used and credentials are not allowed. Access comes from the token in the Authorization header, not from the origin of the page.
Sending an Authorization header from a browser makes it ask permission first, with an OPTIONS request. The API answers that with a 204:
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET
Access-Control-Allow-Headers: authorization, if-none-match
Access-Control-Max-Age: 0The methods and headers are the ones the browser asked for. This request needs no token and is not counted against the rate limit. Access-Control-Max-Age: 0 tells the browser not to remember the answer, so each cross-origin call is two requests: the OPTIONS and the call itself.
From browser JavaScript on another origin you can read ETag, Cache-Control and Content-Type. You cannot read the X-RateLimit headers, Retry-After, X-Mojimoto-Content-Version or X-Mojimoto-Preview. Read those on a server.
A token in browser code is visible to everyone who opens the page. The public read token is made for that. A preview or write token is not.
Pagination
The lists of entries and assets are paged by number, with the same two parameters and the same envelope.
| Parameter | Default | Limits |
|---|---|---|
page |
1 |
Starts at 1. A lower value becomes 1. |
per_page |
20 |
1 to 100. A value outside that range is brought to the nearest end. |
curl "https://mojimoto.com/api/v1/acme/documents?type=post&page=9" \
-H "Authorization: Bearer mjmt_your_read_token"{
"results": [],
"page": 9,
"per_page": 20,
"total_results": 3,
"total_pages": 1,
"lang": "en-gb",
"ref": "published"
}That is a page past the end: an empty results, a 200, and the totals still filled in. total_pages is never less than 1. lang and ref are only on a list of entries.
There are no cursors, no Link headers and no pagination headers: everything is in the body. The content types endpoint returns the whole model in one response and is not paged. The Content Delivery API page has a worked example under "Collections and pagination".
Response headers
Every header the API adds, in one place.
| Header | Sent on | Value |
|---|---|---|
Content-Type |
Every response with a body | application/json, or application/typescript; charset=utf-8 for generated types. |
Cache-Control |
Every response | See Caching. |
ETag |
Published entries, content types and assets | A quoted hash to send back in If-None-Match. |
X-Mojimoto-Content-Version |
The same responses as ETag |
The version the ETag was made from. |
X-Mojimoto-Preview |
A ref=preview request whose token cannot preview |
denied - token lacks the "preview" ability, serving published content |
X-RateLimit-Limit |
Every request that matches an endpoint | Requests allowed per minute. |
X-RateLimit-Remaining |
Every request that matches an endpoint | Requests left in the window. |
Retry-After |
A 429 from the rate limit |
Seconds to wait. |
X-RateLimit-Reset |
A 429 from the rate limit |
When the window ends, as a Unix timestamp. |
Content-Disposition |
Generated types | attachment; filename="mojimoto.generated.ts" |
Access-Control-Allow-Origin |
Every response | * |
Access-Control-Expose-Headers |
Every response except the answer to OPTIONS |
ETag |
Something wrong or missing on this page? Tell us and we will fix it.