Examples
Practical examples for common API workflows.
These all write pages, so they need a token with the content scope. The ones that deploy also need deploy, and “Upload media separately” needs media. Inline media attached to a pages request does not.
Writing a page does not publish it. Each example that should go live ends with a POST to /sites/{siteId}/deployments, which is the one route that deploys.
Publish a single page
Create the page, then publish the site:
curl -X POST https://sitepaste.com/api/v1/public/sites/default/pages \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"title": "Hello world",
"content": "# Hello world\n\nMy first post via the API.",
"tags": ["intro"]
}'
curl -X POST https://sitepaste.com/api/v1/public/sites/default/deployments \
-H "Authorization: Bearer $TOKEN"
The create answers 201 with the page’s URI in Location. A page that already exists at the same slug is a 409, so use the batch below when you want a re-run to update instead.
Batch publish documentation
Send all your docs pages in one request to the batch. Entries are upserted by slug, so running this repeatedly only updates what changed:
curl -X POST https://sitepaste.com/api/v1/public/sites/default/pages/batch \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"pages": [
{
"slug": "getting-started",
"title": "Getting started",
"content": "# Getting started\n\nInstall with npm...",
"contentType": "docs"
},
{
"slug": "configuration",
"title": "Configuration",
"content": "# Configuration\n\nEdit config.json...",
"contentType": "docs"
}
]
}'
curl -X POST https://sitepaste.com/api/v1/public/sites/default/deployments \
-H "Authorization: Bearer $TOKEN"
Group pages with sections
The section field groups pages under a path: /docs/guides/... for docs, or a top-level path like /guides/... for standalone pages. See Sections.
curl -X POST https://sitepaste.com/api/v1/public/sites/default/pages \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"slug": "getting-started",
"title": "Getting started",
"content": "# Getting started\n\nFollow these steps...",
"contentType": "docs",
"section": "guides"
}'
The same slug can exist in different sections or content types: /docs/guides/overview and /docs/tutorials/overview are separate pages.
A standalone section may nest one level by joining two names with a slash. This is how an API reference gets a page per endpoint under a sub-section:
curl -X POST https://sitepaste.com/api/v1/public/sites/default/pages \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"slug": "post-builds",
"title": "POST /builds",
"content": "# POST /builds\n\nQueue a deploy...",
"contentType": "standalone",
"section": "api/builds"
}'
This publishes at /api/builds/post-builds. Docs and blog sections cannot nest.
Credit an author and protect a page
Look up the author’s ID with GET /sites/{siteId}/authors, then set authorId and, for a client-only draft, a password:
AUTHOR_ID=$(curl -s https://sitepaste.com/api/v1/public/sites/default/authors \
-H "Authorization: Bearer $TOKEN" | jq -r '.authors[0].id')
curl -X POST https://sitepaste.com/api/v1/public/sites/default/pages \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d "{
\"title\": \"Q3 case study\",
\"content\": \"For client eyes only.\",
\"authorId\": \"$AUTHOR_ID\",
\"password\": \"share-with-client\"
}"
curl -X POST https://sitepaste.com/api/v1/public/sites/default/deployments \
-H "Authorization: Bearer $TOKEN"
Sending "password": "" later removes the protection; "authorId": "" removes the author.
Update a single field
Send only what changes; everything else is preserved. A page has its own URI, so a one-page change goes there:
curl -X PATCH "https://sitepaste.com/api/v1/public/sites/default/pages/blog/my-draft" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"draft": false}'
Rename a slug
The batch matches a page by its slug, so renaming one means sending its id with the new slug in the batch. Get the id from GET /sites/{siteId}/pages first:
curl -X POST https://sitepaste.com/api/v1/public/sites/default/pages/batch \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"pages": [{"id": "k3m9x2q7r4pz", "slug": "better-slug"}]}'
Upload a photo with a page
Attach files with multipart form data and reference them with file::
curl -X POST https://sitepaste.com/api/v1/public/sites/default/pages \
-H "Authorization: Bearer $TOKEN" \
-F payload='{"title": "Beach day", "content": "Great day at the beach.\n\n", "tags": ["photos"]}' \
-F files=@sunset.jpg
curl -X POST https://sitepaste.com/api/v1/public/sites/default/deployments \
-H "Authorization: Bearer $TOKEN"
Upload media separately
Upload first, then use the returned URL in your content:
RESPONSE=$(curl -s -X POST https://sitepaste.com/api/v1/public/media \
-H "Authorization: Bearer $TOKEN" \
-F file=@header.jpg)
URL=$(echo "$RESPONSE" | jq -r '.url')
curl -X POST https://sitepaste.com/api/v1/public/sites/default/pages \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d "{
\"title\": \"Post with header image\",
\"content\": \"\n\nWelcome to my post.\"
}"
curl -X POST https://sitepaste.com/api/v1/public/sites/default/deployments \
-H "Authorization: Bearer $TOKEN"
Add and remove pages in one call
deleteSlugs removes pages in the same request that creates and updates others. Each entry needs slug and contentType, plus section if the page has one:
curl -X POST https://sitepaste.com/api/v1/public/sites/default/pages/batch \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"pages": [
{"slug": "v2-intro", "title": "Introduction (v2)", "content": "...", "contentType": "docs"}
],
"deleteSlugs": [
{"slug": "v1-intro", "contentType": "docs"},
{"slug": "v1-getting-started", "contentType": "docs", "section": "guides"}
]
}'
curl -X POST https://sitepaste.com/api/v1/public/sites/default/deployments \
-H "Authorization: Bearer $TOKEN"
Sync a local directory
List the remote pages, compare updatedAt against your local files, and push only what changed:
curl -s https://sitepaste.com/api/v1/public/sites/default/pages \
-H "Authorization: Bearer $TOKEN" | jq '.pages[] | {slug, contentType, section, updatedAt}'
To remove remote pages that no longer exist locally, build deleteSlugs entries from the listing. Deletions are matched by slug + contentType + section, not by id.
Delete a page
contentType is required; add section if the page belongs to one:
curl -X DELETE "https://sitepaste.com/api/v1/public/sites/default/pages/blog/old-post" \
-H "Authorization: Bearer $TOKEN"
Returns 204 on success, 404 if the page does not exist.
Beyond curl
To publish from a repository, use the GitHub Action, which wraps the pages batch with local validation. Your editor and your phone are covered by the Obsidian plugin and Apple Shortcuts guides.