Write many pages at once
Applies many page writes and deletions together. Everything in a batch lands or nothing does, so a failure anywhere leaves the site exactly as it was.
POST https://sitepaste.com/api/v1/public/sites/{siteId}/pages/batch
Requires the content scope.
Entries upsert: a page that already exists is updated in place, so a script can send its full content tree on every run. To create a single page and be told when it already exists, use POST /sites/{siteId}/pages.
Saving pages does not publish them. Deploy the site with POST /sites/{siteId}/deployments once the batch has landed.
Usage
curl -X POST https://sitepaste.com/api/v1/public/sites/default/pages/batch \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"pages": [
{
"title": "Getting started",
"slug": "getting-started",
"content": "# Getting started\n\nWelcome to the docs.",
"contentType": "docs",
"tags": ["tutorial"]
}
]
}'
Send Content-Type: application/json with the payload as the body (up to 100 MB), or multipart/form-data with the JSON in a payload field (up to 10 MB, with the files as their own parts alongside it, and up to 100 MB for the whole request). Each limit answers 413 when exceeded. See inline media.
Authorizations
| Header | Type | Required | Description |
|---|---|---|---|
| Authorization | string | Yes | Bearer token (Authorization: Bearer sp_...). Created in the dashboard under Account > Tokens. See authentication. |
Body
| Field | Type | Required | Description |
|---|---|---|---|
| pages | array | Yes | Page objects to write (max 5,000). An empty array is allowed for a deletions-only request. |
| deleteSlugs | array | No | Pages to delete in the same request (max 5,000). See Deletions. |
A single page object sent here, without the envelope, is a 422 naming pages. Send it to the collection instead.
The site is named in the path, not the body.
Page fields
Each entry in pages takes the page fields and the theme overrides the single create takes, plus id, which addresses a page that already exists.
| Field | Type | Required | Description |
|---|---|---|---|
| id | string | No | Page ID (short ID). Looks the page up by ID so any field, including slug, can be updated. |
Every field except the identifier is optional on updates, and an omitted field keeps its existing value. A batch may carry at most 20 distinct password values.
Page identification
There are three ways for an entry to identify its page:
By id: provide id. The page is looked up directly, so you can update any field including slug. This is how you rename a slug. If the ID does not match a page in the target site, the request fails.
{"id": "k3m9x2q7r4pz", "slug": "new-slug", "title": "Renamed page"}
By slug: provide slug without id. If a page with that slug exists (within the same content type and section), it is updated. If not, a new page is created and title is required.
{"slug": "my-page", "draft": true}
Auto: omit both. A slug is generated from title, which is required. If a page with the generated slug exists, it is updated.
{"title": "My new post", "content": "Hello world"}
Partial updates
Send only the fields you want to change; everything else is preserved.
{"pages": [{"slug": "my-page", "draft": true}]}
This flips the draft status without touching the title, content, tags, or anything else.
Sections
A section groups pages under a shared path: /docs/my-section/my-page for docs and blog, /my-section/my-page for standalone. A standalone section may nest one level by joining two names with a slash (api/builds publishes at /api/builds/my-page); docs and blog sections cannot nest. Typed casing is captured as the section’s display name where none is set yet: API/Builds publishes at /api/builds and displays as API. Some names are reserved for standalone section roots. See Sections.
Tags
Tags are stored lowercased, with each run of spaces and hyphens as one hyphen, so machine learning and machine-learning are the same tag. What you typed is captured as the tag’s display name where none is set yet: iOS is stored as ios and displays as iOS, and Machine Learning is stored as machine-learning and displays as Machine Learning. When tags is present, it replaces all existing tags; an empty array removes them; omitted, existing tags are kept.
Deletions
Use deleteSlugs to delete pages in the same request that creates and updates others. Each entry requires slug and contentType, plus section if the page has one. A malformed slug, section, or content type is a 422 keyed by the entry’s index, and nothing in the batch is written. An entry with "contentType": "homepage" is a 422 too, because the homepage cannot be deleted (see delete a page). Well-formed entries that match no existing page are ignored.
{
"pages": [{"title": "New post", "content": "Hello"}],
"deleteSlugs": [
{"slug": "old-post-1", "contentType": "blog"},
{"slug": "old-post-2", "contentType": "docs", "section": "guides"}
]
}
A slug cannot appear in both pages and deleteSlugs. One request can delete the page at /api/builds and create pages in a new api/builds section.
Response
{
"pages": [
{
"id": "k3m9x2q7r4pz",
"slug": "getting-started",
"title": "Getting started",
"contentType": "docs",
"section": "guides",
"draft": false,
"status": "created",
"createdAt": "2026-02-08T12:00:00Z",
"updatedAt": "2026-02-08T12:00:00Z"
}
],
"deleted": ["old-post-1"],
"media": [
{"filename": "sunset.jpg", "url": "/media/.../a1b2c3d4.webp"}
]
}
| Field | Type | Description |
|---|---|---|
| pages[].id | string | Short page ID. Use it for ID-based updates, including slug renames. |
| pages[].slug | string | URL slug as saved. |
| pages[].title | string | Page title as saved. |
| pages[].contentType | string | blog, docs, standalone, or homepage. |
| pages[].section | string | Only when the page has a section. |
| pages[].description | string | Only when the page has a meta description. |
| pages[].apiEndpoint | string | Only on API reference pages. |
| pages[].draft | boolean | Whether the page is kept off the deployed site. |
| pages[].status | string | created or updated, per page. |
| pages[].createdAt | string | RFC 3339. |
| pages[].updatedAt | string | RFC 3339. |
| deleted | array | Slugs actually deleted. Only when deleteSlugs matched pages. |
| media | array | One {filename, url} per uploaded inline file. Only on multipart requests with files. |
Errors
Validation errors return 422 and name the page index and field:
{
"error": "validation failed",
"code": "validation_failed",
"pages": {
"0": { "title": "title is required for new pages" }
}
}
Entry problems are keyed by the entry’s index in pages. A problem with the envelope’s own fields, pages and deleteSlugs, comes back in fields like any other write:
{
"error": "validation failed",
"code": "validation_failed",
"fields": {
"pages": "pages array exceeds 5000 entries"
}
}
To change one page without a batch, PATCH /sites/{siteId}/pages/{pagePath} reports its problems in fields like every other single-resource write.
Duplicate slugs within the batch return the conflicting indexes, and a slug appearing in both pages and deleteSlugs names the page indexes. Both are 422. Unresolved file: references are covered under inline media.
A refusal can land after some inline media has already been stored. Those files stay in the library and count against your storage quota whatever the request’s outcome. The error envelope then carries a media array naming them, using the same {filename, url} entries the success response lists, so a retry need not upload them again. Field problems from that path arrive in fields as usual, alongside the media list.
This route refuses an Idempotency-Key with a 422 naming the header. Re-sending the same batch is safe without one.
See errors.