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

# Local development

> Run RxNote on your machine and call the API on localhost.

For RxNote engineers working in the `rx-note-web` repository. The local app runs the same `/api/v1` code as
production, against the dev database.

**1. Environment**

```bash theme={null}
pnpm env:pull            # writes .env.development from SSM /rxnote-dev/*
```

`INTEGRATION_SECRETS_KEY` must be set (it seals webhook secrets). The API is behind the `PUBLIC_API` flag, which
migration 0102 turns on in the dev database.

**2. Database**

The API's tables come from migration `0102_public_api_v1`. Once per database:

```bash theme={null}
pnpm migrate:run:local 0102_public_api_v1
```

The runner prints its target and refuses anything but the dev database.

**3. Create a test key**

For your own RxNote account (a personal key), or for your organization:

```bash theme={null}
pnpm api:key --email you@example.com
pnpm api:key --email you@example.com --organization
```

The secret (`rxn_test_…`) is printed once. Keys can also be created in the app under **Settings → API**.

**4. Run the app**

```bash theme={null}
pnpm dev
```

With `DISABLE_INNGEST` on (the usual local setup), visits are processed inside the dev server — no Inngest CLI
needed.

**5. Call it**

```bash theme={null}
export RXNOTE_API=http://localhost:3000/api/v1
export RXNOTE_API_KEY=rxn_test_...

curl -X POST "$RXNOTE_API/patients" -H "Authorization: Bearer $RXNOTE_API_KEY" \
  -H "Content-Type: application/json" -d '{ "name": "Test Patient", "age": 42 }'
```

Then follow the [quickstart](/quickstart) with `RXNOTE_API` pointing at localhost — or use **Try it** in the
local docs preview (below) with the *Local development* server selected and your key in the Authorization field.

## Previewing these docs

```bash theme={null}
cd api-docs
pnpm dlx mint dev --port 3333    # http://localhost:3333 — keep this port
```

**Try it** sends requests straight from your browser to the API (no Mintlify proxy), so the API must allow the docs'
origin. Outside production it always allows `http://localhost:3333`; deployed environments allow the origins in
`API_CORS_ORIGINS` (the hosted docs domain), set in SSM.

The API reference is generated from the code: after changing `lib/api/schemas.ts` or `lib/api/openapi.ts`, run
`pnpm api:openapi`. `pnpm check` fails while the generated file is stale.

> [!WARNING]
>
> The dev database is shared. Use synthetic test patients only.


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