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

# Welcome to the Medera API Reference

> REST + WebSocket API for behavioral and mental health.

The Medera API is split across two services that share authentication, tenant context, and audit infrastructure.

<CardGroup cols={2}>
  <Card title="Backend " icon="https://mintcdn.com/medera-357fd587/iC-6rAuwl-0aQSw_/icons/ui/server.svg?fit=max&auto=format&n=iC-6rAuwl-0aQSw_&q=85&s=419656a675042e606aca235afc5f7e5c" horizontal width="40" height="40" data-path="icons/ui/server.svg">
    Tenant + PHI persistence, workflow + deployment lifecycle, EHR + billing integration, real-time channel.
  </Card>

  <Card title="AI Services " icon="https://mintcdn.com/medera-357fd587/iC-6rAuwl-0aQSw_/icons/ui/brain.svg?fit=max&auto=format&n=iC-6rAuwl-0aQSw_&q=85&s=0fdc19884888b6cfb111dd1490535243" horizontal width="40" height="40" data-path="icons/ui/brain.svg">
    Multimodal engines, Neurobehavioral Construct, Care Orchestrator, Medera Voice, clinical NLP.
  </Card>
</CardGroup>

In production the public host is `api.medera.info` and routes to both services through the API gateway.

## Base URLs

| Environment | Backend host                      | AI Services host                    |             |
| :---------- | :-------------------------------- | :---------------------------------- | ----------- |
| Production  | `https://api.medera.info`         | `https://api.medera.info` (proxied) |             |
| Staging     | `https://staging.api.medera.info` | `https://staging.api.medera.info`   |             |
| Sandbox     | `https://sandbox.api.medera.info` | `https://sandbox.api.medera.info`   | Internally: |

* Backend: `http://localhost` (dev) / `http://backend` (Docker)

* AI Services: `http://localhost` (dev) / `http://ai-services` (Docker)

## Authentication

| Surface            | Credential           | Header                                 |                                                          |
| :----------------- | :------------------- | :------------------------------------- | -------------------------------------------------------- |
| End-user requests  | session JWT          | `Authorization: Bearer <jwt>`          |                                                          |
| Server-to-server   | Developer API Key    | `X-API-Key: <key>`                     |                                                          |
| Service-to-service | Internal service key | `X-Service-Key: <key>` (internal only) | See [Authentication Overview](/authentication/overview). |

## Content type

Request and response bodies are JSON.

File uploads use `multipart/form-data`. Recordings, audio, and video uploads use `multer` (Backend) or `UploadFile` (AI Services). Max 150 MB per file.

## Conventions

| Convention  | Detail                                                      |
| :---------- | :---------------------------------------------------------- |
| Pagination  | Cursor-based — `?cursor=...&limit=50`                       |
| Idempotency | Optional `Idempotency-Key` header on POST / PATCH           |
| Versioning  | URL path — `/api/v1/...` implicit, `/api/v2/...` explicit   |
| Rate limits | Per-endpoint, see [Rate Limits](/api-reference/rate-limits) |
| Errors      | JSON `{ error: { code, message, request_id } }`             |

## What's next

<CardGroup cols={3}>
  <Card title="Errors" icon="https://mintcdn.com/medera-357fd587/iC-6rAuwl-0aQSw_/icons/ui/circle-x.svg?fit=max&auto=format&n=iC-6rAuwl-0aQSw_&q=85&s=74d340ae357189568e19e85df38a5744" href="/api-reference/errors" width="40" height="40" data-path="icons/ui/circle-x.svg">
    Error format and common codes.
  </Card>

  <Card title="Rate Limits" icon="https://mintcdn.com/medera-357fd587/iC-6rAuwl-0aQSw_/icons/ui/gauge.svg?fit=max&auto=format&n=iC-6rAuwl-0aQSw_&q=85&s=86d89be1336d48350ae7428fc88988b5" href="/api-reference/rate-limits" width="40" height="40" data-path="icons/ui/gauge.svg">
    Per-tenant limits.
  </Card>

  <Card title="Pagination" icon="https://mintcdn.com/medera-357fd587/iC-6rAuwl-0aQSw_/icons/ui/list.svg?fit=max&auto=format&n=iC-6rAuwl-0aQSw_&q=85&s=06db62b7c458fc4bcf2d5c70ee54b716" href="/api-reference/pagination" width="40" height="40" data-path="icons/ui/list.svg">
    Cursor-based pagination.
  </Card>
</CardGroup>
