Skip to main content
A node passes built-in variables into every script it runs with POST /v1/run. A script reads them like any variable. They’re read-only, and their names are reserved. See Built-in variables in the RequestScript docs for the language rules. Stellarium passes one built-in: jwt.

jwt

jwt is the decoded run token the run was made with, as an object. The node has already verified it: it is signed by the operator, unexpired and addressed to this node. For a run made with the node’s API_KEY, there is no token, and jwt is null:

Passing the caller to a function

Use jwt to tell a resource function who is calling, for example to keep a quota per API client:
A function on another node receives these values as ordinary parameters, which the caller can set to anything. Only the node running the script verified the token. Don’t treat a clientId parameter as proof of identity in a function another node calls.

Rules

  • jwt can’t be changed. jwt = ..., jwt.sub = ..., and changes through a variable that holds it, fail the script.
  • You can’t declare a variable named jwt.
A script that breaks either rule fails like any other script that errors at runtime: the node answers 422 with "error": "Script failed", and a billed run is charged for the tokens it executed.