pagehive

put_script

Create or replace one script file in the draft.

Draft contentChanges dataAll plans

What it does

Create or replace one script file in the draft. It is not parsed as Liquid and is not visible until publish_site. The page keeps the script tag the bot wrote and loads /scripts/name. Live public rows come from /_pagehive/bp.js and bp.query.

Plans

Works on every plan: Free, Basic, Pro and Ultra.

Parameters

NameTypeAbout
site_idrequiredstringThe id of the site. list_sites gives the ids of your sites.
namerequiredstringThe script's file name, such as menu.js. Pages load it from /scripts/<name>.
sourcerequiredstringThe JavaScript.
messagestringA short note for the version history, like a commit message.
verbosebooleantrue lists every file and page of the draft. Otherwise the response lists only what this call changed, plus draft totals.

Example

Call put_script with these arguments:

{
  "site_id": "01a1…",
  "name": "menu.js",
  "source": "document.querySelector('#menu')?.addEventListener('click',()=>document.body.classList.toggle('open'))"
}

Ids like 01a1… stand for your own. list_sites and list_tables give you the real ones.

Related guides