Skip to main content
Every script is exactly one declaration followed by a body in curly braces. The declaration says what kind of script it is, gives it a name and, for contracts, lists its parameters. Nothing may appear before or after the declaration except comments.
The body is a sequence of statements that run from top to bottom until a return is reached or the body ends.

Request scripts

A request is a one-off script. You send it to the server, it runs once, and you get its return value back. Requests don’t take parameters.
Run a request by sending it to POST /run.

Contract scripts

A contract is a script that’s saved on the server and invoked later, optionally with parameters.
A contract declaration has these parts:
  • The path is a dot-separated prefix that organizes contracts, like a namespace. Path segments may be any word, including keywords, so contract if.else.Thing is allowed.
  • The version is covered in Versioning.
  • Parameters are name: type pairs separated by commas, with an optional trailing comma. Parameter names must be unique.
  • A contract with no parameters leaves out the parentheses entirely. Writing empty parentheses, (), is an error.
Inside the body, parameters behave like const variables: you can read them but not reassign them. Save contracts with POST /contracts. See Contracts for the full workflow.

Return values

Whatever a script returns becomes the returnValue of the HTTP response, encoded as JSON:
If a script ends without a return, or uses a bare return, the return value is null. See JSON encoding for how each type is represented.