What it does
Write several draft files in one call: up to 20 pages, partials, stylesheets, scripts, robots.txt, sitemap.xml and the redirect list together, stored as one draft version. Each item in files has kind (page, partial, css, script, robots, sitemap, or redirects) and source; a page also has path and optional title, settings and page_css; a partial or script has name; css has path for a page stylesheet or name "global" for the global stylesheet. delete lists items to remove by kind and path or name, including uploaded files as kind asset with name (or path asset:name); a deleted page also loses its page stylesheet. files and delete together hold at most 20 items. Files merge onto the draft; the same checks as put_page and the other writes apply, and if any item fails nothing is written. Optional base_version must equal the current draft version, or the call fails with validation_failed reason version_conflict. The whole call counts as one API call. Visitors see nothing until publish_site, unless publish true publishes this version in the same call. files and pages in the response list only what changed (change: created, replaced, or deleted), with draft totals; verbose true lists the whole draft.
Plans
Works on every plan: Free, Basic, Pro and Ultra.
Parameters
| Name | Type | About |
|---|---|---|
site_idrequired | string | The id of the site. list_sites gives the ids of your sites. |
files | array of objects | Up to 20 pages, partials, stylesheets, scripts, robots.txt, sitemap.xml or the redirect list. Each has kind and source, plus path or name. |
delete | array of objects | Files to remove, each by kind and path or name. kind asset with name removes an uploaded file. |
base_version | integer | The draft version number you read last. If the draft has changed since, the call fails with version_conflict instead of overwriting. |
publish | boolean | true publishes the draft in the same call, once the change is applied. |
message | string | A short note for the version history, like a commit message. |
verbose | boolean | true lists every file and page of the draft. Otherwise the response lists only what this call changed, plus draft totals. |
Example
Call write_files with these arguments:
{
"site_id": "01a1…",
"files": [
{
"kind": "partial",
"name": "header",
"source": "<header><a href=\"/\">Home</a></header>"
},
{
"kind": "css",
"name": "global",
"source": "body{font-family:system-ui}"
}
]
}
Ids like 01a1… stand for your own. list_sites and list_tables give you the real ones.
Related guides
- Pages and partialsOne page per address, with shared headers and footers.
- Images, fonts, PDFs and videoUpload files and use them on your pages.