Replace a project's pasted snippets and CSS (Override, advanced), and redeploy.
PUT/v1/projects/{projectId}/custom-scriptsTry it
Session token
Replaces the project's pasted code — Integrations › Custom code › Override (advanced) — turns it on, and redeploys the site so the change goes live. Snippets and CSS are injected into every HTML page at build time — doc engine v1 and v2 alike — after the custom code from your docs, so pasted CSS always applies last.
Tip
Prefer a _syntext/ folder in your docs for new code: it's reviewed and versioned with your pages. Move Custom Code Into Your Docs moves pasted code there. Saving here leaves the three switches as they are.
Note
Requires a session JWT and the admin or owner role in the organization that owns {projectId}; other members get 403 forbidden. API keys are rejected with 401. Starter plan or higher — on Free the request returns 402 plan_required. Every save is recorded in the audit log as custom_code.pasted_changed, with a short fingerprint of the code before and after.
Path Parameters
NameDescription
projectId:stringpathRequired
The project ID, a UUID.
Request Body
The whole configuration — anything you leave out is removed.
NameDescription
headSnippets:object[]bodyRequired
Up to 10 snippets inserted just before </head>, in order. Send [] for none.
Show 4 child attributesobject[]
id:stringbodyRequired
Your identifier for the snippet, 1–64 characters.
name:stringbodyRequired
A label, 1–100 characters.
code:stringbodyRequired
Raw HTML, up to 10 KB. It can't contain </head> or </body>.
enabled:booleanbodyRequired
Whether it's injected. A disabled snippet is kept but left out of pages.
bodySnippets:object[]bodyRequired
Up to 10 snippets inserted just before </body>, with the same fields. Send [] for none.
customCss:stringbody
CSS added as a <style> block after the head snippets, up to 50 KB. It follows the same CSS rules as _syntext/*.css; a stylesheet that breaks one is refused with 400 invalid_custom_code and the rule's message.
confirmPrivate:booleanbody
On a private site (Password, Invite-only or SSO), saving a snippet that's new, changed or turned back on returns 409 confirmation_required — snippets can read everything a signed-in reader sees. Send the same body again with confirmPrivate: true to save it. error.details.snippets lists the snippet names.
Snippets don't run on previews; the Custom CSS does.
Response
The saved configuration, plus what happened to the redeploy:
NameDescription
data.redeploy:object
{ "triggered": true, "buildId": "…" } when a build started. Otherwise { "triggered": false, "skippedReason": "…" } — for example when the month's builds are used up, or there's nothing to rebuild from yet. In that case the change goes live with your next deploy.
Errors
Status
Code
When
400
validation_error
More than 10 snippets in a slot, a snippet over 10 KB, CSS over 50 KB, </head> or </body> in a snippet or the CSS, or a missing field. Each problem is in details.issues
401
unauthorized
No session token, an invalid or expired one, or an API key
402
plan_required
The workspace is on Free — custom scripts need Starter or higher