# API reference

Authentication, the insurance model and every endpoint with a real request and response.

## Authentication

Send your API key as `Authorization: Bearer <key>` on every `/v1` and `/mcp` call (`X-API-Key: <key>` also works on `/v1`). Keys start with `sl_test_` (sandbox accounts) or `sl_live_` (live accounts; keys made before November 2026 start `pc_`), are stored only as a hash, and reach only your own account's connections. A live account keeps a sandbox side: a `sl_test_` key reaches only the sandbox portals and their connections, a key made with `"environment": "live"` only the real ones, and connections say which they are in `environment`. A key made in the sandbox stays a test key when the account goes live; make a live key then. A `read` key can list, look up, run read operations and check a connection, and nothing else.

To rotate without downtime: create a new key with [`POST /v1/api-keys`](https://sidelatch.com/docs/api#ref-post-v1-api-keys) or in the [console](https://sidelatch.com/account), deploy it, then revoke the old one.

**Never in the browser.**Your page gets a link token instead: single use, tied to one user and one portal, and expired after 10 minutes.

## Insurance model

Every insurance carrier returns these shapes, whatever the carrier's own portal calls its fields.

| Operation | Params | Returns |
|---|---|---|
| `list_policies` |  | `Policy[]` |
| `get_policy` | `policy_number` | `Policy` |
| `list_commission_statements` |  | `CommissionStatement[]` |
| `list_claims` |  | `Claim[]` |

### Writes

Where a carrier's portal supports them, carriers also take the agency's service work, the same way for every carrier. Each is a [write](https://sidelatch.com/docs/guides/writes): a `read_write` key, an `Idempotency-Key`, and a connection the user linked with changes allowed. A change or a certificate that needs the carrier's underwriter comes back `submitted` or `pending_review`; read the list operation later for its outcome.

| Operation | Params | Returns |
|---|---|---|
| `report_claim` | `policy_number`, `loss_date`, `description` | `Claim` |
| `add_claim_note` | `claim_number`, `note` | `ClaimNote` |
| `attach_claim_document` (upload) | `claim_number` + a file | `ClaimDocument` |
| `request_certificate` | `policy_number`, `holder_name`, `holder_street`, `holder_city`, `holder_state`, `holder_postal_code`, optional `additional_insured`, `waiver_of_subrogation`, `description` | `Certificate` |
| `list_certificates` |  | `Certificate[]` |
| `download_certificate` | `certificate_id` | the certificate PDF (ACORD 25) |
| `request_policy_change` | `policy_number`, `change_type`, `effective_date`, `details` | `PolicyChange` |
| `list_policy_changes` |  | `PolicyChange[]` |

`change_type` is one of `add_vehicle`, `remove_vehicle`, `add_driver`, `remove_driver`, `change_address`, `add_additional_insured`, `change_coverage`, `cancel`, `other`. `GET /v1/portals` says which of these each carrier offers.

### Policy

| Field | Type | Notes |
|---|---|---|
| `policy_number` | string | The carrier's policy number. |
| `carrier` | string | The carrier's display name. |
| `insured_name` | string | Person or business the policy covers. |
| `line_of_business` | string | `commercial_auto`, `general_liability`, `homeowners`, `workers_comp`, `business_owners`, or the carrier's own code in lower case. |
| `status` | string | Policy: `active`, `cancelled`, `expired`, `pending`. Claim: `open`, `closed`, `denied`. `unknown` if unmapped. |
| `effective_date` | date | Coverage start. |
| `expiration_date` | date | Coverage end. |
| `annual_premium` | number | In dollars. |

### CommissionStatement

| Field | Type | Notes |
|---|---|---|
| `statement_id` | string | The carrier's statement id. |
| `carrier` | string | The carrier's display name. |
| `period` | string | Month the statement covers, `YYYY-MM`. |
| `total` | number | Commission paid on the statement, in dollars. |
| `lines` | CommissionLine[] | One line per policy on the statement. |

### CommissionLine

| Field | Type | Notes |
|---|---|---|
| `policy_number` | string | The carrier's policy number. |
| `premium` | number | Premium the commission was paid on. |
| `rate` | number | Commission rate as a fraction: `0.12` is 12%. |
| `amount` | number | Commission paid for this policy. |

### Claim

| Field | Type | Notes |
|---|---|---|
| `claim_number` | string | The carrier's claim number. |
| `policy_number` | string | The carrier's policy number. |
| `carrier` | string | The carrier's display name. |
| `status` | string | Policy: `active`, `cancelled`, `expired`, `pending`. Claim: `open`, `closed`, `denied`. `unknown` if unmapped. |
| `loss_date` | date | Date of loss. |
| `reported_date` | date | Date the claim was reported. |
| `paid_amount` | number | Paid so far, in dollars. |

### Certificate

| Field | Type | Notes |
|---|---|---|
| `certificate_id` | string |  |
| `policy_number` | string | The carrier's policy number. |
| `carrier` | string | The carrier's display name. |
| `holder_name` | string |  |
| `status` | string | Policy: `active`, `cancelled`, `expired`, `pending`. Claim: `open`, `closed`, `denied`. `unknown` if unmapped. |
| `issued_date` | datetime.date \| None |  |
| `additional_insured` | bool |  |
| `waiver_of_subrogation` | bool |  |

### PolicyChange

| Field | Type | Notes |
|---|---|---|
| `change_id` | string |  |
| `policy_number` | string | The carrier's policy number. |
| `carrier` | string | The carrier's display name. |
| `change_type` | string |  |
| `status` | string | Policy: `active`, `cancelled`, `expired`, `pending`. Claim: `open`, `closed`, `denied`. `unknown` if unmapped. |
| `effective_date` | date | Coverage start. |
| `submitted_date` | date |  |
| `premium_change` | float \| None |  |

### ClaimNote

| Field | Type | Notes |
|---|---|---|
| `note_id` | string |  |
| `claim_number` | string | The carrier's claim number. |
| `created_date` | date |  |

## Endpoints

Every endpoint takes and returns JSON. Want to try calls in the browser? Use the [interactive explorer](https://sidelatch.com/docs/explorer) or fetch [`openapi.json`](https://sidelatch.com/openapi.json).

**Base URL**`https://sidelatch.com`

## Portals

### GET `/v1/portals`

List portals. Every portal you can connect to, its operations with example params, and its health over the last 24 hours.

**Request**

```http
GET /v1/portals
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "portals": [
    {
      "portal": "demo_carrier",
      "display_name": "Demo Carrier",
      "sandbox": true,
      "health": {
        "status": "healthy",
        "canaries_24h": 12,
        "results_24h": {
          "ok": 12
        }
      },
      "operations": [
        {
          "operation": "list_policies",
          "example_params": {}
        },
        {
          "operation": "get_policy",
          "example_params": {
            "policy_number": "CA-100231"
          }
        }
      ]
    }
  ]
}
```

### POST `/v1/portal-requests`

Request a portal. Ask us to support a portal that isn't listed yet, or for more from one you already use (new screens, documents or fields): pass its `portal`. We add to it; every operation you use today keeps working as it is, and the new ones appear in `/v1/portals` once they pass our checks. Asking again for the same site while it's open returns the same request (more notes are added to it). Up to 10 requests a day.

| Name | In | Type | Description |
|---|---|---|---|
| `name` | body | string | The portal, as your users call it. Up to 80 characters. |
| `url` | body | string | Its sign-in page. |
| `notes` optional | body | string | What you need from it. Up to 1,000 characters. |
| `portal` optional | body | string | For more from a portal you use: its name from `/v1/portals`. The response's `adds_to` names it. A request for a site you already use is treated the same way. |

**Request**

```http
POST /v1/portal-requests
Authorization: Bearer sl_live_...

{
  "name": "Acme Carrier Agent Portal",
  "url": "https://agents.acmecarrier.com/login",
  "notes": "Policies and commission statements for each agency"
}
```

**Response 200**

```json
{
  "id": "preq_6f1c...",
  "name": "Acme Carrier Agent Portal",
  "url": "https://agents.acmecarrier.com/login",
  "host": "agents.acmecarrier.com",
  "notes": "Policies and commission statements for each agency",
  "status": "requested",
  "portal": null,
  "created_at": 1795000000.0,
  "updated_at": 1795000000.0
}
```

Read-only keys can't file requests.

### GET `/v1/portal-requests`

List your portal requests. Your requests, newest first. `status` moves through `requested`, `building`, `testing` and `live` (or `declined`). Once live, `portal` is the name to use in `/v1/link-tokens`.

**Request**

```http
GET /v1/portal-requests
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "requests": [
    {
      "id": "preq_6f1c...",
      "name": "Acme Carrier Agent Portal",
      "host": "agents.acmecarrier.com",
      "status": "live",
      "portal": "acme_carrier"
    }
  ]
}
```

## Linking

### POST `/v1/link-tokens`

Create a link token. A single-use token that lets one of your users link one portal. It expires in 10 minutes and is safe to send to the browser.

| Name | In | Type | Description |
|---|---|---|---|
| `user_id` | body | string | Your id for the user. Up to 200 characters. |
| `portal` | body | string | A portal name from `/v1/portals`. |
| `writes` optional | body | boolean | `true` (default): you may run the portal's write operations on this connection, and the window tells the user so. `false`: a read-only connection; the window says you can only read. See [Writes](https://sidelatch.com/docs/guides/writes). |

**Request**

```http
POST /v1/link-tokens
Authorization: Bearer sl_live_...

{
  "user_id": "agency-42",
  "portal": "demo_carrier"
}
```

**Response 200**

```json
{
  "link_token": "gAAAAABn...",
  "expires_in": 600
}
```

`404` for an unknown portal. `403` when a sandbox account asks for a live portal.

### POST `/v1/links`

Link from your own screen. Sign a user in without the connect window: your screen collects the login and your backend sends it here. The reply is a connection, or a [challenge](https://sidelatch.com/docs/guides/connect-window#challenges) to show the user. Use the connect window unless you need your own screens: with it, the password never passes through your code. Portals whose check only works on their own page answer `login_blocked`; open the connect window for those.

| Name | In | Type | Description |
|---|---|---|---|
| `user_id` | body | string | Your id for the user. |
| `portal` | body | string | The portal to link. |
| `username` | body | string | The user's portal username. |
| `password` | body | string | The user's portal password. Stored encrypted; never returned. |

**Request**

```http
POST /v1/links
Authorization: Bearer sl_live_...

{
  "user_id": "agency-42",
  "portal": "demo",
  "username": "agent4",
  "password": "..."
}
```

**Response 200**

```json
{
  "status": "challenge_required",
  "link_id": "L6t8rImc...",
  "challenge": {
    "type": "choice",
    "message": "Where should we send your code?",
    "inputs": [
      {
        "name": "code",
        "type": "select",
        "label": "Where should we send your code?",
        "answer": "code",
        "options": [
          {
            "value": "sms",
            "label": "Text ***-***-0142"
          },
          {
            "value": "email",
            "label": "Email a***@example.com"
          }
        ]
      }
    ],
    "expires_in": 300,
    "attempts_left": 3,
    "step": 1,
    "max_steps": 6
  }
}
```

With no challenge the reply is `{"status": "connected", "connection_id": ..., "portal": ...}`. Needs a `read_write` key.

### POST `/v1/links/{link_id}/answer`

Answer a challenge. Send what the user entered, shaped by the challenge's `inputs`: `code` for a code, a choice (the option's `value`) or a CAPTCHA; `answers` for security questions; an empty body for a phone approval, repeated while the reply is `pending`.

| Name | In | Type | Description |
|---|---|---|---|
| `link_id` | path | string | From the challenge reply. |
| `code` optional | body | string | The code, the chosen option's value, or the CAPTCHA text. |
| `answers` optional | body | object | Security questions: input name to answer. |
| `totp_secret` optional | body | string | An authenticator setup key, to answer this step without the user from now on. |

**Request**

```http
POST /v1/links/{link_id}/answer
Authorization: Bearer sl_live_...

{
  "code": "email"
}
```

**Response 200**

```json
{
  "connection_id": "conn_8f2c41d07a9b4e6f",
  "portal": "demo",
  "status": "connected"
}
```

The reply is a connection, the next challenge, `pending`, or an error (`challenge_failed`, `link_expired`, `locked_out`).

## Connections

### GET `/v1/connections`

List connections. Every account your users have linked, newest last.

| Name | In | Type | Description |
|---|---|---|---|
| `user_id` optional | query | string | Only this user's connections. |

**Request**

```http
GET /v1/connections
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "connections": [
    {
      "connection_id": "conn_8f2c41d07a9b4e6f",
      "user_id": "agency-42",
      "portal": "demo_carrier",
      "status": "connected",
      "created_at": 1795700000.0
    }
  ]
}
```

### GET `/v1/connections/{conn_id}`

Get a connection. One connection: its status and reason, when it last worked, and what keeps it signed in without the user.

| Name | In | Type | Description |
|---|---|---|---|
| `conn_id` | path | string | The connection id. |

**Request**

```http
GET /v1/connections/{conn_id}
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "connection_id": "conn_8f2c41d07a9b4e6f",
  "user_id": "agency-42",
  "portal": "demo_carrier",
  "status": "connected",
  "created_at": 1795700000.0,
  "linked_at": "2026-11-26T15:04:05Z",
  "last_success_at": "2026-11-28T09:12:44Z",
  "last_run_at": "2026-11-28T09:12:44Z",
  "status_changed_at": "2026-11-26T15:04:05Z",
  "unattended": {
    "saved_session": true,
    "authenticator_key": false,
    "email_forwarding": false,
    "keepalive": false
  }
}
```

When `status` is `reconnect_needed`, `reason` says [why](https://sidelatch.com/docs/errors#reasons).

### GET `/v1/connections/{conn_id}/runs`

List a connection's runs. Recent runs on one connection, newest first: what was asked, how it ended and the steps taken.

| Name | In | Type | Description |
|---|---|---|---|
| `conn_id` | path | string | The connection id. |
| `status` optional | query | string | `queued`, `running`, `completed` or `failed`. |
| `limit` optional | query | integer | Up to 100. Default 20. |
| `cursor` optional | query | string | `next_cursor` from the page before. |

**Request**

```http
GET /v1/connections/{conn_id}/runs
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "data": [
    {
      "id": "run_5d1e...",
      "object": "run",
      "connection_id": "conn_8f2c41d07a9b4e6f",
      "user_id": "agency-42",
      "portal": "demo_carrier",
      "operation": "list_policies",
      "source": "api",
      "mode": "sync",
      "status": "completed",
      "error": null,
      "http_status": 200,
      "duration_ms": 412,
      "steps": [
        {
          "step": "session_reused"
        },
        {
          "step": "portal_request",
          "method": "GET",
          "status": 200,
          "ms": 96
        }
      ],
      "created_at": "2026-11-26T15:04:05Z",
      "started_at": "2026-11-26T15:04:05Z",
      "finished_at": "2026-11-26T15:04:05Z"
    }
  ],
  "has_more": false,
  "next_cursor": null
}
```

### GET `/v1/connections/{conn_id}/sandbox-fault`

Sandbox: see a simulated failure. Sandbox carriers only (`demo_carrier`, `demo_mutual`). The failure set on this connection, if any, and the ones you can set. See [Break a sandbox connection](https://sidelatch.com/docs/quickstart#sandbox-faults).

| Name | In | Type | Description |
|---|---|---|---|
| `conn_id` | path | string | The connection id. |

**Request**

```http
GET /v1/connections/{conn_id}/sandbox-fault
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "connection_id": "conn_8f2c41d07a9b4e6f",
  "portal": "demo_carrier",
  "active": {
    "kind": "password_changed",
    "label": "Change the password",
    "until_relink": true,
    "set_at": "2026-12-03T15:10:00Z",
    "expires_at": null,
    "expect": "The read fails with reconnect_needed ..."
  },
  "available": [
    {
      "kind": "session_expired",
      "label": "Expire the session",
      "what": "...",
      "expect": "..."
    }
  ]
}
```

`400` `bad_request` on a portal that isn't a sandbox carrier.

### PUT `/v1/connections/{conn_id}/sandbox-fault`

Sandbox: simulate a failure. Make this connection's next runs meet a failure a real portal produces, to see what your app gets. Only this connection is affected, and it never alerts anyone.

| Name | In | Type | Description |
|---|---|---|---|
| `conn_id` | path | string | The connection id. |
| `kind` | body | string | `session_expired`, `password_changed`, `code_required` (`demo_mutual`), `portal_down` or `site_changed`. |

**Request**

```http
PUT /v1/connections/{conn_id}/sandbox-fault
Authorization: Bearer sl_live_...

{
  "kind": "password_changed"
}
```

**Response 200**

```json
{
  "connection_id": "conn_8f2c41d07a9b4e6f",
  "portal": "demo_carrier",
  "active": {
    "kind": "password_changed",
    "label": "Change the password",
    "until_relink": true,
    "set_at": "2026-12-03T15:10:00Z",
    "expires_at": null,
    "expect": "The read fails with reconnect_needed ..."
  },
  "available": [
    {
      "kind": "session_expired",
      "label": "Expire the session",
      "what": "...",
      "expect": "..."
    }
  ]
}
```

`400` if this portal can't simulate that kind.

### DELETE `/v1/connections/{conn_id}/sandbox-fault`

Sandbox: undo a simulated failure. Takes the failure away. A connection already moved to `reconnect_needed` stays there until the user signs in again, as it would after a real failure.

| Name | In | Type | Description |
|---|---|---|---|
| `conn_id` | path | string | The connection id. |

**Request**

```http
DELETE /v1/connections/{conn_id}/sandbox-fault
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "connection_id": "conn_8f2c41d07a9b4e6f",
  "portal": "demo_carrier",
  "active": null,
  "available": []
}
```

### POST `/v1/connections/{conn_id}/relink-link`

Make a sign-in link. A hosted page where this user signs in again, for when the connection needs it and they are not in your app. Single use; the connection id stays the same.

| Name | In | Type | Description |
|---|---|---|---|
| `conn_id` | path | string | The connection id. |

**Request**

```http
POST /v1/connections/{conn_id}/relink-link
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "url": "https://sidelatch.com/connect?token=gAAAAB...",
  "expires_in": 600
}
```

### POST `/v1/connections/{conn_id}/run`

Run an operation. Read or write through a connection. If the portal has logged the user out, we sign in again first. Operations marked `writes` in `/v1/portals` change data in the portal: they need a `read_write` key, are never cached and never retried by us. Send an `Idempotency-Key` header with each write; a retry with the same key gets the first answer back (header `Idempotent-Replayed: true`) instead of writing twice. Operations that return a file (`returns: "file"`) answer with the file's bytes and content type, not JSON.

| Name | In | Type | Description |
|---|---|---|---|
| `conn_id` | path | string | The connection id. |
| `Idempotency-Key` optional | header | string | For writes: any unique string, up to 200 characters. Kept 24 hours. |
| `operation` | body | string | An operation the portal offers. |
| `params` optional | body | object | The operation's parameters. |
| `async` optional | body | boolean | Answer `202` with a queued [run](https://sidelatch.com/docs/concepts#runs) at once instead of waiting for the portal. Not for uploads. |
| `dry_run` optional | body | boolean | Check the key, the connection, the operation and its params without calling the portal. Nothing is sent or changed. |
| `max_age` optional | body | integer | Accept a stored result up to this many seconds old instead of reading the portal again. `0` always reads live. Omitted: live, except operations whose data changes slowly (a monthly statement), which are reused for a while. |

**Request**

```http
POST /v1/connections/{conn_id}/run
Authorization: Bearer sl_live_...

{
  "operation": "get_policy",
  "params": {
    "policy_number": "CA-100231"
  }
}
```

**Response 200**

```json
{
  "data": {
    "policy_number": "CA-100231",
    "carrier": "Demo Carrier",
    "insured_name": "Riverside Plumbing LLC",
    "line_of_business": "commercial_auto",
    "status": "active",
    "effective_date": "2026-03-01",
    "expiration_date": "2027-03-01",
    "annual_premium": 18450.0
  },
  "cached": false,
  "retrieved_at": "2026-11-26T15:04:05+00:00",
  "run_id": "run_5d1e..."
}
```

`cached` says whether the result came from a recent read; `retrieved_at` is when the portal was read; `run_id` names the [run](https://sidelatch.com/docs/concepts#runs) (null for a cached answer). An operation that returns a file (`returns: "file"` in `/v1/portals`: a statement, an export, a letter) answers with the file itself, not JSON: a `Content-Type` and filename that match its bytes (PDF, Excel, CSV, Word, images and more, even where the portal mislabels them) in `Content-Disposition`. Failures use the codes in [Errors](https://sidelatch.com/docs/errors).

### POST `/v1/connections/{conn_id}/upload`

Upload a file. Run an operation that takes a file (`upload: true` in `/v1/portals`), such as a claim document. Send `multipart/form-data`. Up to 10 MB. Uploads are writes: `read_write` key, `Idempotency-Key` recommended.

| Name | In | Type | Description |
|---|---|---|---|
| `conn_id` | path | string | The connection id. |
| `operation` | form | string | An upload operation. |
| `params` optional | form | JSON object | The operation's other parameters. |
| `file` | form | file | The file. |

**Request**

```http
POST /v1/connections/{conn_id}/upload
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "data": {
    "document_id": "DOC-1a2b3c4d",
    "claim_number": "CL-88123",
    "filename": "estimate.pdf",
    "size_bytes": 48211
  },
  "retrieved_at": "2026-11-26T15:04:05+00:00"
}
```

`413` `file_too_large` over 10 MB. `400` `not_an_upload` for an operation that takes no file.

### GET `/v1/connections/{conn_id}/requests`

Request log. This connection's recent calls, when `request_logging` is on in settings: operation, outcome, status, timing, and the params and response with personal details removed (names, emails, phones, addresses, account and ID numbers, secrets). Stored encrypted and deleted after 3 days.

| Name | In | Type | Description |
|---|---|---|---|
| `conn_id` | path | string | The connection id. |
| `limit` optional | query | integer | 1 to 500. Defaults to 100, newest first. |

**Request**

```http
GET /v1/connections/{conn_id}/requests
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "retention_days": 3,
  "requests": [
    {
      "id": "req_0f3e...",
      "at": 1795700000.0,
      "operation": "list_policies",
      "outcome": "ok",
      "status": 200,
      "duration_ms": 412,
      "request": {},
      "response": [
        {
          "policy_number": "CA-100231",
          "insured_name": "[redacted]"
        }
      ]
    }
  ]
}
```

### POST `/v1/connections/{conn_id}/mfa-email`

Get a code-forwarding address. An email address for this connection's sign-in codes. Show it to the user and ask them to forward the portal's code emails there (a mail rule). When the portal asks for an emailed code on a later sign-in, we use the forwarded code and the connection keeps working instead of needing a relink. We keep only the code, in memory, for a few minutes; the email itself is never stored. Authenticator-app codes are handled by the setup key the connect window offers.

| Name | In | Type | Description |
|---|---|---|---|
| `conn_id` | path | string | The connection id. |

**Request**

```http
POST /v1/connections/{conn_id}/mfa-email
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "address": "mfa+3f9c0d1e2b4a5c6d7e8f9a0b@in.sidelatch.com",
  "senders": []
}
```

`404` `not_enabled` if forwarding is not set up on this server.

### GET `/v1/connections/{conn_id}/consents`

Consent records. What the end user agreed to each time they linked this connection, newest first: the disclosure the connect window showed them (its text and SHA-256), the language, how they signed in (`password`, `browser`, `helper`, or `api` for `POST /v1/links`, where no disclosure is shown), the operations you could run at the time, and when and from which address. Kept after a disconnect, as the record of the authorization.

| Name | In | Type | Description |
|---|---|---|---|
| `conn_id` | path | string | The connection id. |

**Request**

```http
GET /v1/connections/{conn_id}/consents
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "data": [
    {
      "id": "cns_4f1a...",
      "connection_id": "conn_8c2d...",
      "user_id": "user-123",
      "portal": "demo_carrier",
      "method": "password",
      "locale": "en",
      "disclosure": "Acme uses Sidelatch to connect your Demo Carrier account. ...",
      "disclosure_sha256": "9b1f...",
      "scope": {
        "operations": [
          "get_policy",
          "list_policies"
        ],
        "writes": []
      },
      "ip": "203.0.113.9",
      "user_agent": "Mozilla/5.0 ...",
      "at": "2026-12-02T15:04:05Z"
    }
  ],
  "has_more": false,
  "next_cursor": null
}
```

### POST `/v1/connections/{conn_id}/schedules`

Schedule a read. Run a read on an interval, from every hour to every seven days. Each turn is an [async run](https://sidelatch.com/docs/concepts#runs): you get `run.completed` (or `run.failed`) and read the answer from `GET /v1/runs/{run_id}` within a day. Reads that return data only; at most 10 per connection. A turn is skipped while the connection needs a relink.

| Name | In | Type | Description |
|---|---|---|---|
| `conn_id` | path | string | The connection id. |
| `operation` | body | string | A read operation. |
| `params` optional | body | object | The operation's parameters. |
| `every_seconds` | body | integer | 3600 to 604800. |

**Request**

```http
POST /v1/connections/{conn_id}/schedules
Authorization: Bearer sl_live_...

{
  "operation": "list_policies",
  "every_seconds": 86400
}
```

**Response 200**

```json
{
  "schedule_id": "sch_1a2b...",
  "object": "schedule",
  "connection_id": "conn_8c2d...",
  "operation": "list_policies",
  "params": {},
  "every_seconds": 86400,
  "next_run_at": "2026-12-02T16:10:00Z",
  "last_run_id": null,
  "created_at": "2026-12-02T15:04:05Z"
}
```

`422` `bad_params` for a write, a file operation, bad params or too many schedules.

### GET `/v1/connections/{conn_id}/schedules`

List schedules. This connection's schedules, with when each runs next and its last run.

| Name | In | Type | Description |
|---|---|---|---|
| `conn_id` | path | string | The connection id. |

**Request**

```http
GET /v1/connections/{conn_id}/schedules
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "data": [
    {
      "schedule_id": "sch_1a2b...",
      "operation": "list_policies",
      "every_seconds": 86400,
      "next_run_at": "2026-12-03T15:10:00Z",
      "last_run_id": "run_5d1e..."
    }
  ],
  "has_more": false,
  "next_cursor": null
}
```

### DELETE `/v1/schedules/{schedule_id}`

Delete a schedule. Stops a schedule. Runs already started finish.

| Name | In | Type | Description |
|---|---|---|---|
| `schedule_id` | path | string | The schedule id. |

**Request**

```http
DELETE /v1/schedules/{schedule_id}
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "schedule_id": "sch_1a2b...",
  "deleted": true
}
```

`404` if there is no such schedule.

### POST `/v1/connections/{conn_id}/canary`

Check a connection. Runs the portal's health check on one connection. Always returns 200; the outcome is in `result`.

| Name | In | Type | Description |
|---|---|---|---|
| `conn_id` | path | string | The connection id. |

**Request**

```http
POST /v1/connections/{conn_id}/canary
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "portal": "demo_carrier",
  "result": "ok"
}
```

### DELETE `/v1/connections/{conn_id}`

Disconnect. Deletes the stored login and sends `connection.deleted`.

| Name | In | Type | Description |
|---|---|---|---|
| `conn_id` | path | string | The connection id. |

**Request**

```http
DELETE /v1/connections/{conn_id}
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "status": "disconnected"
}
```

## Account

### GET `/v1/field-scopes`

Field scopes. The fields each operation returns to your account. Operations not listed return every field.

**Request**

```http
GET /v1/field-scopes
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "field_scopes": {
    "demo_carrier.list_policies": [
      "policy_number",
      "status"
    ]
  }
}
```

### PUT `/v1/field-scopes`

Set field scopes. Return only the fields you use: `{"<portal>.<operation>": [fields]}`. A dotted name keeps one field of a nested object. Everything else is dropped before the answer is cached, logged or returned, so it never reaches you. Send `{}` to return every field again.

| Name | In | Type | Description |
|---|---|---|---|
| `field_scopes` | body | object | Operation to field names. |

**Request**

```http
PUT /v1/field-scopes
Authorization: Bearer sl_live_...

{
  "field_scopes": {
    "demo_carrier.list_policies": [
      "policy_number",
      "status"
    ]
  }
}
```

**Response 200**

```json
{
  "field_scopes": {
    "demo_carrier.list_policies": [
      "policy_number",
      "status"
    ]
  }
}
```

`422` `bad_params` for an unknown operation or field.

### GET `/v1/settings`

Get settings. Your plan, allowed origins and webhook.

**Request**

```http
GET /v1/settings
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "customer_id": "cus_3k9w2m",
  "name": "Acme Agency Software",
  "plan": "sandbox",
  "allowed_origins": [
    "https://dash.acme.com"
  ],
  "webhook_url": "https://api.acme.com/hooks/sidelatch",
  "webhook_secret": "whsec_..."
}
```

### PATCH `/v1/settings`

Update settings. Send only the fields you are changing. Saving a webhook URL for the first time creates a signing secret.

| Name | In | Type | Description |
|---|---|---|---|
| `allowed_origins` optional | body | string[] | Up to 20 origins, like `https://dash.acme.com`. |
| `webhook_url` optional | body | string \| null | A public `https://` URL, or null to turn webhooks off. |
| `request_logging` optional | body | boolean | Keep a redacted, encrypted record of each portal call for 3 days, for debugging (see the request log). Off by default. |
| `background_checks` optional | body | boolean | On by default: we check idle connections every few hours and keep sessions warm, so you hear about broken logins early. Off: we call your users' portals only when you make a request. |

**Request**

```http
PATCH /v1/settings
Authorization: Bearer sl_live_...

{
  "allowed_origins": [
    "https://dash.acme.com"
  ],
  "webhook_url": "https://api.acme.com/hooks/sidelatch"
}
```

**Response 200**

```json
{
  "customer_id": "cus_3k9w2m",
  "name": "Acme Agency Software",
  "plan": "sandbox",
  "allowed_origins": [
    "https://dash.acme.com"
  ],
  "webhook_url": "https://api.acme.com/hooks/sidelatch",
  "webhook_secret": "whsec_..."
}
```

### POST `/v1/settings/webhook-secret`

Rotate the webhook secret. Signs every later event with a new secret. Update your handler right after.

**Request**

```http
POST /v1/settings/webhook-secret
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "webhook_secret": "whsec_..."
}
```

### GET `/v1/api-keys`

List API keys. Keys are shown by their last four characters.

**Request**

```http
GET /v1/api-keys
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "api_keys": [
    {
      "id": "key_5d1e0c7a9f3b",
      "hint": "x7Qa",
      "created_at": 1795700000.0,
      "revoked_at": null
    }
  ]
}
```

### POST `/v1/api-keys`

Create an API key. Returns the new key once. Switch your backend to it, then revoke the old one. A `read` key can never change portal data, mint keys, change settings or create write-enabled MCP links.

| Name | In | Type | Description |
|---|---|---|---|
| `scope` optional | body | string | `read_write` (default) or `read`. |

**Request**

```http
POST /v1/api-keys
Authorization: Bearer sl_live_...

{
  "scope": "read"
}
```

**Response 200**

```json
{
  "id": "key_9a8b7c6d5e4f",
  "api_key": "sl_test_...",
  "scope": "read"
}
```

### DELETE `/v1/api-keys/{key_id}`

Revoke an API key. The key stops working immediately.

| Name | In | Type | Description |
|---|---|---|---|
| `key_id` | path | string | The key id from the list. |

**Request**

```http
DELETE /v1/api-keys/{key_id}
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "status": "revoked"
}
```

### GET `/v1/usage`

Usage. Calls per day, portal, action and outcome, and your connection counts by status.

| Name | In | Type | Description |
|---|---|---|---|
| `days` optional | query | integer | 1 to 365. Defaults to 30. |

**Request**

```http
GET /v1/usage
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "days": 30,
  "calls": [
    {
      "day": "2026-11-26",
      "portal": "demo_carrier",
      "action": "list_policies",
      "outcome": "ok",
      "count": 42
    }
  ],
  "connections": [
    {
      "portal": "demo_carrier",
      "status": "connected",
      "count": 3
    }
  ]
}
```

## Runs

### GET `/v1/runs`

List runs. Every run on your account, newest first.

| Name | In | Type | Description |
|---|---|---|---|
| `connection_id` optional | query | string | Only this connection's runs. |
| `status` optional | query | string | `queued`, `running`, `completed` or `failed`. |
| `limit` optional | query | integer | Up to 100. Default 20. |
| `cursor` optional | query | string | `next_cursor` from the page before. |

**Request**

```http
GET /v1/runs
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "data": [
    {
      "id": "run_5d1e...",
      "object": "run",
      "connection_id": "conn_8f2c41d07a9b4e6f",
      "user_id": "agency-42",
      "portal": "demo_carrier",
      "operation": "list_policies",
      "source": "api",
      "mode": "sync",
      "status": "completed",
      "error": null,
      "http_status": 200,
      "duration_ms": 412,
      "steps": [
        {
          "step": "session_reused"
        },
        {
          "step": "portal_request",
          "method": "GET",
          "status": 200,
          "ms": 96
        }
      ],
      "created_at": "2026-11-26T15:04:05Z",
      "started_at": "2026-11-26T15:04:05Z",
      "finished_at": "2026-11-26T15:04:05Z"
    }
  ],
  "has_more": false,
  "next_cursor": null
}
```

### GET `/v1/runs/{run_id}`

Get a run. One run and its steps. For an async run that has finished, `data` holds the result for a day; if it failed, `failure` holds the error.

| Name | In | Type | Description |
|---|---|---|---|
| `run_id` | path | string | The run id. |

**Request**

```http
GET /v1/runs/{run_id}
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "id": "run_5d1e...",
  "object": "run",
  "connection_id": "conn_8f2c41d07a9b4e6f",
  "user_id": "agency-42",
  "portal": "demo_carrier",
  "operation": "list_policies",
  "source": "api",
  "mode": "sync",
  "status": "completed",
  "error": null,
  "http_status": 200,
  "duration_ms": 412,
  "steps": [
    {
      "step": "session_reused"
    },
    {
      "step": "portal_request",
      "method": "GET",
      "status": 200,
      "ms": 96
    }
  ],
  "created_at": "2026-11-26T15:04:05Z",
  "started_at": "2026-11-26T15:04:05Z",
  "finished_at": "2026-11-26T15:04:05Z"
}
```

## Events

### GET `/v1/events`

List events. Everything that happened on your account, newest first, kept 30 days. Use it to catch up after your webhook endpoint was down.

| Name | In | Type | Description |
|---|---|---|---|
| `type` optional | query | string | Only this event type. |
| `connection_id` optional | query | string | Only events about this connection. |
| `limit` optional | query | integer | Up to 100. Default 20. |
| `cursor` optional | query | string | `next_cursor` from the page before. |

**Request**

```http
GET /v1/events
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "data": [
    {
      "id": "evt_1f0c...",
      "object": "event",
      "type": "connection.reconnect_needed",
      "created": 1795700000,
      "created_at": "2026-11-26T15:04:05Z",
      "data": {
        "connection_id": "conn_8f2c41d07a9b4e6f",
        "user_id": "agency-42",
        "portal": "demo_carrier",
        "status": "reconnect_needed",
        "reason": "wrong_password"
      }
    }
  ],
  "has_more": false,
  "next_cursor": null
}
```

### GET `/v1/events/{event_id}`

Get an event. One event and every attempt to deliver it.

| Name | In | Type | Description |
|---|---|---|---|
| `event_id` | path | string | The event id. |

**Request**

```http
GET /v1/events/{event_id}
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "id": "evt_1f0c...",
  "object": "event",
  "type": "connection.reconnect_needed",
  "created": 1795700000,
  "created_at": "2026-11-26T15:04:05Z",
  "data": {
    "connection_id": "conn_8f2c41d07a9b4e6f",
    "user_id": "agency-42",
    "portal": "demo_carrier",
    "status": "reconnect_needed",
    "reason": "wrong_password"
  },
  "deliveries": [
    {
      "id": "dlv_7a3c...",
      "object": "delivery",
      "event_id": "evt_1f0c...",
      "url": "https://api.acme.com/hooks/sidelatch",
      "status": "delivered",
      "attempts": 1,
      "response_status": 200,
      "error": null,
      "next_attempt_at": null,
      "created_at": "2026-11-26T15:04:05Z",
      "finished_at": "2026-11-26T15:04:06Z"
    }
  ]
}
```

### POST `/v1/events/{event_id}/resend`

Send an event again. Deliver one event to your current webhook URL again.

| Name | In | Type | Description |
|---|---|---|---|
| `event_id` | path | string | The event id. |

**Request**

```http
POST /v1/events/{event_id}/resend
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "status": "queued",
  "delivery_id": "dlv_7a3c..."
}
```

### GET `/v1/webhook-deliveries`

List webhook deliveries. Every delivery to your webhook, newest first, with the number of attempts and your endpoint's last answer.

| Name | In | Type | Description |
|---|---|---|---|
| `status` optional | query | string | `pending`, `delivered` or `failed`. |
| `limit` optional | query | integer | Up to 100. Default 20. |
| `cursor` optional | query | string | `next_cursor` from the page before. |

**Request**

```http
GET /v1/webhook-deliveries
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "data": [
    {
      "id": "dlv_7a3c...",
      "object": "delivery",
      "event_id": "evt_1f0c...",
      "url": "https://api.acme.com/hooks/sidelatch",
      "status": "delivered",
      "attempts": 1,
      "response_status": 200,
      "error": null,
      "next_attempt_at": null,
      "created_at": "2026-11-26T15:04:05Z",
      "finished_at": "2026-11-26T15:04:06Z",
      "event_type": "connection.reconnect_needed"
    }
  ],
  "has_more": false,
  "next_cursor": null
}
```

## MCP

### POST `/v1/connections/{conn_id}/mcp-links`

Create an MCP link. An MCP server URL for one connection, to give to that end user so their AI assistant can read their portal data. `token` is shown once: the client sends it as `Authorization: Bearer`, or the user types it as the access code when an OAuth client (Claude, ChatGPT) asks them to approve.

| Name | In | Type | Description |
|---|---|---|---|
| `conn_id` | path | string | The connection id. |
| `label` optional | body | string | Your note, up to 100 characters. |
| `operations` optional | body | string[] | Only these operations become tools. Omit for all. |
| `allow_relink` optional | body | boolean | Include a hosted relink URL when the login breaks. Default true. |
| `allow_writes` optional | body | boolean | Include operations that change portal data. Default false: the link is read-only. |
| `expires_in_days` optional | body | integer | 1 to 365. Omit for no expiry. |

**Request**

```http
POST /v1/connections/{conn_id}/mcp-links
Authorization: Bearer sl_live_...

{
  "label": "Agency 42 in Claude",
  "operations": [
    "list_policies",
    "get_policy"
  ]
}
```

**Response 200**

```json
{
  "id": "mcl_6b1f0e2d9c8a7b6c5d4e",
  "url": "https://sidelatch.com/mcp/l/mcl_6b1f0e2d9c8a7b6c5d4e",
  "connection_id": "conn_8f2c41d07a9b4e6f",
  "label": "Agency 42 in Claude",
  "operations": [
    "list_policies",
    "get_policy"
  ],
  "allow_relink": true,
  "expires_at": null,
  "active": true,
  "token_hint": "...Qx4f",
  "token": "slmcp_..."
}
```

`400` for an operation the portal does not have.

### GET `/v1/connections/{conn_id}/mcp-links`

List a connection's MCP links. Every link minted for one connection, active or not. Tokens are never shown again.

| Name | In | Type | Description |
|---|---|---|---|
| `conn_id` | path | string | The connection id. |

**Request**

```http
GET /v1/connections/{conn_id}/mcp-links
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "mcp_links": [
    {
      "id": "mcl_6b1f0e2d9c8a7b6c5d4e",
      "connection_id": "conn_8f2c41d07a9b4e6f",
      "active": true,
      "last_used_at": 1795700000.0,
      "token_hint": "...Qx4f"
    }
  ]
}
```

### GET `/v1/mcp-links`

List all MCP links. Every MCP link on your account.

**Request**

```http
GET /v1/mcp-links
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "mcp_links": [
    {
      "id": "mcl_6b1f0e2d9c8a7b6c5d4e",
      "connection_id": "conn_8f2c41d07a9b4e6f",
      "active": true
    }
  ]
}
```

### DELETE `/v1/mcp-links/{link_id}`

Revoke an MCP link. The link and every OAuth token issued for it stop working at once. Disconnecting the connection revokes its links too.

| Name | In | Type | Description |
|---|---|---|---|
| `link_id` | path | string | The link id. |

**Request**

```http
DELETE /v1/mcp-links/{link_id}
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "status": "revoked"
}
```

### POST `/mcp`

MCP server for your agents. A Streamable HTTP MCP server over all your connections. Send `Authorization: Bearer <API key>`. Tools: `list_connections`, `get_connection_status` and `<portal>__<operation>` for each portal you have connections to.

**Request**

```http
POST /mcp
Authorization: Bearer sl_live_...

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "demo_carrier__get_policy",
    "arguments": {
      "connection_id": "conn_8f2c41d07a9b4e6f",
      "policy_number": "CA-100231"
    }
  }
}
```

**Response 200**

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "isError": false,
    "structuredContent": {
      "source": "portal",
      "untrusted": true,
      "portal": "demo_carrier",
      "connection_id": "conn_8f2c41d07a9b4e6f",
      "cached": false,
      "retrieved_at": "2026-11-26T15:04:05+00:00",
      "data": {
        "policy_number": "CA-100231",
        "carrier": "Demo Carrier",
        "insured_name": "Riverside Plumbing LLC",
        "line_of_business": "commercial_auto",
        "status": "active",
        "effective_date": "2026-03-01",
        "expiration_date": "2027-03-01",
        "annual_premium": 18450.0
      }
    }
  }
}
```

See [MCP](https://sidelatch.com/docs/guides/mcp).

### POST `/mcp/l/{link_id}`

MCP server for one end user. The URL from an MCP link. Bearer is the link token or an OAuth access token. Tools are that portal's operations (no connection id needed) and `get_connection_status`.

| Name | In | Type | Description |
|---|---|---|---|
| `link_id` | path | string | From the link's `url`. |

**Request**

```http
POST /mcp/l/{link_id}
Authorization: Bearer sl_live_...

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/list"
}
```

**Response 200**

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "tools": [
      {
        "name": "list_policies",
        "annotations": {
          "readOnlyHint": true
        }
      }
    ]
  }
}
```

See [MCP](https://sidelatch.com/docs/guides/mcp).

## Webhooks

### POST `/v1/webhooks/test`

Send a test event. Queues a `webhook.test` event to your webhook URL.

**Request**

```http
POST /v1/webhooks/test
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "status": "queued"
}
```

`400` if no webhook URL is set.

## Signup

### POST `/v1/signup`No API key

Create a sandbox account. No API key needed. Creates a free sandbox account and signs you in to the console, where you make your API key ([`POST /v1/api-keys`](https://sidelatch.com/docs/api#ref-post-v1-api-keys)). No key is returned here.

| Name | In | Type | Description |
|---|---|---|---|
| `company` | body | string | Your company name. |
| `email` | body | string | A work email we can reach you at. |
| `password` | body | string | For signing in to the console. At least 10 characters. |

**Request**

```http
POST /v1/signup

{
  "company": "Acme Agency Software",
  "email": "dev@acme.com",
  "password": "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"
}
```

**Response 200**

```json
{
  "customer_id": "cus_3k9w2m",
  "plan": "sandbox",
  "next": "/account",
  "sandbox_portals": [
    "demo",
    "demo_carrier"
  ]
}
```

`409` if the email already has an account. `429` when signups are busy; try again in an hour.

## Portal builds

### POST `/v1/portal-builds/check`

Check a portal before building. The checks the describe step shows as you type: the sign-in page answers, and the data is in scope (banking, health records, government IDs, other people's accounts and public data are refused). A vague description gets a clearer `rewrite` and `questions`. Saves nothing.

| Name | In | Type | Description |
|---|---|---|---|
| `url` | body | string | The portal's https sign-in page. |
| `description` | body | string | The data you need, in plain English. |

**Request**

```http
POST /v1/portal-builds/check
Authorization: Bearer sl_live_...

{
  "url": "https://payroll.example.com/login",
  "description": "Each pay stub: gross, net, taxes"
}
```

**Response 200**

```json
{
  "ok": true,
  "url": {
    "ok": true,
    "status": 200,
    "sign_in_page": true,
    "reason": ""
  },
  "scope": {
    "allowed": true,
    "category": "ok",
    "reason": "In scope.",
    "rewrite": "Each pay stub: gross, net, taxes",
    "questions": []
  }
}
```

Up to 120 checks an hour.

### POST `/v1/portal-builds`

Start a build. Runs the checks again and starts a build in `describing`. Then draft the schema, record the screens, build, check your data and publish. Limits: 5 builds a day; Free has 3 every 30 days and one portal.

| Name | In | Type | Description |
|---|---|---|---|
| `url` | body | string | The portal's sign-in page. |
| `description` | body | string | The data you need. |

**Request**

```http
POST /v1/portal-builds
Authorization: Bearer sl_live_...

{
  "url": "https://payroll.example.com/login",
  "description": "Each pay stub: gross, net, taxes"
}
```

**Response 200**

```json
{
  "id": "bld_7c1e...",
  "status": "describing",
  "url": "https://payroll.example.com/login",
  "description": "Each pay stub: gross, net, taxes",
  "spec_name": null
}
```

`422` with the reason when a check fails.

### GET `/v1/portal-builds`

List builds. Your builds, newest first, and your plan's build limits.

**Request**

```http
GET /v1/portal-builds
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "data": [
    {
      "id": "bld_7c1e...",
      "status": "ready",
      "spec_name": "c_3k9w2m_pay_stubs"
    }
  ],
  "limits": {
    "plan": "live",
    "model_paid_by": "your_key",
    "builds_last_30_days": 2
  }
}
```

### GET `/v1/portal-builds/{build_id}`

Get a build. A build's status (`describing`, `recording`, `building`, `ready`, `partial`, `needs_operator`, `published`, `abandoned`) and its values-free report: the reads found, each schema field filled or missing, and what the builder did.

| Name | In | Type | Description |
|---|---|---|---|
| `build_id` | path | string | The build's id (`bld_...`). |

**Request**

```http
GET /v1/portal-builds/{build_id}
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "id": "bld_7c1e...",
  "status": "partial",
  "report": {
    "coverage": {
      "missing": [
        "pay_stub.employer_taxes"
      ]
    }
  }
}
```

### DELETE `/v1/portal-builds/{build_id}`

Delete a build. Deletes the build and what it made: an open recording is ended without saving, its recordings are deleted, and an unpublished portal and its test connection go. A published portal goes too while no connection uses it; otherwise `409 portal_in_use` (delete those connections first).

| Name | In | Type | Description |
|---|---|---|---|
| `build_id` | path | string | The build's id (`bld_...`). |

**Request**

```http
DELETE /v1/portal-builds/{build_id}
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "id": "bld_7c1e...",
  "deleted": true
}
```

### POST `/v1/portal-builds/{build_id}/schema`

Draft the output schema. Drafts records and fields from your description (your own model key if you set one). Fits the insurance model when it can.

| Name | In | Type | Description |
|---|---|---|---|
| `build_id` | path | string | The build's id (`bld_...`). |

**Request**

```http
POST /v1/portal-builds/{build_id}/schema
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "schema": {
    "title": "Pay stubs",
    "vertical": "none",
    "records": [
      {
        "name": "pay_stub",
        "many": true,
        "fields": [
          {
            "name": "gross",
            "type": "number",
            "description": "Gross pay"
          }
        ]
      }
    ]
  },
  "checklist": [
    "The list of pay stubs and one opened"
  ]
}
```

### PUT `/v1/portal-builds/{build_id}/schema`

Edit the output schema. Your schema: records with `name`, `many` and `fields` (name, type: string, number, integer, boolean or date, description).

| Name | In | Type | Description |
|---|---|---|---|
| `build_id` | path | string | The build's id (`bld_...`). |
| `schema` | body | object | The schema. |

**Request**

```http
PUT /v1/portal-builds/{build_id}/schema
Authorization: Bearer sl_live_...

{
  "schema": {
    "records": [
      {
        "name": "pay_stub",
        "many": true,
        "fields": [
          {
            "name": "gross",
            "type": "number"
          }
        ]
      }
    ]
  }
}
```

**Response 200**

```json
{
  "schema": {
    "title": "",
    "vertical": "none",
    "records": [
      {
        "name": "pay_stub",
        "many": true,
        "fields": [
          {
            "name": "gross",
            "type": "number",
            "description": ""
          }
        ]
      }
    ]
  },
  "checklist": [
    "The list of pay stubs and one opened"
  ]
}
```

### POST `/v1/portal-builds/{build_id}/capture`

Record the screens. A link to our hosted browser for your own sitting (2 hours): you sign in on the portal's real page and open each screen on the checklist. Finishing it starts the build. Record again on a partial build to add screens.

| Name | In | Type | Description |
|---|---|---|---|
| `build_id` | path | string | The build's id (`bld_...`). |

**Request**

```http
POST /v1/portal-builds/{build_id}/capture
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "capture_id": "cap_9a...",
  "url": "https://sidelatch.com/capture/...",
  "expires_in": 7200,
  "checklist": [
    "The list of pay stubs and one opened"
  ]
}
```

One recording at a time per account.

### POST `/v1/portal-builds/{build_id}/build`

Run the builder. Builds from every recording of this build: reads found, mapped onto your schema, tested on a scrubbed copy. Answers at once; `build.completed` carries the outcome.

| Name | In | Type | Description |
|---|---|---|---|
| `build_id` | path | string | The build's id (`bld_...`). |

**Request**

```http
POST /v1/portal-builds/{build_id}/build
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "id": "bld_7c1e...",
  "status": "building"
}
```

### POST `/v1/portal-builds/{build_id}/test-connection`

Connect the new portal. Your signed-in session from the recording becomes a test connection (never billed, not in your API), so you don't sign in twice. If that session is gone, answers a `link_token` for the connect window.

| Name | In | Type | Description |
|---|---|---|---|
| `build_id` | path | string | The build's id (`bld_...`). |

**Request**

```http
POST /v1/portal-builds/{build_id}/test-connection
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "connection_id": "conn_...",
  "status": "connected",
  "from": "your recording"
}
```

### POST `/v1/portal-builds/{build_id}/data`

See your data. Every read on the test connection, with the values, beside the schema. Values are in this response only.

| Name | In | Type | Description |
|---|---|---|---|
| `build_id` | path | string | The build's id (`bld_...`). |

**Request**

```http
POST /v1/portal-builds/{build_id}/data
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "portal": "c_3k9w2m_pay_stubs",
  "results": [
    {
      "operation": "list_pay_stubs",
      "status": "ok",
      "items": 24
    }
  ]
}
```

### POST `/v1/portal-builds/{build_id}/publish`

Publish it. The portal becomes yours, private (marked Private beta). On Free the test connection becomes your one connection. Pass `accept_terms`: the terms are in `GET /v1/portal-builds-terms`.

| Name | In | Type | Description |
|---|---|---|---|
| `build_id` | path | string | The build's id (`bld_...`). |
| `accept_terms` | body | boolean | You accept the builder's terms. |
| `display_name` optional | body | string | A name for the portal. |

**Request**

```http
POST /v1/portal-builds/{build_id}/publish
Authorization: Bearer sl_live_...

{
  "accept_terms": true
}
```

**Response 200**

```json
{
  "id": "bld_7c1e...",
  "status": "published",
  "portal": "c_3k9w2m_pay_stubs"
}
```

### POST `/v1/portal-builds/{build_id}/feedback`

Something's wrong. The builder tries again with your note; a second note (or no recording left) goes to an operator.

| Name | In | Type | Description |
|---|---|---|---|
| `build_id` | path | string | The build's id (`bld_...`). |
| `text` | body | string | What's wrong. |

**Request**

```http
POST /v1/portal-builds/{build_id}/feedback
Authorization: Bearer sl_live_...

{
  "text": "Net pay is missing"
}
```

**Response 200**

```json
{
  "id": "bld_7c1e...",
  "status": "building",
  "next": "refine"
}
```

### POST `/v1/portal-builds/{build_id}/agent`

Run it as an agent portal. Company accounts with their own model key: for a portal that won't compile, an agent reads the pages into your schema on every run (slower; priced per run). It graduates to compiled reads on its own after a few runs.

| Name | In | Type | Description |
|---|---|---|---|
| `build_id` | path | string | The build's id (`bld_...`). |

**Request**

```http
POST /v1/portal-builds/{build_id}/agent
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "id": "bld_7c1e...",
  "status": "ready",
  "mode": "agent",
  "portal": "c_3k9w2m_pay_stubs"
}
```

### GET `/v1/portal-builds-terms`

The builder's terms. What you accept when you publish a portal you built.

**Request**

```http
GET /v1/portal-builds-terms
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "version": "2026-12-03",
  "terms": [
    "When you build a portal with the Services, you choose the site..."
  ]
}
```

### GET `/v1/portal-builds/specs/{name}`

A built portal's versions. Its operations and version history.

| Name | In | Type | Description |
|---|---|---|---|
| `name` | path | string | The portal's name. |

**Request**

```http
GET /v1/portal-builds/specs/{name}
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "name": "c_3k9w2m_pay_stubs",
  "operations": [
    "list_pay_stubs"
  ],
  "versions": [
    {
      "version": 2
    }
  ],
  "frozen": false
}
```

### POST `/v1/portal-builds/specs/{name}/rollback`

Roll back a built portal. Loads an earlier version again (as a new version). Dropping operations still in use is refused unless `allow_removals`.

| Name | In | Type | Description |
|---|---|---|---|
| `name` | path | string | The portal's name. |
| `version` | body | integer | A version from its history. |

**Request**

```http
POST /v1/portal-builds/specs/{name}/rollback
Authorization: Bearer sl_live_...

{
  "version": 1
}
```

**Response 200**

```json
{
  "name": "c_3k9w2m_pay_stubs",
  "version": 3,
  "operations": [
    "list_pay_stubs"
  ]
}
```

### DELETE `/v1/private-portals/{name}`

Delete a built portal. Refused while connections use it.

| Name | In | Type | Description |
|---|---|---|---|
| `name` | path | string | The portal's name. |

**Request**

```http
DELETE /v1/private-portals/{name}
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "name": "c_3k9w2m_pay_stubs",
  "removed": true
}
```

### GET `/v1/ai-key`

Your model key. Whether your account has its own model key (last four only) and who pays for build model calls.

**Request**

```http
GET /v1/ai-key
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "key": {
    "provider": "anthropic",
    "hint": "\u2026a1b2"
  },
  "model_paid_by": "your_key"
}
```

### PUT `/v1/ai-key`

Set your model key. Your Anthropic API key: every model call your builds and agent runs make uses it (the scope check stays on ours). Kept encrypted, never logged. Account admins only.

| Name | In | Type | Description |
|---|---|---|---|
| `key` | body | string | An Anthropic API key (`sk-ant-...`). |
| `provider` optional | body | string | `anthropic`. |

**Request**

```http
PUT /v1/ai-key
Authorization: Bearer sl_live_...

{
  "key": "sk-ant-..."
}
```

**Response 200**

```json
{
  "key": {
    "provider": "anthropic",
    "hint": "\u2026a1b2"
  },
  "model_paid_by": "your_key"
}
```

### DELETE `/v1/ai-key`

Remove your model key.

**Request**

```http
DELETE /v1/ai-key
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "key": null
}
```

### POST `/v1/portal-builds/move`

Move to a company account. From a Free or Pro account: a single-use token (24 hours) an admin of a company account redeems with `/v1/portal-builds/claim` to take your built portal. Your own connection stays behind.

**Request**

```http
POST /v1/portal-builds/move
Authorization: Bearer sl_live_...
```

**Response 200**

```json
{
  "token": "...",
  "portals": [
    "c_3k9w2m_pay_stubs"
  ],
  "expires_in": 86400
}
```

### POST `/v1/portal-builds/claim`

Claim a moved portal. An admin of the company account, signed in to the console.

| Name | In | Type | Description |
|---|---|---|---|
| `token` | body | string | The move token. |

**Request**

```http
POST /v1/portal-builds/claim
Authorization: Bearer sl_live_...

{
  "token": "..."
}
```

**Response 200**

```json
{
  "moved": [
    "c_3k9w2m_pay_stubs"
  ],
  "live": true,
  "next": null
}
```

## Service

### GET `/health`No API key

Health. Liveness check. No API key needed. A human view is at [/status](https://sidelatch.com/status).

**Request**

```http
GET /health
```

**Response 200**

```json
{
  "status": "ok",
  "portals": [
    "bleachernotes",
    "demo",
    "demo_carrier"
  ]
}
```

---

Sidelatch docs: [Docs](https://sidelatch.com/docs.md) · [Quick start](https://sidelatch.com/docs/quickstart.md) · [Concepts](https://sidelatch.com/docs/concepts.md) · [The connect window](https://sidelatch.com/docs/guides/connect-window.md) · [Webhooks](https://sidelatch.com/docs/guides/webhooks.md) · [MCP for AI agents](https://sidelatch.com/docs/guides/mcp.md) · [Writes](https://sidelatch.com/docs/guides/writes.md) · [Build a portal](https://sidelatch.com/docs/guides/build-a-portal.md) · [Events](https://sidelatch.com/docs/events.md) · [Errors](https://sidelatch.com/docs/errors.md) · [API reference](https://sidelatch.com/docs/api.md)
