Page API
A page hosted on Showfold can ask about its own owner: the pages on their home page and how the visitor is related to the owner. It can also save a signed-in visitor’s own data in the owner’s stores. Paste in a snippet or an agent prompt, or call the API from the page’s own script.
How calls work
Each call is a GET from the page’s own script to a path on its own address, starting with /_showfold/api/v1/; saving a record is a POST to the same kind of path. Showfold knows which page is asking from the address it runs on, so a call names no page, owner or key. The same page served anywhere else gets no answer.
Each answer holds only what the visitor could already see, and nothing in it says who the visitor is.
Pages
Every planThe owner’s pages shown on their home page, in the home page’s order, 50 at a time.
tagstringOptionalOnly pages with this tag.
afterstringOptionalThe next value from the previous answer, for the next 50 pages.
pagesarrayOne entry per page, in the home page’s order.
pages[].titlestringThe page’s title.
pages[].iconstring or nullThe address of the page’s icon, or null.
pages[].addressstringThe page’s own address.
pages[].lockedbooleanTrue when the visitor can’t open the page yet.
nextstring or nullPass as after for the next 50 pages. Null on the last batch.
Error answers 2
404no bodyThis page can’t ask right now. The answer has no body and never says why.
429try again laterToo many calls in a short time. Retry-After says how many seconds to wait.
fetch("/_showfold/api/v1/pages?tag=reports")
.then((r) => r.json()){
"pages": [
{
"title": "Chapter 12",
"icon": null,
"address": "https://<owner>.showfold.page/i/<page id>",
"locked": false
}
],
"next": null
}Viewer
Every planHow the visitor is related to the page’s owner. Nothing in the answer says who the visitor is.
Nothing. The answer is about the page it’s called from.
relationshipstringOne of owner, member, guest or none. owner is the workspace’s owning account. member is a member of the workspace’s organization. guest is a visitor on the owner’s guest list; guest needs Pro or Team — on Free there is no guest list and a guest is answered as none. none means the visitor is not signed in to this owner, or has not yet pressed Continue or Join on this owner’s pages.
Error answers 2
404no bodyThis page can’t ask right now. The answer has no body and never says why.
429try again laterToo many calls in a short time. Retry-After says how many seconds to wait.
fetch("/_showfold/api/v1/viewer")
.then((r) => r.json()){
"relationship": "guest"
}Widget
Every planAn address for Showfold’s own Join button, guest badge, Sign in button or Data on this page button, good for one minute, to load in a frame on this page. The Join button, guest badge, Sign in and Data on this page snippets do this for you.
kindstringRequiredIn the path: join for the Join button, guest-badge for the guest badge, sign-in for the Sign in button, data-panel for the Data on this page button.
urlstringThe frame’s address, good for one minute.
expiresAtstringWhen the address stops working, as an ISO 8601 time.
Error answers 2
404no bodyThis page can’t ask right now. The answer has no body and never says why.
429try again laterToo many calls in a short time. Retry-After says how many seconds to wait.
fetch("/_showfold/api/v1/widget/join")
.then((r) => r.json()){
"url": "https://static.showfold.page/i/page-button?t=…",
"expiresAt": "2026-10-27T12:01:00.000Z"
}Store
Pro and TeamRead or save the signed-in visitor’s own record in one of the owner’s stores. Only the visitor sees it, unless the store is owner-visible.
scopestringRequiredIn the path: global for a store shared by all the owner’s pages, or page for this page’s own store.
namestringRequiredIn the path: the store’s name.
recordobject or nullThe visitor’s record, or null before their first save.
versionintegerThe record’s version, 0 before the first save.
recordobjectThe whole record, as JSON. In a write-once store it is laid over the saved record.
expectVersionintegerOptional. The version you loaded, so a save from an out-of-date device is refused instead of overwriting newer progress. Leave it out and the last save wins.
versionintegerThe record’s new version.
Error answers 8
401sign in neededThe visitor is signed out. Show the Sign in snippet.
403notice neededThe store is owner-visible or write-once and the visitor has not agreed to Showfold’s current notice. Ask Showfold’s frame to show it, then save again. Nothing is saved.
404no bodyThis page can’t ask right now. The answer has no body and never says why.
404not availableThere is no such store, or the owner’s stores are not available.
409out of dateThe save’s expectVersion is older than the saved record. The answer holds the newer version.
409already savedThe store is write-once and the save would change a value already saved. The answer names the field, never a value. Nothing is saved.
422invalidThe record doesn’t fit the store. The answer names the field (missing, unknown or wrong type) or the size limit, never a value.
429try again laterToo many calls in a short time. Retry-After says how many seconds to wait.
A store is defined through the owner’s agent — by using a store prompt or the ‘create_store’ tool. It’s never defined by a page’s own script.
nameThe field’s identifier. Letters, digits and underscores; starts with a letter; 1–40 characters.
requiredWhen true, a record write that omits this field is refused, naming the field.
typeThe field’s type: one of the six kinds above, or a list or object that nests further types.
A required field refuses a record write that leaves it out, naming the field. Adding a required field to an existing store requires a default value that every older record then takes.
A store can be made write-once when it is created, with write_once on the create_store tool or the Write-once box on the Stores screen, and that can’t be changed later. In a write-once store a save fills empty fields once. A field that already holds a value must be left out or sent with exactly that value, or the whole save is refused with 409 already saved, naming the field, and nothing is saved. Before a visitor’s first save, Showfold’s frame asks them to agree to keep the record permanently, with the same 403 notice needed answer as an owner-visible store, so write-once stores save only inside Showfold’s frame. After that the visitor can’t erase it: it is kept as proof of what they agreed until the store is deleted, for at most 10 years, and Showfold deletes one only on a request it decides or where the law requires. A write-once store can gain new optional fields; removing or changing a field, or adding a required one, is refused.
A store can also be made owner-visible when it is created, with owner_visible on the create_store tool or the Owner-visible box on the Stores screen, and that can’t be changed later either. The people who manage an owner-visible store see each visitor’s record with their display name and username, once that visitor has agreed to Showfold’s notice. A save before that is refused with 403 notice needed: the page then sends { type: "showfold:store-notice", scope: "global" or "page", store: "<name>" } to window.parent, Showfold’s frame shows its notice, and the frame answers { type: "showfold:store-notice-result", scope, store, agreed }; when agreed is true, save again. Owner-visible stores save only inside Showfold’s frame, so a page’s content address opened on its own can’t save into them, and on a custom domain Safari before 26.2 can’t save into any store. A page can open Showfold’s Data on this page panel with { type: "showfold:data-panel" } or the Data on this page button.
Letters, digits and underscores; starts with a letter; 1–40 characters.
- Fields per store
At most 100 fields, nested ones included.
- Nesting depth
At most 4 levels deep.
- Schema size
Field definitions at most 16384 bytes.
- Default value size
A default value at most 1024 bytes.
stringAny text. Refuses: Non-string values.
numberAny JSON number. Refuses: Non-number values.
intWhole numbers. Refuses: Fractions, numeric text, non-number values.
booltrue or false. Refuses: Non-boolean values.
listA JSON array whose items all match the declared item type. Refuses: Non-array values or items that don’t match the item type.
objectA JSON object whose named fields all pass their own type’s check. Refuses: Non-object values or fields that fail their type’s check.
int accepts whole numbers only and refuses fractions and numeric text; bool accepts only true or false. Nothing is coerced.
A list field declares its item type; an object field declares named subfields, each with its own type, that validate every record write.
// list field
{ kind: "list", items: <type> }
// object field
{ kind: "object", fields: [<field>, …] }When a definition or write is refused
- A store can hold at most 100 fields, nested ones included.
- Fields can nest at most 4 levels deep.
- A field name may not be a reserved object property (__proto__, constructor or prototype).
- The field definitions are too large.
- A required field needs a default value that older records take.
- The default value does not match the field's type.
- A default value can be at most 1,024 bytes.
- This store is write-once, so its saved values can’t be erased or rewritten, and new fields must be optional. To start over, delete the whole store.
- A store with this name already exists here.
- A store needs at least one field.
fetch("/_showfold/api/v1/store/global/theme")
.then((r) => r.json()){
"record": {
"dark": true
},
"version": 4
}fetch("/_showfold/api/v1/store/global/theme", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ record: { dark: true }, expectVersion: 4 }),
})
.then((r) => r.json()){
"version": 5
}Guest badge
Pro and TeamShows You’re a guest ✓ to the owner’s guests, and nothing to anyone else.
Paste it into your page’s HTML where the badge should appear, such as beside the page’s title.
<div data-showfold="guest-badge"></div>
<script>(function () {
var TYPE = "showfold:frame-size";
var MAX_WIDTH = 320;
var MAX_HEIGHT = 64;
var CALL = "/_showfold/api/v1/widget/";
var TITLES = { "join": "Join on Showfold", "guest-badge": "Showfold guest badge", "sign-in": "Sign in on Showfold", "data-panel": "Data on this page on Showfold" };
function clamp(value, max) {
return Math.max(0, Math.min(max, value));
}
function place(element, kind, address) {
var origin = new URL(address).origin;
var frame = document.createElement("iframe");
frame.src = address;
frame.title = TITLES[kind];
frame.setAttribute("scrolling", "no");
frame.setAttribute("style", "border:0;width:0;height:0");
window.addEventListener("message", function (event) {
var data = event.data;
if (event.origin !== origin || event.source !== frame.contentWindow) return;
if (!data || data.type !== TYPE) return;
if (typeof data.width !== "number" || typeof data.height !== "number") return;
if (!isFinite(data.width) || !isFinite(data.height)) return;
frame.style.width = clamp(data.width, MAX_WIDTH) + "px";
frame.style.height = clamp(data.height, MAX_HEIGHT) + "px";
});
element.appendChild(frame);
}
function mount(element) {
var kind = element.getAttribute("data-showfold");
element.setAttribute("data-showfold-ready", "");
try {
fetch(CALL + kind, { credentials: "same-origin", cache: "no-store" })
.then(function (response) {
return response.status === 200 ? response.json() : null;
})
.then(function (body) {
if (body && typeof body.url === "string") place(element, kind, body.url);
})
.catch(function () {});
} catch (error) {}
}
var elements = document.querySelectorAll('[data-showfold="join"],[data-showfold="guest-badge"],[data-showfold="sign-in"],[data-showfold="data-panel"]');
for (var i = 0; i < elements.length; i++) {
if (!elements[i].hasAttribute("data-showfold-ready")) mount(elements[i]);
}
})();</script>Page list
Every planLists the owner’s pages shown on their home page as plain links, with a lock on locked pages, styled by your page. Set data-tag to list one tag. Set data-render to none to get the pages as data in a showfold:pages event and draw them yourself.
Paste it into your page’s HTML where the list should appear. Leave data-tag empty to list every page on your home page. Its markup uses the class names showfold-pages, showfold-page, showfold-page-link, showfold-page-icon, showfold-lock and showfold-more.
<div data-showfold="pages" data-tag=""></div>
<script>(function () {
function load(tag, after) {
var query = "";
if (tag) query += "?tag=" + encodeURIComponent(tag);
if (after) query += (tag ? "&" : "?") + "after=" + encodeURIComponent(after);
try {
return fetch("/_showfold/api/v1/pages" + query, { credentials: "same-origin", cache: "no-store" })
.then(function (response) {
return response.status === 200 ? response.json() : null;
})
.then(function (body) {
if (!body || !Array.isArray(body.pages)) return null;
return { pages: body.pages, next: typeof body.next === "string" ? body.next : null };
})
.catch(function () {
return null;
});
} catch (error) {
return Promise.resolve(null);
}
}
function row(page) {
var item = document.createElement("li");
item.className = "showfold-page";
var link = document.createElement("a");
link.className = "showfold-page-link";
link.setAttribute("href", page.address);
link.setAttribute("target", "_top");
if (page.icon) {
var icon = document.createElement("img");
icon.className = "showfold-page-icon";
icon.setAttribute("src", page.icon);
icon.setAttribute("alt", "");
link.appendChild(icon);
}
link.appendChild(document.createTextNode(page.title));
item.appendChild(link);
if (page.locked) {
var lock = document.createElement("span");
lock.className = "showfold-lock";
lock.setAttribute("role", "img");
lock.setAttribute("aria-label", "Locked");
lock.textContent = "🔒";
item.appendChild(lock);
}
return item;
}
function drawn(element, tag) {
var list = null;
var button = null;
function show(after) {
load(tag, after).then(function (batch) {
if (!batch) {
if (button) button.disabled = false;
return;
}
if (button) {
element.removeChild(button);
button = null;
}
if (batch.pages.length === 0 && !list) return;
if (!list) {
list = document.createElement("ul");
list.className = "showfold-pages";
element.appendChild(list);
}
for (var i = 0; i < batch.pages.length; i++) list.appendChild(row(batch.pages[i]));
if (batch.next) {
var next = batch.next;
button = document.createElement("button");
button.type = "button";
button.className = "showfold-more";
button.textContent = "Show more";
button.addEventListener("click", function () {
button.disabled = true;
show(next);
});
element.appendChild(button);
}
});
}
show(null);
}
function data(element, tag) {
function run(after) {
load(tag, after).then(function (batch) {
if (!batch) return;
var more = batch.next
? function () {
run(batch.next);
}
: null;
element.dispatchEvent(
new CustomEvent("showfold:pages", { bubbles: true, detail: { pages: batch.pages, more: more } })
);
});
}
run(null);
}
var elements = document.querySelectorAll('[data-showfold="pages"]');
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
if (element.hasAttribute("data-showfold-ready")) continue;
element.setAttribute("data-showfold-ready", "");
var tag = element.getAttribute("data-tag") || "";
if (element.getAttribute("data-render") === "none") data(element, tag);
else drawn(element, tag);
}
})();</script>Sign in
Pro and TeamShows Showfold’s own Sign in button while the visitor is signed out, so they can sign in on Showfold and come back to save. It shows nothing once they are signed in, or when the owner’s stores are not available.
Paste it into your page’s HTML next to the control that saves.
<div data-showfold="sign-in"></div>
<script>(function () {
var TYPE = "showfold:frame-size";
var MAX_WIDTH = 320;
var MAX_HEIGHT = 64;
var CALL = "/_showfold/api/v1/widget/";
var TITLES = { "join": "Join on Showfold", "guest-badge": "Showfold guest badge", "sign-in": "Sign in on Showfold", "data-panel": "Data on this page on Showfold" };
function clamp(value, max) {
return Math.max(0, Math.min(max, value));
}
function place(element, kind, address) {
var origin = new URL(address).origin;
var frame = document.createElement("iframe");
frame.src = address;
frame.title = TITLES[kind];
frame.setAttribute("scrolling", "no");
frame.setAttribute("style", "border:0;width:0;height:0");
window.addEventListener("message", function (event) {
var data = event.data;
if (event.origin !== origin || event.source !== frame.contentWindow) return;
if (!data || data.type !== TYPE) return;
if (typeof data.width !== "number" || typeof data.height !== "number") return;
if (!isFinite(data.width) || !isFinite(data.height)) return;
frame.style.width = clamp(data.width, MAX_WIDTH) + "px";
frame.style.height = clamp(data.height, MAX_HEIGHT) + "px";
});
element.appendChild(frame);
}
function mount(element) {
var kind = element.getAttribute("data-showfold");
element.setAttribute("data-showfold-ready", "");
try {
fetch(CALL + kind, { credentials: "same-origin", cache: "no-store" })
.then(function (response) {
return response.status === 200 ? response.json() : null;
})
.then(function (body) {
if (body && typeof body.url === "string") place(element, kind, body.url);
})
.catch(function () {});
} catch (error) {}
}
var elements = document.querySelectorAll('[data-showfold="join"],[data-showfold="guest-badge"],[data-showfold="sign-in"],[data-showfold="data-panel"]');
for (var i = 0; i < elements.length; i++) {
if (!elements[i].hasAttribute("data-showfold-ready")) mount(elements[i]);
}
})();</script>Data on this page
Pro and TeamShows Showfold’s own Data on this page button. It opens Showfold’s panel, where a visitor sees what this page can keep for them, who can see it, and where to view, download or erase it. It shows nothing when the owner’s stores are not available.
Paste it into your page’s HTML where visitors look for privacy or account links, such as the footer.
<div data-showfold="data-panel"></div>
<script>(function () {
var TYPE = "showfold:frame-size";
var MAX_WIDTH = 320;
var MAX_HEIGHT = 64;
var CALL = "/_showfold/api/v1/widget/";
var TITLES = { "join": "Join on Showfold", "guest-badge": "Showfold guest badge", "sign-in": "Sign in on Showfold", "data-panel": "Data on this page on Showfold" };
function clamp(value, max) {
return Math.max(0, Math.min(max, value));
}
function place(element, kind, address) {
var origin = new URL(address).origin;
var frame = document.createElement("iframe");
frame.src = address;
frame.title = TITLES[kind];
frame.setAttribute("scrolling", "no");
frame.setAttribute("style", "border:0;width:0;height:0");
window.addEventListener("message", function (event) {
var data = event.data;
if (event.origin !== origin || event.source !== frame.contentWindow) return;
if (!data || data.type !== TYPE) return;
if (typeof data.width !== "number" || typeof data.height !== "number") return;
if (!isFinite(data.width) || !isFinite(data.height)) return;
frame.style.width = clamp(data.width, MAX_WIDTH) + "px";
frame.style.height = clamp(data.height, MAX_HEIGHT) + "px";
});
element.appendChild(frame);
}
function mount(element) {
var kind = element.getAttribute("data-showfold");
element.setAttribute("data-showfold-ready", "");
try {
fetch(CALL + kind, { credentials: "same-origin", cache: "no-store" })
.then(function (response) {
return response.status === 200 ? response.json() : null;
})
.then(function (body) {
if (body && typeof body.url === "string") place(element, kind, body.url);
})
.catch(function () {});
} catch (error) {}
}
var elements = document.querySelectorAll('[data-showfold="join"],[data-showfold="guest-badge"],[data-showfold="sign-in"],[data-showfold="data-panel"]');
for (var i = 0; i < elements.length; i++) {
if (!elements[i].hasAttribute("data-showfold-ready")) mount(elements[i]);
}
})();</script>Dark mode that follows the reader
Pro and TeamHas your agent add a dark-mode switch to your pages that remembers each signed-in reader’s choice on every page and device.
Paste it into your agent. If Showfold asks you to confirm the store first, your agent gives you the link and waits.
On my Showfold pages, add a dark-mode switch that remembers each reader’s choice across all my pages.
1. Use create_store to create a global store named theme with one optional bool field named dark. Create nothing else.
2. If create_store answers with a confirm link, give me the link and stop until I tell you I have confirmed it. Never ask again to get around it.
3. On each page I name, add a switch that reads GET /_showfold/api/v1/store/global/theme when the page loads and turns dark mode on when dark is true, and that saves the reader’s choice with POST /_showfold/api/v1/store/global/theme and the body {"record":{"dark":true}} or {"record":{"dark":false}}.
4. Paste Showfold’s Sign in snippet unchanged next to the switch. It shows only while the reader is signed out; while a read or save answers 401, hide the switch.
5. Upload each page as a new version.Save progress on one page
Pro and TeamHas your agent save each signed-in visitor’s progress on one page, such as a game save, so it follows them to any device.
Paste it into your agent. If Showfold asks you to confirm the store first, your agent gives you the link and waits.
On my Showfold page <name the page>, save each signed-in visitor’s progress on Showfold instead of in the browser.
1. Read the page’s code and list what progress it keeps.
2. Use create_store to create a page store named save on that page, with one typed field for each piece of progress (string, number, int, bool, list or object), every field optional. Create nothing else.
3. If create_store answers with a confirm link, give me the link and stop until I tell you I have confirmed it. Never ask again to get around it.
4. When the page loads, read GET /_showfold/api/v1/store/page/save. To save, POST /_showfold/api/v1/store/page/save with {"record":{…},"expectVersion":<the version from the last read or save>}.
5. On 409, load the newer save instead of overwriting it. On 422, keep going and tell the visitor the save failed. Paste Showfold’s Sign in snippet unchanged where the save status shows; it appears only while the visitor is signed out.
6. Upload the page as a new version.