API overview

The Sitepaste API lets you manage pages, upload media, and deploy your site programmatically, whether from a script, a CI pipeline, a phone shortcut, or any HTTP client. It is available on the Pro plan. Billing, team management, and sending mail to your subscribers have no endpoints and stay in the dashboard.

If you are new to Sitepaste, start with Getting started for the core concepts.

Base URL

https://sitepaste.com/api/v1/public

Endpoints

Each endpoint has its own reference page. The groups below match the scope a token needs to reach them.

Publishing a page end to end takes four requests: POST /sites/{siteId}/pages writes it, POST /media uploads anything it shows, POST /sites/{siteId}/deployments puts it live, and GET /sites/{siteId}/pages/{pagePath} reads it back. Every other endpoint is a GET, POST, PATCH, or DELETE over one of the resources below.

Pages

Requires the content scope.

MethodPathPurpose
POST/sites/{siteId}/pagesCreate one page on a site
POST/sites/{siteId}/pages/batchCreate, update, and delete many pages in one request
GET/sites/{siteId}/pagesList page metadata for a site, including the IDs used for renames
GET/sites/{siteId}/pages/{pagePath}Read a single page’s full record, content included
PATCH/sites/{siteId}/pages/{pagePath}Update one page at its own URI, without sending a batch
DELETE/sites/{siteId}/pages/{pagePath}Delete a single page at its own URI

Authors

Requires the content scope.

MethodPathPurpose
GET/sites/{siteId}/authorsList a site’s authors and the IDs used to credit pages to them
POST/sites/{siteId}/authorsCreate an author on a site
GET/sites/{siteId}/authors/{authorId}Read one author’s record
PATCH/sites/{siteId}/authors/{authorId}Update an author’s fields by id
DELETE/sites/{siteId}/authors/{authorId}Delete an author by id

Events and event types

Requires the content scope.

MethodPathPurpose
GET/sites/{siteId}/eventsList a site’s events, hidden ones included
POST/sites/{siteId}/eventsCreate one event on a site
POST/sites/{siteId}/events/batchCreate, update, and delete many events in one request
GET/sites/{siteId}/events/{eventId}Read one event’s record, hidden ones included
PATCH/sites/{siteId}/events/{eventId}Update one event at its own URL, without sending a batch
DELETE/sites/{siteId}/events/{eventId}Delete a single event by id
GET/sites/{siteId}/event-typesList a site’s event types in display order
POST/sites/{siteId}/event-typesCreate one event type on a site
POST/sites/{siteId}/event-types/batchUpsert event types by slug, with deletes in the same call
PATCH/sites/{siteId}/event-typesSet the display order of a site’s event types by slug
GET/sites/{siteId}/event-types/{slug}Read one event type by its slug
PATCH/sites/{siteId}/event-types/{slug}Update one event type at its own URL
DELETE/sites/{siteId}/event-types/{slug}Delete a single event type by slug

Sections and tags

Requires the content scope.

MethodPathPurpose
GET/sites/{siteId}/sectionsList a site’s sections with page counts and metadata
PATCH/sites/{siteId}/sectionsWrite the full nav-group order in one atomic request
GET/sites/{siteId}/sections/{sectionPath}Read one section with its page count and metadata
PATCH/sites/{siteId}/sections/{sectionPath}Set a section’s display title, description, and nav position
DELETE/sites/{siteId}/sections/{sectionPath}Delete a section, every page in it, and the metadata that names it
GET/sites/{siteId}/tagsList a site’s tags with page counts and metadata
GET/sites/{siteId}/tags/{slug}Read one tag with its page count and metadata
PATCH/sites/{siteId}/tags/{slug}Rename a tag across the site, set its display title and description, or both
DELETE/sites/{siteId}/tags/{slug}Remove a tag from every page and drop its metadata

Media and uploads

Requires the media scope. The library is shared by every site in the workspace, so these routes are not site-scoped. There are two ways in: POST /media sends the file through the request, and /uploads hands back upload URLs that a large file is sent to directly.

MethodPathPurpose
POST/mediaUpload a single file and get its URL to reference in content
GET/mediaList the files in the workspace media library
PATCH/media?fileIds=Move a set of files into a folder, or note them, in one request
DELETE/media?fileIds=Delete a set of media files in one request
GET/media/foldersList the workspace’s media folders in display order
POST/media/foldersCreate a media folder (photographer galleries)
GET/media/folders/{folderId}Read one media folder
PATCH/media/folders/{folderId}Rename a media folder, or reorder the media inside it
DELETE/media/folders/{folderId}Delete a media folder; its files return to the library root
GET/media/{fileId}Read one file’s record from the media library
PATCH/media/{fileId}Set a file’s note, move it between folders, or both
DELETE/media/{fileId}Delete a single media file from the library
POST/uploadsGet the upload URLs to send a file to directly
GET/uploads/{uploadId}Read an upload’s state: whether its bytes have landed yet
POST/uploads/{uploadId}/completeValidate an uploaded file and add it to the media library
DELETE/uploads/{uploadId}Abort an upload in progress

Deploys and previews

Requires the deploy scope.

MethodPathPurpose
POST/sites/{siteId}/deploymentsQueue a deploy that publishes your saved pages as a static site
GET/sites/{siteId}/deploymentsList recent deploys with status and attribution
GET/sites/{siteId}/deployments/latestGet the most recent deploy’s status for a site
GET/sites/{siteId}/deployments/liveRead the deploy currently serving the site
DELETE/sites/{siteId}/deployments/liveTake a site offline, keeping all content
GET/sites/{siteId}/deployments/{deploymentId}Read one deploy from the site’s history
GET/sites/{siteId}/pending-changesSee what changed since the last deploy
POST/sites/{siteId}/previewsBuild the site to a shareable preview before deploying
GET/sites/{siteId}/previewsList a site’s active previews
GET/sites/{siteId}/previews/{previewId}Read one preview’s status and URL
PATCH/sites/{siteId}/previews/{previewId}Change a preview’s visibility or password
DELETE/sites/{siteId}/previews/{previewId}Expire a preview and remove its output
POST/sites/{siteId}/previews/{previewId}/rebuildRebuild a preview with the current content
POST/sites/{siteId}/previews/{previewId}/promoteSwap a ready preview into the live site

Workspace, sites, and domains

Requires the settings scope.

MethodPathPurpose
GET/workspaceRead the workspace a token acts on, and which site is its default
PATCH/workspaceMake a site the workspace default
GET/sitesList the workspace’s sites with the site limit
POST/sitesCreate a site within the paid allowance
GET/sites/{siteId}Read one site’s full settings by id
PATCH/sites/{siteId}Update one site’s settings by id
DELETE/sites/{siteId}Delete a site and everything on it
GET/domainsList custom domains with status and the domain limit
POST/domainsAdd a custom domain and receive its DNS setup records
GET/domains/{domainId}Read one custom domain’s status and DNS records
PATCH/domains/{domainId}Point a domain at a different site in the workspace
DELETE/domains/{domainId}Remove a custom domain from the workspace
POST/domains/{domainId}/checkCheck the domain’s DNS and move it on to its next status

Submissions, subscribers, and metrics

Requires the data scope.

MethodPathPurpose
GET/sites/{siteId}/contact-submissionsList a site’s contact form submissions
GET/sites/{siteId}/contact-submissions/{submissionId}Read one contact form submission
DELETE/sites/{siteId}/contact-submissions/{submissionId}Delete one contact form submission
GET/sites/{siteId}/newsletter-subscribersList a site’s newsletter subscribers
POST/sites/{siteId}/newsletter-subscribersAdd a newsletter subscriber directly
GET/sites/{siteId}/newsletter-subscribers/{subscriberId}Read one newsletter subscriber’s record
PATCH/sites/{siteId}/newsletter-subscribers/{subscriberId}Update a subscriber’s fields or confirm them
DELETE/sites/{siteId}/newsletter-subscribers/{subscriberId}Remove a newsletter subscriber
GET/sites/{siteId}/metricsRead a site’s traffic metrics

Authentication

Every request requires a bearer token in the Authorization header:

Authorization: Bearer sp_your_token_here

Tokens are created in the dashboard under Account > Tokens, where each token is given the scopes it may use: content, media, settings, deploy, and data. Each endpoint requires exactly one scope, and a token missing it gets a 403 whose code is token_scope_required and whose scope field names the scope. Writing content needs content and publishing it needs deploy, in two requests. See authentication.

Quick example

TOKEN="sp_your_token_here"

# Write the page
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\nPublished via the API.",
    "tags": ["first-post"]
  }'

# Publish it
curl -X POST https://sitepaste.com/api/v1/public/sites/default/deployments \
  -H "Authorization: Bearer $TOKEN"

Saving a page does not publish it.

Addressing

A workspace’s resources hang off the root; a site’s hang off that site:

/workspace  /sites  /domains  /media  /uploads      the workspace
/sites/{siteId}/...                                 one site in it

The workspace comes from your token, so it never appears in the path. One media library serves every site in the workspace, so /media sits at the root, while each page belongs to one site under /sites/{siteId}/pages.

{siteId} takes a site’s short ID or the literal default:

curl https://sitepaste.com/api/v1/public/sites/default/pages \
  -H "Authorization: Bearer $TOKEN"

default resolves to the workspace’s default site at request time. A stored URI holding default follows the default if you change it later; one holding a site’s own ID does not. Use default interactively, and the ID in anything you save, schedule, or share.

Query parameters such as ?limit=, ?offset=, ?q=, and ?type= filter and window a collection. The two bulk media routes, PATCH /media?fileIds=a,b and DELETE /media?fileIds=a,b, name their files in ?fileIds=, and the PATCH body carries what to write.

Under /sites/{siteId}, the path names the site, so no body carries a siteId.

Action sub-resources

Four routes start an action on the resource above them:

POST /domains/{domainId}/check         POST /previews/{previewId}/rebuild
POST /uploads/{uploadId}/complete      POST /previews/{previewId}/promote

Each starts work, and none is idempotent: asking twice does the work twice unless you send an Idempotency-Key. A GET on one is a 405. Read the result at the parent: /domains/{domainId}, /previews/{previewId}, or /uploads/{uploadId}.

What a collection POST means

A POST to a collection creates one member and answers 201 with a Location naming it. Use the /batch sub-resource below to write many members at once.

Three routes answer differently:

RouteAnswers
POST /sites/{siteId}/deployments202, with Location naming the deploy to poll
POST /sites/{siteId}/previews202, with Location naming the preview to poll
POST /domains201 with no Location, since an apex domain and its www. pair are created together

Three collections also have a /batch sub-resource. Send it the envelope and it applies many writes at once, atomically, answering 200 with a report:

CollectionBatch routeEnvelope
/sites/{siteId}/pages/pages/batch{"pages": [...], "deleteSlugs": [...]}
/sites/{siteId}/events/events/batch{"events": [...], "deleteIds": [...]}
/sites/{siteId}/event-types/event-types/batch{"eventTypes": [...], "deleteSlugs": [...]}

A create answers 409 on a member that already exists. A batch entry upserts instead, so re-sending the same batch lands the same state. Use /batch to mirror content or to land several writes together, and the collection to write a single member.

What a collection PATCH means

A PATCH on a collection writes across its members in one request. The URI says which members, and the body says what to write:

RouteSelectsBodyWrites
/sites/{siteId}/event-typesthe whole collection{"order": [...]}the display order
/sites/{siteId}/sectionsthe whole collection{"order": [...]}the nav-group order
/media?fileIds=the files the query names{"folderId": ..., "note": ...}one change across them

Request bodies

Send Content-Type: application/json on every request that carries a body. An endpoint that receives a body in a format it does not parse answers 415. The exceptions take multipart/form-data: POST /media, and the two page-write routes, POST /sites/{siteId}/pages and POST /sites/{siteId}/pages/batch, when they carry inline media. A 415 refusing a PATCH body also names the formats that route does take, in Accept-Patch.

Every PATCH is a partial write: a field you send is written, a field you omit keeps its stored value. An empty string clears a field, and null reads as not sent. A PATCH body sent as application/merge-patch+json is refused with 415. Where null means something on a particular field, that field’s own page says so: folderId on PATCH /media/{fileId} takes null to unfile a file.

No endpoint reads a request body on DELETE. Deletes that act on several things name them in the query: DELETE /media?fileIds=a,b.

A field that belongs to a neighbouring endpoint is refused with a 422 naming it, and the error says which route takes it. That covers siteId, which is named in the path; a batch envelope’s keys on a route that writes one record; and fileIds on PATCH /media, which names its files in the query.

Response format

All responses are JSON unless you ask for something else. Two collections serve a second representation, chosen with Accept:

RequestResponse
GET /sites/{siteId}/pagesPage metadata as JSON
GET /sites/{siteId}/pages with Accept: application/zipEvery page as a zip of Markdown
GET /sites/{siteId}/newsletter-subscribersSubscribers as JSON
GET /sites/{siteId}/newsletter-subscribers with Accept: text/csvSubscribers as CSV

An Accept header that rules out every representation an endpoint can produce gets a 406.

Errors

Every error answers with the same envelope, whatever went wrong:

{
  "error": "validation failed",
  "code": "validation_failed",
  "fields": {
    "slug": "slug must not be empty"
  }
}
MemberMeaning
errorA sentence to show a user. Do not match on it; the wording can change
codeA stable identifier, always present. Branch on this
fieldsPresent on a validation failure, keyed by the field at fault. Batch endpoints key by entry index instead. See POST /sites/{siteId}/pages/batch

Some codes carry extra members: a token_scope_required refusal adds scope, a site_limit_reached 402 adds limit and used, a domain_limit_reached 402 adds those plus includedDomains and domainPacks, and a pro_features_in_use 402 adds features.

The codes you can branch on:

CodeMeaning
bad_requestThe request could not be understood
unauthorizedMissing or invalid token
forbiddenThe token may not do this
token_scope_requiredThe token lacks the scope named in scope
payment_past_dueThe workspace’s subscription needs attention
plan_requiredThe plan does not include this
payment_requiredA 402 with no more specific code. The feature needs a plan you are not on
quota_exceededA storage or monthly quota is spent
site_limit_reachedThe workspace is at its paid site capacity
domain_limit_reachedThe workspace is at its paid custom-domain capacity
pro_features_in_useThe workspace is not on Pro but the site uses the Pro features in features, so it cannot be built
not_foundNo such resource
no_default_siteThe request named default but the workspace has no default site; name a site or set one
method_not_allowedWrong method; the Allow header lists the right ones
not_acceptableNo representation matches your Accept header
conflictThe request conflicts with the current state
idempotency_key_reuseAn Idempotency-Key was sent with a different request than the one it names
idempotency_key_in_flightA request with this Idempotency-Key has not finished yet
payload_too_largeBody or file over the limit
payload_field_too_largeThe multipart payload field is over its own 10 MB limit; split the batch rather than shrink the files
unsupported_media_typeThe endpoint does not parse that Content-Type
validation_failedThe body parsed but does not validate; see fields
cooldown_activeThe 30-second deploy cooldown is running
rate_limitedA rate limit, the upload budget, or the hourly deploy budget is spent
internal_errorServer error
service_unavailableServer busy; retry shortly

Wherever a request takes an id, a siteId, or any other resource ID, pass the ID a response gave you.

Status codes

CodeMeaning
200Success
201Created. The Location header names the new resource, except on POST /domains
202Accepted: a deploy or preview build is queued. Location points at the status to poll
204No content. Every write whose only news is that it worked answers this; a write that has something to report, such as the updated resource or a count of what it touched, answers 200 with it
304Not modified. See conditional reads
400The request could not be understood
401Missing or invalid token
402Quota exceeded, or the plan does not allow the operation
403Pro plan required, the subscription is past due, or the token lacks the route’s scope
404Resource not found
405Wrong method for this path; Allow lists the ones that work
406No representation matches your Accept header
409Conflicts with the current state (a taken slug, an only site, a domain already claimed, a per-site metadata cap reached, an Idempotency-Key still in flight)
413Request body or file too large
415The endpoint does not parse that Content-Type
422The body parsed but a field is invalid; fields names them
429Rate limit or deploy cooldown active
500Server error
503Server busy (retry shortly)

400 and 422 divide this way: 400 means the request could not be understood, as with malformed JSON or a path that names no resource. 422 means it was understood and a field is wrong, and fields names them.

A {siteId} naming a site that does not exist, or one in another workspace, is a 404 on every route under /sites/{siteId}, never a 403.

An id that exists but belongs to another site of your own workspace is a 404 too: /sites/a/previews/{id} will not reach a preview that lives on site b.

Paging

Every list takes the same two parameters:

ParameterDefaultMeaning
limit1000How many to return, 1 to 1000
offset0How many to skip

and answers with the window plus the size of the whole collection:

{
  "pages": [ ... ],
  "total": 4210,
  "limit": 100,
  "offset": 200
}

A limit or offset outside these ranges is a 422.

Every list is totally ordered, so walking one with offset visits each item exactly once, even straight after a batch write that touched many of them at once.

A few collections are bounded and are returned whole: sections and tags (capped per site), sites and domains (bounded by your plan), media folders, and active previews. These take no window, and answer a limit or offset with a 422.

Idempotency

A POST that times out leaves you unable to tell whether it arrived. Send an Idempotency-Key and a retry is answered from the first request’s recorded outcome instead of doing the work again.

KEY=$(uuidgen)
curl -X POST "https://sitepaste.com/api/v1/public/sites/default/deployments" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Idempotency-Key: $KEY"
# ... connection drops, outcome unknown. Send exactly the same request again:
curl -X POST "https://sitepaste.com/api/v1/public/sites/default/deployments" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Idempotency-Key: $KEY"
# HTTP/1.1 202 Accepted
# Idempotency-Replayed: true      <- one deploy was queued, not two

The key is yours to choose: any printable ASCII up to 255 characters, and a UUID is a good default. It is scoped to your workspace, so two workspaces using the same string never see each other’s results, and it lasts 24 hours.

  • A replayed response carries Idempotency-Replayed: true and repeats the original status, body, and Location exactly.
  • The key remembers the whole request: method, path, query string, and body. Re-using one for a different request, including a retry with different ? parameters, is a 422 with code idempotency_key_reuse.
  • Query strings are compared in canonical form, which sorts parameters by name and keeps each name’s own values in the order you sent them. So ?a=1&b=2 matches ?b=2&a=1, while ?fileIds=a&fileIds=b does not match ?fileIds=b&fileIds=a. Send a repeated parameter’s values in a stable order across a retry.
  • A retry that arrives while the first request is still running gets a 409 with code idempotency_key_in_flight and a Retry-After. Wait that long and send it again.
  • A keyed request has four minutes to finish and is cancelled if it runs longer, so a key always comes free for your retry. The one route that can approach that ceiling is POST /uploads/{uploadId}/complete, which is safe to repeat without a key: a completion whose upload has already produced a file answers 409 naming that file.
  • 5xx, 429, 402, and 409 release the key, so a retry genuinely retries. Every other status is kept: fix the body and use a new key.

Send it on anything unsafe. It is honoured on every POST, PATCH, and DELETE except the three routes that carry file uploads: POST /media, POST /sites/{siteId}/pages, and POST /sites/{siteId}/pages/batch. Those refuse a supplied key with a 422 naming the header. Retry them without it: POST /uploads keeps one handle however many times you retry the flow, the pages batch upserts by slug, and the single page create answers 409 on a page that already exists.

A key on a GET or HEAD is ignored, so a client that sets the header on every request is fine.

Conditional reads

Every JSON read carries a strong ETag and honours If-None-Match:

# First read
curl -i "https://sitepaste.com/api/v1/public/sites/default/deployments/latest" \
  -H "Authorization: Bearer $TOKEN"
# ... ETag: "6b8c...":

# Poll without refetching the body
curl -i "https://sitepaste.com/api/v1/public/sites/default/deployments/latest" \
  -H "Authorization: Bearer $TOKEN" \
  -H 'If-None-Match: "6b8c..."'
# HTTP/1.1 304 Not Modified

Send the ETag back and an unchanged resource answers 304 with no body, which keeps polling a deploy cheap. Reads carry Cache-Control: private, no-cache: store the response, and revalidate before using it.

The zip and CSV representations above carry no validator, so a conditional request for one is served in full.

Deleting in a batch

Three endpoints delete alongside their writes, and they differ in what an entry that matches nothing does:

EndpointFieldAn entry that matches nothing
POST /sites/{siteId}/pages/batchdeleteSlugsIgnored. The response’s deleted lists only what was actually removed
POST /sites/{siteId}/event-types/batchdeleteSlugsIgnored. The response’s deleted lists only what was actually removed
POST /sites/{siteId}/events/batchdeleteIdsRejected with 422, and nothing in the batch is written

The single-resource deletes answer 404 when the target does not exist. That covers every DELETE on an item URI, from /sites/{siteId}/pages/{contentType}/{slug} through the media, domain, and subscriber routes.

Tags are the exception. DELETE /sites/{siteId}/tags/{slug} always answers 200 with the number of pages the tag was removed from, so a tag no page carries comes back as {"deleted": 0} rather than a 404. PATCH /sites/{siteId}/tags/{slug} answers 200 with the tag as it now stands, adding a renamed count when the request renamed it.

Rate limiting

Three budgets apply, and one request can spend more than one of them.

BudgetLimitCounted perSpent by
Requests600 per minuteCalling clientEvery request
Uploads600 per minuteWorkspacePOST /media and POST /uploads/{uploadId}/complete
Deploys300 per hourWorkspacePOST /sites/{siteId}/deployments, POST /sites/{siteId}/previews, rebuild, promote, and GET /sites/{siteId}/pages asked for as application/zip

The request budget is counted per calling client, not per token or workspace. The other two budgets are shared by every token in a workspace.

A batch is one request whether it carries 1 page or 5,000, and neither it nor its inline media spends anything from the deploy budget. Write in bulk, then deploy once. The 30-second deploy cooldown is usually the tighter limit, since it caps a site at 120 deploys an hour on its own.

Work refused before it starts costs nothing, so retrying into a cooldown cannot drain the hour. POST /media is the exception: it spends from the upload budget as soon as the request arrives.

A spent budget answers 429 with Retry-After in seconds. A refused deploy leaves your writes saved.

Refused byRetry-After
A per-minute budget60
The hourly deploy budget3600
The 30-second deploy cooldownThe seconds left on it, rounded up

Each budget reports under its own headers:

HeadersBudget
X-RateLimit-Limit, X-RateLimit-RemainingRequests
X-Upload-RateLimit-Limit, X-Upload-RateLimit-RemainingUploads
X-Heavy-RateLimit-Limit, X-Heavy-RateLimit-RemainingDeploys

The upload and deploy pairs are sent on a request that goes through as well as on one that is refused, so a job can pace itself against what is left. A response can omit a -Remaining header. Treat its absence as no news rather than as a spent budget.

For publishing without writing code, see the Publish from guides for the Obsidian plugin, the GitHub Action, and Apple Shortcuts.