Batch post reads
Anyone rewriting or auditing hundreds of posts should not make one call per post. batch-read returns up to 50 posts per call, each in the same shape as the public detail GET /v1/posts/{ref}.
Routes and scope
Section titled “Routes and scope”| Route | Credential |
|---|---|
POST /v1/posts/batch-read |
Site key or a site grant. |
POST /v1/sites/{site}/posts/batch-read |
Company key or company grant; {site} is checked against the credential’s company. |
- Scope:
posts:read. batch-readis a static route sibling of/posts/{ref}: a post whose slug is literallybatch-readcan only be reached by id onGET. Always usePOSTfor the batch.
Request
Section titled “Request”POST /v1/sites/{site}/posts/batch-readAuthorization: Bearer ck_...Content-Type: application/json
{ "refs": ["01J9Z3...", "how-to-choose-a-laptop", "9b2f1c3e-..."] }refs is a list of ids (ULID or UUID) or slugs. The body accepts only refs; any other field is 400.
Validation rules, in the order the server applies them:
- Each ref is trimmed; blank ones are ignored.
- Repeated refs are ignored (first occurrence order wins) and cost no quota.
- Each ref is at most 200 bytes.
- After cleaning: at least 1 and at most 50. The server never truncates silently.
| Problem | Status | Message |
|---|---|---|
| No valid ref | 400 | refs is required: a list of post ids or slugs |
| More than 50 distinct refs | 400 | refs accepts at most 50 posts per request |
| Ref over 200 bytes | 400 | each ref must have at most 200 bytes |
Response
Section titled “Response”200 with Cache-Control: private, no-store:
{ "items": [ { "ref": "how-to-choose-a-laptop", "post": { "id": "...", "slug": "how-to-choose-a-laptop", "content_html": "<p>...</p>" } } ], "errors": [ { "ref": "01J9Z3...", "code": "POST_NOT_FOUND", "message": "post not found" } ]}items: one element per ref found, in the order ofrefs.refis the text you sent (trimmed);postis the same object as the public detail, with rendered, sanitizedcontent_html(never raw blocks).errors: one element per ref that did not come out. It does not fail the batch.
Codes in errors[]:
code |
message |
When |
|---|---|---|
POST_NOT_FOUND |
post not found |
The ref does not exist on this site, or the post is not published, or it belongs to another site, or the post type is outside your grant’s restriction. Draft, scheduled and restricted answer the same as nonexistent. |
UPSTREAM_UNAVAILABLE |
upstream service unavailable |
The content service failed for that item. Retry only those refs later. |
Only published (live) posts are returned. To read drafts use GET /posts/{ref}/source (see API v2) or the pending routes.
Whole batch down
Section titled “Whole batch down”If no item came out and every error is UPSTREAM_UNAVAILABLE, the response is 502 (UPSTREAM_UNAVAILABLE, upstream service unavailable), not 200. A batch with empty items and some POST_NOT_FOUND is still 200.
Quota: 1 unit per item
Section titled “Quota: 1 unit per item”Authentication charges 1 unit for the call and the batch charges the remaining N - 1 before reading any post: a batch of N distinct refs costs N read units. It does not matter whether the ref exists.
| Credential | Where the cost comes from | Detail |
|---|---|---|
OAuth grant (cvt_) |
The grant’s read quota: 600/min, burst 60 | A 50-ref batch fits in the burst. The extra items come only from the grant; the app bucket pays just the call’s 1 unit. |
Company key (team ck_) |
The key’s bucket: 600/min, burst 100 | Fails closed (503) if the limiter is down. |
Site key (ck_) |
The key’s in-memory bucket: 60/min | A 50-ref batch spends 50 of the minute’s 60. If the bucket runs out mid-charge, it is 429. |
Over quota: 429 with Retry-After, and nothing is read. The RateLimit-Policy and RateLimit headers show what remains (see Rate limits).
Client pattern
Section titled “Client pattern”- Group refs in blocks of up to 50.
- Read
itemsanderrors. Refs inPOST_NOT_FOUNDare not worth retrying; refs inUPSTREAM_UNAVAILABLEgo into a later batch. - On
429, waitRetry-Afterbefore the next batch; with a site key, space batches out (50 items per minute of remaining quota). - Reads are safe to repeat: no side effects and no need for an Idempotency-Key.
For metrics on several posts at once, see Analytics per post.