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

# HTTP and request contracts

> Authenticate, address state, choose a route, and check request and response contracts.

Use the same authenticated HTTP client across Adapt-1 workflows. The task determines the request body and the state it can change.

## Base URL and key

```text API base theme={null}
https://rei-neuroadapt-api.reilabs.org/api/v1
```

```http Required headers theme={null}
Authorization: Bearer <ADAPT1_API_KEY>
Content-Type: application/json
```

Set `ADAPT1_API_KEY` in a server-side environment or secret store. Do not send it to browser clients, include it in prompts, or commit it with examples. The [quickstart](/docs/neuroadapt/quickstart) includes cURL, Python, and server-side JavaScript requests.

When using this versioned base, append `/domains` or `/memory/query`, not another `/api/v1`. System routes such as `/version` live at the host root rather than under the versioned base.

## Identity and task scope

| Identifier                | What it controls                                                                   |
| ------------------------- | ---------------------------------------------------------------------------------- |
| Bearer token              | The authenticated owner and effective hosted session identity                      |
| `domain_id`               | A task contract and its scoped evidence and learned state                          |
| Body `session_id`         | A compatibility field on routes that require it; not a tenant selector             |
| Episode or interaction ID | An application-defined sequence or interaction boundary, not a new owner or Domain |

Use `"session_id": "ignored"` where a request requires the field. The hosted service derives the effective session from the bearer token. Changing the placeholder does not isolate State-gateway records.

Use a fresh `domain_id` for an independent tutorial run. Keep the same Domain when reconnecting to compatible retained task state. Do not clear an existing Domain as an implicit setup step.

## Match the request to the operation

| Application operation       | Route relative to the API base       | Request content                                                      |
| --------------------------- | ------------------------------------ | -------------------------------------------------------------------- |
| Create a task scope         | `POST /domains`                      | Domain ID and the task declaration                                   |
| Submit an observation       | `POST /domains/{domain_id}/events`   | Event type and the observed values                                   |
| Request a current result    | `POST /domains/{domain_id}/query`    | Question, applicable context, and requested result fields            |
| Return a measured outcome   | `POST /domains/{domain_id}/feedback` | Outcome and the binding to the executed decision or relevant context |
| Inspect supporting evidence | `POST /domains/{domain_id}/explain`  | The documented explanation request, not an arbitrary query payload   |
| Query continuing evidence   | `POST /memory/query`                 | `session_id`, `user_message`, and optional retrieval controls        |

A configuration fragment in a guide is not a complete request unless labeled as one. Keep application-only settings, trace IDs, executor timing, and private evaluation fields outside the API body unless the selected route explicitly accepts them.

## Schema coverage

<Note>
  The checked-in [OpenAPI snapshot](/neuroadapt-openapi.json) does **not yet describe every learning workflow in these guides**. Do not treat a successful validation against a permissive object schema as proof that a learning configuration is supported.
</Note>

| Surface                                                            | Documentation to use                                                                                                                                                          |
| ------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| State query, correction, batch storage, and state-summary requests | The corresponding typed schemas and endpoint definitions in the OpenAPI snapshot                                                                                              |
| Domain learning and Discovery configuration                        | The relevant Domain guide and its exact configuration example; the snapshot's Domain-create definition omits `learning`                                                       |
| Domain query context and learning controls                         | The relevant workflow guide; the snapshot's query definition does not enumerate all documented context and learning controls                                                  |
| Decision-bound or context-bound feedback                           | [Feedback guide](/docs/neuroadapt/make-behavior-improve-from-feedback); the snapshot omits documented fields such as `decision_id`, `relation`, `policy`, and `feedback_kind` |
| Numeric trajectory configuration                                   | [Machina configuration](/docs/machina/configuration); trajectory routes are not included in this OpenAPI snapshot                                                             |

The gaps above describe the checked-in documentation snapshot, not a test of a deployed service. A guide documents an intended contract; it does not replace deployment verification. Before deploying an integration, confirm the selected route against the schema for that deployment and run a dedicated integration test. If the deployment rejects a documented field, keep the validation error and resolve the mismatch rather than silently removing a required learning setting.

When generating a client, distinguish **schema-validated fields**, **guide-documented fields**, and **live-tested behavior**. Do not invent missing request or response models to make client generation pass.

## Reading and learning are separate controls

For the documented Domain prediction workflow, the read request uses:

```json Read controls · request fragment theme={null}
{
  "update_memory_state": false,
  "allow_exploration": false
}
```

`update_memory_state` and `allow_exploration` serve different purposes. Turning exploration off is not a general freeze switch. A retained-use or frozen-evaluation interval also excludes event and feedback writes and checks the applicable learner-state identity or versions when exposed. Trajectory workflows have their own operation semantics; do not copy Domain-query flags into trajectory requests.

## Handle the result at two levels

<Steps>
  <Step title="Check transport and shape">
    Check the HTTP status, decode JSON, and validate the fields needed by your application. A `200` response alone does not establish that a learner consumed an observation.
  </Step>

  <Step title="Check the workflow outcome">
    For event ingestion, inspect learner eligibility. For a transition prediction, require `transition_prediction.status == "predicted"` before using predicted values. For feedback, inspect `credit_assignment.contextual_learning_applied` and the relevant sample count. Missing diagnostics are not success.
  </Step>

  <Step title="Keep the evidence needed to debug">
    Preserve sanitized request bodies, response bodies, Domain IDs, admission reasons, and the operation actually executed. Exclude credentials. Treat stored observations and traces as potentially sensitive application data.
  </Step>
</Steps>

## Timeouts and retries

Use a finite timeout. A timed-out write may have been applied even when the client received no response. The examples therefore do not automatically retry mutations. Do not assume that an event ID or interaction ID provides idempotency unless the route documents that guarantee.

For an ambiguous write, stop the ordered loop, inspect the relevant state, and reconcile the request before submitting it again. See [errors and reliability](/docs/neuroadapt/errors-and-reliability) and [operations and retries](/docs/neuroadapt/operational-behavior-and-retries).

<CardGroup cols={2}>
  <Card title="First API call" icon="terminal" href="/docs/neuroadapt/quickstart">
    Send a read-only request in your preferred language.
  </Card>

  <Card title="First learned result" icon="arrow-right" href="/docs/neuroadapt/first-learned-result">
    Follow a complete observation-to-prediction example.
  </Card>
</CardGroup>
