Pages and blocks
Address pages, read and change blocks, write whole pages, publish, and restore earlier versions.
A page is a list of blocks: a hero, a rich text section, a gallery, a form. Each block has a type, its props (the words, images and links it shows), an optional variant, and an id unique within the page. You edit a page's draft; visitors see the published version until you publish again.
Address a page
A page is addressed by its id (pg_…) or its address:
| You write | Page |
|---|---|
index | the homepage, / |
about | /about |
insights/my-post (or insights%2Fmy-post) | /insights/my-post |
Sub-resources (/blocks, /publish, /unpublish, /duplicate, /revisions) take the id or a one-segment address. Use the id for deeper pages.
Read a page
curl -i https://api.unvop.com/v1/sites/site_…/pages/index \
-H "Authorization: Bearer $UNVOP_KEY"The answer is the page with every block of its draft, and an ETag header to send back when you save (ETags). Add ?version=published to read what is live instead. GET /sites/{siteId}/pages lists every page and article, the homepage first.
Know the block types
GET /sites/{siteId}/blocks lists every block the site's pages can use, with its fields (name, type, label, options), defaults and variants. Read it before you write blocks: props are checked against these fields, and a page that doesn't fit is refused with 422 invalid_spec and errors that name the exact path, like pages[0].blocks[2].props.heading.
Rich text props take simple HTML, like <p>Open every day from 8.</p>. Image props take a URL from your media library.
Change one block
PATCH a block with the props you want to change. Props you leave out are kept.
curl -X PATCH https://api.unvop.com/v1/sites/site_…/pages/index/blocks/b_hero \
-H "Authorization: Bearer $UNVOP_KEY" \
-H "Content-Type: application/json" \
-H 'If-Match: "…the ETag…"' \
-d '{ "props": { "heading": "Fresh bread from 7am" } }'const page = await fetch(`https://api.unvop.com/v1/sites/${siteId}/pages/index`, { headers });
const etag = page.headers.get('ETag');
const { blocks } = await page.json();
await fetch(`https://api.unvop.com/v1/sites/${siteId}/pages/index/blocks/${blocks[0].id}`, {
method: 'PATCH',
headers: { ...headers, 'Content-Type': 'application/json', 'If-Match': etag },
body: JSON.stringify({ props: { heading: 'Fresh bread from 7am' } }),
});page = requests.get(f"https://api.unvop.com/v1/sites/{site_id}/pages/index", headers=headers)
etag = page.headers["ETag"]
blocks = page.json()["blocks"]
requests.patch(
f"https://api.unvop.com/v1/sites/{site_id}/pages/index/blocks/{blocks[0]['id']}",
headers={**headers, "If-Match": etag},
json={"props": {"heading": "Fresh bread from 7am"}},
)A PATCH can also set variant, hidden (keep the block but don't show it) and anchor (the id people can link to with #).
Add, move and remove blocks
POST /sites/{siteId}/pages/{page}/blocks inserts a block at the end, at a position, or before or after another block:
{ "type": "richText", "props": { "body": "<p>Open every day from 8.</p>" }, "after": "b_hero" }POST …/blocks/{blockId}/move takes the same position, before or after. DELETE …/blocks/{blockId} removes one. Each answers with the page as it now is, plus any warnings.
Write a whole page
PUT /sites/{siteId}/pages/{page} writes a page in one call: its title, SEO and every block. It creates the page when nothing is at that address. Send "publish": true to make it live in the same call.
{
"title": "About us",
"blocks": [
{ "id": "b1", "type": "richText", "props": { "body": "<p>We bake every morning.</p>" } }
],
"publish": false
}POST /sites/{siteId}/pages is the lighter way to start: it adds a draft page from a title and kind (page or post), optionally from one of the theme's templates.
Publish, unpublish and restore
POST …/pages/{page}/publishmakes the draft live and keeps a revision. Send anoteto say what changed.POST /sites/{siteId}/publishpublishes every page at once.POST …/pages/{page}/unpublishtakes a page off the live site and keeps its draft. The homepage can't be unpublished.GET …/pages/{page}/revisionslists the last 50 published versions;POST …/revisions/{revisionId}/restoreputs one back as the draft. Publish it to make it live again.POST …/pages/{page}/duplicatecopies the draft to a new page at a free address.
Deleting a page (DELETE …/pages/{page}) takes it off the live site. The homepage can't be deleted; replace it with PUT instead.
The look
Blocks carry content; the look lives in the site's design. GET /sites/{siteId}/design returns the brand tokens (colours, fonts, radius), the fonts and the stylesheet. PATCH /sites/{siteId}/design/tokens changes tokens by name and every page updates at once. Both need design:write to change.