> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stellarium.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Built-in variables

> The values a node passes into every request script.

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](https://requestscript.mintlify.app/language/built-in-variables) in the RequestScript docs for the language rules.

Stellarium passes one built-in: `jwt`.

## jwt

`jwt` is the decoded [run token](https://docs.stellarium.sh/concepts/api-clients.md#running-a-script) 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.

| Field | Type | Value |
| - | - | - |
| `iss` | `string` | Always `"stellarium"` |
| `sub` | `string` | The API client's ID (`cli_...`) |
| `aud` | `string` | The public key of the node running the script |
| `org` | `string` | The ID of the organization the API client belongs to, which pays for the run |
| `iat` | `int32` | When the token was issued, in Unix seconds |
| `exp` | `int32` | When the token expires, in Unix seconds |
| `jti` | `string` | The token's unique ID |

For a run made with the node's `API_KEY`, there is no token, and `jwt` is `null`:

```kotlin theme={null}
request Caller {
    if (jwt == null) {
        return "api key"
    }
    return jwt.sub
}
```

### 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:

```kotlin theme={null}
request CheckQuota {
    const quotas: com.example.Quotas

    return quotas.remaining(clientId: jwt.sub, organizationId: jwt.org)
}
```

> [!WARNING]
>
> 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.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.