> For the complete documentation index, see [llms.txt](https://docs.lingoql.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.lingoql.com/sub0/apis-abi/accessors.md).

# Accessors

Accessors let Sub0 resolve values at runtime.

They remove hardcoded values from your API definitions.

### Context accessors

Use these to read from the incoming request or environment.

| Accessor    | Reads from            | Example             |
| ----------- | --------------------- | ------------------- |
| `$ENV.`     | Environment variables | `$ENV.JWT_KEY`      |
| `$PAYLOAD.` | Request body          | `$PAYLOAD.email`    |
| `$HEADER.`  | Request headers       | `$HEADER.x-api-key` |

```json
"encryption_key": "$ENV.JWT_KEY"
```

```json
"parameters": ["$PAYLOAD.email"]
```

```json
"x-api-key": "$HEADER.x-api-key"
```

### System accessors

Use these when Sub0 should generate or inject the value.

| Accessor      | Purpose           | Example                    |
| ------------- | ----------------- | -------------------------- |
| `$DATETIME`   | Current timestamp | `created_at`, `updated_at` |
| `$GENERATOR.` | Generated IDs     | `$GENERATOR.UUID`          |

Supported generators:

* `UUID`
* `ULID`
* `KSUID`
* `NANOID`
* `CUID`
* `CUID2`
* `SHORTUUID`
* `SLUGID`
* `BSON`
* `UNIQID`

```json
"parameters": ["name", "email", "$DATETIME"]
```

```json
{
  "generate": "KSUID",
  "for": "id"
}
```

### Protected accessors

Use these after token verification on protected endpoints.

| Accessor      | Purpose                                  | Example         |
| ------------- | ---------------------------------------- | --------------- |
| `$PROTECTED.` | Claims extracted from the verified token | `$PROTECTED.id` |

```json
"upload_folder": "/gallery/$PROTECTED.id"
```

```json
"parameters": ["$PROTECTED.id"]
```

### Rules that matter

* Accessors work anywhere a value is accepted.
* Nested access works for `$PAYLOAD` and `$PROTECTED`.
* If a value cannot be resolved, the request fails safely.

### Next step

Use accessors with [Payload Validation](/sub0/apis-abi/payload-validation.md) and [Authentication](/sub0/apis-abi/authentication.md) to build safe, dynamic endpoints.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.lingoql.com/sub0/apis-abi/accessors.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
