> 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/structure.md).

# Structure

A Sub0 endpoint is a resource with one or more actionables.

The resource defines the API surface.

The actionables define what happens when it runs.

### Endpoint shape

```json
{
  "id": "user-signup-01",
  "resource": "user-signup",
  "tokenize": {
    "type": "JWT",
    "encryption_key": "$ENV.JWT_KEY"
  },
  "actionables": [
    {
      "id": 1,
      "mode": "QUERY",
      "sql_query": {
        "query": "INSERT INTO users (email) VALUES ($1)",
        "parameters": ["email"]
      }
    }
  ],
  "returnables": ["id", "email", "token"]
}
```

### Core endpoint properties

| Property                        | Purpose                                  |
| ------------------------------- | ---------------------------------------- |
| `id`                            | Unique endpoint ID                       |
| `resource`                      | Route name                               |
| `maintenance`                   | Temporarily disables the endpoint        |
| `tokenize`                      | Issues a token                           |
| `protected`                     | Requires a valid token                   |
| `cacheable`                     | Caches the response                      |
| `queue`                         | Queues the whole resource                |
| `parallel`                      | Runs actionables concurrently            |
| `run_in_background`             | Returns before work completes            |
| `returnables`                   | Controls the final response              |
| `combine_returned_results_from` | Merges results from selected actionables |
| `actionables`                   | Lists the operations to run              |

### Core actionable properties

| Property                      | Purpose                                    |
| ----------------------------- | ------------------------------------------ |
| `id`                          | Unique actionable ID inside the resource   |
| `mode`                        | `QUERY`, `HTTPREQUEST`, or `UPLOAD`        |
| `sql_query`                   | SQL operation                              |
| `mongo_query`                 | MongoDB operation                          |
| `http`                        | External HTTP request                      |
| `uploads`                     | File upload rules                          |
| `payload_validation`          | Request validation                         |
| `hashables`                   | Hash fields before use                     |
| `verify_hashables`            | Verify hashed values                       |
| `generators`                  | Generate IDs and similar values            |
| `depends_on`                  | Reuse outputs from other actions           |
| `returnables`                 | Fields to return from this action          |
| `main_returnable`             | Marks the primary response                 |
| `cacheable`                   | Caches this action                         |
| `queue`                       | Queues this action                         |
| `retries`                     | Retries failed execution                   |
| `broadcast_websocket_message` | Emits a WebSocket message                  |
| `cron_job`                    | Schedules the action                       |
| `no_op`                       | Runs only when called through `depends_on` |

### Execution modes

#### `QUERY`

Use `sql_query` for SQL databases.

Use `mongo_query` for MongoDB.

#### `HTTPREQUEST`

Use this to call third-party APIs or internal services.

```json
"mode": "HTTPREQUEST",
"http": {
  "url": "https://api.example.com",
  "method": "POST",
  "headers": {},
  "request_body": {}
}
```

#### `UPLOAD`

Use this for file uploads and file deletion.

```json
"mode": "UPLOAD",
"uploads": {
  "max_file_uploads": 1,
  "allowed_mimetypes": ["image/png"]
}
```

### Response shaping

Use `returnables` to control what comes back to the client.

```json
"returnables": [
  "name",
  "email",
  "address.city",
  "users.0.name"
]
```

Rules:

* Dot notation reads nested fields.
* Array indices are supported.
* `"ignore:field"` excludes a field.

If you do not set `main_returnable`, Sub0 returns the last actionable result by default.

### How execution works

* Actionables run in order by default.
* Set `parallel: true` only when actions do not depend on each other.
* Use `depends_on` when one action needs another action's output.

### Next step

Move to [Accessors](/sub0/apis-abi/accessors.md) to see how values are resolved at runtime.


---

# 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/structure.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.
