# Quickstart

Page: https://aws-sandbox.myclaimhouse.com/docs/quickstart

Seven steps, all in test mode, about five minutes. Nothing here reaches a real payer or costs anything. You need `curl` and a terminal.

This quickstart is about eligibility, the fastest thing to try. Claims, attachments, remittances (ERAs) and predeterminations follow the same key, headers and conventions: see the [Claims](https://aws-sandbox.myclaimhouse.com/docs/claims.md), [Attachments](https://aws-sandbox.myclaimhouse.com/docs/attachments.md), [ERAs](https://aws-sandbox.myclaimhouse.com/docs/eras.md) and [Predeterminations](https://aws-sandbox.myclaimhouse.com/docs/predeterminations.md) guides once this works.

## 1. Get a test key

Sign in to the dashboard (or [create a sandbox account](https://aws-sandbox.myclaimhouse.com/sign-up)), open **Developers**, then **API keys**, and under **Create an API key** choose mode **Test** with both **Read** and **Submit** permissions. Copy the key: it is shown once. Then keep it in a variable:

```bash
export CLAIMHOUSE_KEY="ch_test_<key id>.<secret>"
```

Check that it works:

```bash runnable status=200
curl "https://aws-sandbox.myclaimhouse.com/api/v1/me" -H "Authorization: Bearer $CLAIMHOUSE_KEY"
```

The answer names the key, shows `"mode": "test"` and lists its permissions:

```json schema=me
{
  "id": "key_...",
  "object": "api_key",
  "name": "Quickstart",
  "mode": "test",
  "permissions": ["read", "submit"],
  "organization": { "id": "org_...", "object": "organization", "name": "..." }
}
```

## 2. Find your test office

A check is made for an office. Every new organization starts with a test-mode sample office, so you can use it as it is. List your offices:

```bash runnable status=200 capture=OFFICE_ID=data.0.id
curl "https://aws-sandbox.myclaimhouse.com/api/v1/offices" -H "Authorization: Bearer $CLAIMHOUSE_KEY"
```

Keep the first office's ID in a variable (this runs the same request and keeps its `id`):

```bash
export OFFICE_ID=$(curl -s "https://aws-sandbox.myclaimhouse.com/api/v1/offices" -H "Authorization: Bearer $CLAIMHOUSE_KEY" | grep -o '"id":"off_[^"]*"' | head -1 | cut -d'"' -f4)
```

No office in the list? Add one with [`POST /offices`](https://aws-sandbox.myclaimhouse.com/docs/offices.md#add-an-office). With exactly one office in the key's mode you may also leave `office_id` out of a check: that office is used.

## 3. Find a payer

Search the payer directory for a payer that answers eligibility checks:

```bash runnable status=200 capture=PAYER_ID=data.0.id
curl "https://aws-sandbox.myclaimhouse.com/api/v1/payers/search?q=delta&supports=eligibility" -H "Authorization: Bearer $CLAIMHOUSE_KEY"
```

Each payer has a Claim House ID (`pyr_...`) that never changes. Keep the first one:

```bash
export PAYER_ID=$(curl -s "https://aws-sandbox.myclaimhouse.com/api/v1/payers/search?q=delta&supports=eligibility&limit=1" -H "Authorization: Bearer $CLAIMHOUSE_KEY" | grep -o '"id":"pyr_[^"]*"' | head -1 | cut -d'"' -f4)
```

The directory is also public, without a key, on [the payer network page](https://aws-sandbox.myclaimhouse.com/network).

## 4. Run a sandbox eligibility check

An eligibility check needs no `Idempotency-Key`: without one it simply runs. Send one (a value you make up, new for each new check) when you may retry after a timeout, and the retry gets the first answer instead of running again; every other `POST` and `PATCH` needs one. In test mode the subscriber's `member_id` picks the scenario, and `CH-ACTIVE-FULL` is an active plan with full benefits. The people here are made up: use made-up people too.

```bash runnable status=200
curl "https://aws-sandbox.myclaimhouse.com/api/v1/eligibility" \
  -H "Authorization: Bearer $CLAIMHOUSE_KEY" \
  -H "Content-Type: application/json" \
  -d @- <<EOF
{
  "office_id": "$OFFICE_ID",
  "payer_id": "$PAYER_ID",
  "subscriber": {
    "first_name": "Sam",
    "last_name": "Sample",
    "date_of_birth": "1990-01-01",
    "member_id": "CH-ACTIVE-FULL"
  },
  "procedure_codes": ["D0120", "D2740"]
}
EOF
```

The service date is left out, so it defaults to today in the office's time zone.

## 5. Read the answer

The reply is the check. These are the parts you will use first (the real answer has more):

```json schema=check
{
  "id": "elg_...",
  "object": "eligibility_check",
  "outcome": "answered",
  "status": "active",
  "billing": { "charged": false, "state": "not_billable", "reason": "test_mode", "label": "Not billed: test mode" },
  "plan": { "name": "...", "type": "PPO", "group_number": "...", "benefit_period": "Calendar year" },
  "maximums": [{ "level": "individual", "period": "calendar_year", "amount": "2000.00", "used": "0.00", "remaining": "2000.00", "applies_to": null }],
  "deductibles": [{ "level": "individual", "period": "calendar_year", "amount": "50.00", "used": "0.00", "remaining": "50.00", "applies_to": "..." }],
  "coverage": [{ "category": "preventive", "percent_paid": 100, "covered": true, "frequency": null, "notes": "..." }],
  "procedures": [{ "code": "D0120", "percent_paid": 100, "covered": true, "status": "covered_now" }],
  "not_returned": []
}
```

- `status` says whether the patient has coverage: `active`, `inactive` or `unknown`.
- `maximums` and `deductibles` give `amount`, `used` and `remaining` as decimal strings, so no floating point rounds your money.
- `coverage` is by category (preventive, basic, major and so on); `procedures` has one row for each code you asked about, with the percent paid, how often it is covered and whether it is covered now.
- A value the payer did not return is `null`, and its name is in `not_returned`.

> [!NOTE]
> Run the same check again within 60 minutes and you get the saved answer instead of a new call: `cache.state` is `hit` and `billing.reason` is `cache_hit`. Send `Cache-Control: no-cache` to ask the payer again.

[Eligibility](https://aws-sandbox.myclaimhouse.com/docs/eligibility.md) explains every part.

## 6. Trigger a rejection

Run the same request with the member ID `CH-NOT-FOUND`. The payer cannot find the subscriber, so the reply is an error that carries the check, and the reasons to fix are in `check.rejection`:

```bash runnable status=422 capture=CHECK_ID=check.id
curl "https://aws-sandbox.myclaimhouse.com/api/v1/eligibility" \
  -H "Authorization: Bearer $CLAIMHOUSE_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d @- <<EOF
{
  "office_id": "$OFFICE_ID",
  "payer_id": "$PAYER_ID",
  "subscriber": {
    "first_name": "Sam",
    "last_name": "Sample",
    "date_of_birth": "1990-01-01",
    "member_id": "CH-NOT-FOUND"
  }
}
EOF
```

```json schema=check_error
{
  "error": "PAYER_REJECTED",
  "message": "The payer rejected the check. The check object says what to change, and whether resending can help.",
  "errors": [],
  "request_id": "req_...",
  "check": {
    "id": "elg_...",
    "outcome": "rejected",
    "rejection": {
      "kind": "fix_and_resend",
      "payer_code": "75",
      "reasons": [
        {
          "code": "MEMBER_NOT_FOUND",
          "about": "subscriber",
          "field": "subscriber.member_id",
          "message": "... could not find this subscriber.",
          "fix": "Check the member ID, name and date of birth against the insurance card, then send the check again."
        }
      ]
    }
  }
}
```

`kind` tells you what to do. `fix_and_resend` means change something and send again; `field` names what to change. Keep the check's `id` (`check.id` in the answer; this reads it back as your newest rejected check):

```bash
export CHECK_ID=$(curl -s "https://aws-sandbox.myclaimhouse.com/api/v1/eligibility?outcome=rejected&limit=1" -H "Authorization: Bearer $CLAIMHOUSE_KEY" | grep -o '"id":"elg_[^"]*"' | head -1 | cut -d'"' -f4)
```

## 7. Fix it and resend with `parent_id`

Send the corrected request with `parent_id` set to the rejected check. Here the member ID is corrected (in the sandbox, any other member ID gets the default scenario), and a new `Idempotency-Key` marks the new attempt:

```bash runnable status=200
curl "https://aws-sandbox.myclaimhouse.com/api/v1/eligibility" \
  -H "Authorization: Bearer $CLAIMHOUSE_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d @- <<EOF
{
  "office_id": "$OFFICE_ID",
  "payer_id": "$PAYER_ID",
  "parent_id": "$CHECK_ID",
  "subscriber": {
    "first_name": "Sam",
    "last_name": "Sample",
    "date_of_birth": "1990-01-01",
    "member_id": "W100200300"
  }
}
EOF
```

The new check answers with `parent_id` set to the check it corrects, so you can follow the chain. To list the corrections of a check, use `GET /eligibility?parent_id=<id>`.

## Next

- [Errors, retries and idempotency](https://aws-sandbox.myclaimhouse.com/docs/errors-and-idempotency.md): what to do when a request times out.
- [Events and webhooks](https://aws-sandbox.myclaimhouse.com/docs/events-and-webhooks.md): get a signed webhook when a check completes.
- [Sandbox and scenarios](https://aws-sandbox.myclaimhouse.com/docs/sandbox.md): every scripted payer.
- [Going live](https://aws-sandbox.myclaimhouse.com/docs/going-live.md): what changes with a live key.
