Create a page

Create one page. The response is a 201 with the new page’s URI in Location.

POST https://sitepaste.com/api/v1/public/sites/{siteId}/pages

Requires the content scope.

To write many pages at once, or to create, update, and delete together, use POST /sites/{siteId}/pages/batch. To change a page that already exists, use PATCH at the page’s own URI.

Usage

curl -X POST https://sitepaste.com/api/v1/public/sites/default/pages \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Getting started",
    "slug": "getting-started",
    "content": "# Getting started\n\nWelcome to the docs.",
    "contentType": "docs"
  }'

The response’s Location names the new page:

Location: /api/v1/public/sites/default/pages/docs/getting-started

Saving a page does not publish it. Deploy the site with POST /sites/{siteId}/deployments when you are ready for the change to go live.

Authorizations

HeaderTypeRequiredDescription
AuthorizationstringYesBearer token (Authorization: Bearer sp_...). Created in the dashboard under Account > Tokens. See authentication.

Body

The body is one page object, made of the fields below. Send Content-Type: application/json, or multipart/form-data with the JSON in a payload field alongside file parts when the page carries inline media.

The site is named in the path, not the body. See addressing.

pages and deleteSlugs belong to the batch, an id names a page that already exists and belongs to a PATCH, and publishing has its own route. A body carrying one of them answers 422 naming the field and where it belongs.

Page fields

title is required. Everything else is optional, and a field you leave out takes its default.

FieldTypeRequiredDescription
slugstringNoURL slug (max 100 bytes). Generated from title when omitted.
titlestringYesPage title (max 200 bytes).
contentstringNoMarkdown content (max 100,000 bytes). Leading and trailing whitespace is trimmed. May contain file: references to inline media.
contentTypestringNoblog, docs, standalone, or homepage. Defaults to blog for new pages.
sectionstringNoGroups the page under a path. See Sections.
descriptionstringNoMeta description (max 500 bytes). Trimmed.
apiEndpointstringNoMarks the page as an API reference, like GET /sites/{siteId}/pages/{slug} (max 200 bytes). The method is uppercased on save and shows as a badge in the site navigation. Empty string clears it.
draftbooleanNoLeaves the page off the deployed site. Defaults to false for API-created pages.
tagsarrayNoUp to 20 tags, each max 30 bytes. See Tags.
publishedAtstringNoRFC 3339 timestamp. Defaults to now for new pages.
authorIdstringNoAuthor to credit the page to, from list authors. Empty string removes the author.
passwordstringNoPassword-protects the page (min 8 bytes). See Protection.
ogImageUrlstringNoSocial preview image URL. Empty string clears it.
showListingsbooleanNoHomepage only: show recent posts and section listings below the content.
languagestringNoLanguage tag for the page, like en or pt-BR. Empty string clears it.
paramsobjectNoArbitrary JSON stored with the page, for a theme to read. Replaces existing params when present.

Theme overrides

A page can override the site’s theme settings, exactly as in the page editor’s theme panel. All are optional; a page without overrides inherits everything from the site.

String settings clear back to “inherit” with an empty string:

FieldTypeDescription
themestringTheme name for this page.
primaryColorstringHex color in the form #RRGGBB, like #336699.
primaryColorDarkstringHex color in the form #RRGGBB, used while the page is shown in dark mode. When blank, dark mode uses this page’s primaryColor if set, and otherwise the site’s dark mode color.
fontSizestringcompact, comfortable, or large.
codeThemeLightstringSyntax highlighting theme for light mode.
codeThemeDarkstringSyntax highlighting theme for dark mode.
galleryDownloadPositionstringWhere the “Download all” button appears: top or footer.

Boolean settings take the strings "true", "false", or "inherit". A JSON true or false is accepted too and means the same as its string.

FieldDescription
showTocTable of contents.
showSocialShareSocial share buttons.
showCommentsComments.
showNextPrevNext/previous post navigation.
showNewsletterCtaNewsletter signup CTA.
showTagsTag chips.
showDatesPublish dates.
showAuthorAuthor byline.
showReadingTimeReading time estimate.
showBreadcrumbsBreadcrumbs.
showCopyMarkdownCopy-as-Markdown button.
showGalleryDownloadGallery “Download all” button, which serves the gallery as a ZIP.
showGalleryItemDownloadDownload buttons on individual gallery photos and videos, in the grid and the lightbox.
fullWidthGalleryFull-width gallery grid (photographer theme).
masonryGalleryMasonry gallery grid (photographer theme).

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.

Response

201 Created, with the page in the representation GET /sites/{siteId}/pages/{pagePath} serves and the page’s URI in Location. On a multipart request that carried files, the body also lists them:

FieldTypeDescription
mediaarrayOne {filename, url} per uploaded inline file. Only on multipart requests with files.

Errors

Field problems return 422 and name the field, like every other single-resource write:

{
  "error": "validation failed",
  "code": "validation_failed",
  "fields": {
    "title": "title is required for new pages"
  }
}

A page that already exists at the same content type, section, and slug is a 409. Update it at its own URI instead, or send the batch, which upserts.

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.

This route refuses an Idempotency-Key with a 422 naming the header. Re-sending a create never writes twice, because a page that already exists answers 409.

See errors.