/Docs
Search docs or ask a question⌘K
DocsAgent
Changelog
API Reference Update Pasted Custom Code

Update Pasted Custom Code

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[]
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

StatusCodeWhen
400validation_errorMore 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
401unauthorizedNo session token, an invalid or expired one, or an API key
402plan_requiredThe workspace is on Free — custom scripts need Starter or higher
403forbiddenYou're not a member of the project's organization
404not_foundThe project doesn't exist
Was this page helpful? Yes No
Request
cURLJavaScriptPythonGoRubyPHPJavaC#cURL
curl -X PUT https://api.syntext.dev/v1/projects/$PROJECT_ID/custom-scripts \
-H "Authorization: Bearer $SYNTEXT_JWT" \
-H "Content-Type: application/json" \
-d '{
"headSnippets": [
{ "id": "plausible", "name": "Plausible", "code": "<script defer data-domain=\"docs.acme.com\" src=\"https://plausible.io/js/script.js\"></script>", "enabled": true }
],
"bodySnippets": [],
"customCss": ".hero h1 { letter-spacing: -0.02em; }"
}'
Responseapplication/json
200OK
{
"data": {
"enabled": true,
"config": {
"headSnippets": [
{ "id": "plausible", "name": "Plausible", "code": "<script defer data-domain=\"docs.acme.com\" src=\"https://plausible.io/js/script.js\"></script>", "enabled": true }
],
"bodySnippets": [],
"customCss": ".hero h1 { letter-spacing: -0.02em; }"
},
"updatedAt": "2026-11-10T14:03:22.000Z",
"redeploy": { "triggered": true, "buildId": "b2f1c3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d" }
}
}
Product
Resources
Company
© 2026 SyntextBuilt with Syntext