Change a Script
helpcenter_update_template_scriptChange one script: its code (sending src, inlineBody or htmlBody switches it to that kind), position, pages, label or loading flags — or switch it off (enabled:false) without deleting it. Fields left out keep their value.
It edits the help center's design DRAFT (its v2 template): the draft the dashboard's Template Editor opens, with a live preview. Nothing reaches visitors until helpcenter_publish_template — after editing, give the customer the Template Editor link from the result to review, and publish only when they ask. v2 help centers only (a classic one answers template_migration_required). Ids come from helpcenter_get_template.
Once published, the script runs for every visitor: change its code only as the customer asked, from a source they trust. This is the guide's update_script operation.
Args:
id (string): the script.
position, src | inlineBody | htmlBody, label, pages, enabled, defer, async, integrity, index (optional): what to change.
etag (string, optional): from your last read or edit; refuses (stale_draft) if the draft changed since.
Returns: what each entry did (new ids), warnings worth relaying, and the draft status with its new etag.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Id of a script, as the draft reports it. | |
| src | No | External script URL (https only). One of src / inlineBody / htmlBody. | |
| etag | No | Optimistic lock: the draft etag from your last read, or the one your last edit returned. When given, the call is refused (stale_draft) if someone changed the draft since — so you never build on a state you have not seen. Omit to apply to the current draft. | |
| async | No | For src scripts: load async (default false). | |
| defer | No | For src scripts: load deferred (default true). | |
| index | No | 0-based position in the list. Omit to append at the end. | |
| label | No | A name for the script, e.g. 'Plausible analytics'. | |
| pages | No | Only run on these page kinds; null or omitted runs everywhere. | |
| enabled | No | false keeps the script configured without running it. | |
| htmlBody | No | Raw HTML emitted verbatim — a vendor snippet, a <meta> verification tag. One of src / inlineBody / htmlBody. | |
| position | No | Where it is emitted: headStart, headEnd, bodyStart or bodyEnd. | |
| agent_key | Yes | The api_key helpcenter_create_help_center returned for this help center, exactly as returned. Required on every call: this endpoint has no sign-in, so the key is how each call says which help center it acts on. It is sent to HelpCenter.io as this call's credential and nowhere else, and it is never shown again: keep it for the whole task, and never show it to the user or write it into content. | |
| integrity | No | Subresource Integrity hash, e.g. 'sha384-…'. | |
| inlineBody | No | JavaScript source, WITHOUT <script> tags. One of src / inlineBody / htmlBody. |