Save a script version
/scripts/{slug}Saves the files you send as the script's next version. The save is refused unless base_version is the script's latest version, so an edit made meanwhile in the app or anywhere else is never overwritten.
Scope | Heavy call | Long poll | CLI |
|---|---|---|---|
| Yes | No |
|
Guidance
The usual loop: Get a script with
include=source, edit the files, Validate a script, then save withbase_versionset to the version you read.Send the whole file set every time. A file you leave out is removed from the new version.
On
409 version_conflict, someone saved first.error.details.latest_versionhas the latest number. Read that version, re-apply your change to its files, and save again with the newbase_version. Sending the latest number without re-reading overwrites their change in the new version.The version check runs before the code is checked, so a stale
base_versionanswers409even when the code also has errors.A save always adds a version; older versions stay readable as
slug@N. To go back, save an older version's files on top.The path takes the bare slug only.
slug@Nanswers400 invalid_request. When one of your studies shares the slug, addkind.It is a heavy call. On
429 busy, wait forRetry-Afterand send it again. A retry after the first save landed gets409 version_conflict: read the script to confirm your version is there.
Path parameters
Name | Type | Description |
|---|---|---|
| string | Your script's bare slug |
Query parameters
Name | Type | Required | Default | Description |
|---|---|---|---|---|
| string | No | None |
|
Request body
Field | Type | Required | Description |
|---|---|---|---|
| array of File | Yes | The whole file set for the new version. 1 to 50 files, 2 MB in all |
| integer | Yes | The version your edit started from |
| string | No | Recorded on the new version |
Response
200 with the Script at its new version, without files.
Status codes
Status | Code | Meaning |
|---|---|---|
| - | The new version was saved |
|
| The path is not a bare slug, the body is not JSON, |
|
| You cannot change this script |
|
| You have no script with that slug |
|
| The script is past |
|
| A study shares the slug. Add |
|
| The code has errors. |
|
| Past your heavy calls at once. |
