# Test mode

> Build your integration with a test key. Sample data only, magic numbers that play out real call flows with real timing, and the placeholders you'll see.

A test key (`ck_test_...`, `cs_test_...`) works on every endpoint, but it only ever touches sample data:

- It doesn't dial anyone, and it costs nothing.
- It can't see or change your real leads, calls, Do Not Call list or events.
- Every reply has the same shape as a live one, with `"livemode": false`.
- It does see your real campaign IDs and names, so the same `campaign_id` works later with a live key.

Everything else is real: the key's permissions and campaigns, the rate limits, `Idempotency-Key`, and every check and error code that doesn't need real data.

## Magic numbers

The phone number you send picks what the pretend call does. Each one sends the same events, in the same order and with the same timing, as a real call would.

| Phone | What the call does | Events after `lead.created` and `lead.queued` | `call.completed` arrives |
| --- | --- | --- | --- |
| `+15550100001` | Answers, is interested, an SDR takes the call | `call.started`, `call.answered`, `lead.interested`, `handover.accepted`, `call.completed` | 216 seconds after you add the lead |
| `+15550100002` | A voicemail is left | `call.started`, `call.answered`, `voicemail.left`, `call.completed` | 71 seconds |
| `+15550100003` | No answer | `call.started`, `call.completed` | 41 seconds |
| `+15550100004` | Busy | `call.started`, `call.completed` | 15 seconds |
| `+15550100005` | Asks not to be called again | `call.started`, `call.answered`, `lead.opted_out`, `call.completed` | 44 seconds |
| `+15550100006` | Books a callback for tomorrow at 14:00 UTC | `call.started`, `call.answered`, `callback.booked`, `call.completed` | 121 seconds |
| `+15550100007` | Wrong number | `call.started`, `call.answered`, `call.completed` | 41 seconds |
| Anything else | One of the seven above | The same as that one | |

For any other number, the flow is picked from your `external_id` (or the phone, if you send no `external_id`). The same input always gets the same flow, so you can run a test again and get the same result.

How the pretend calls behave:

- The call only happens for a `call_now` lead (`"call_now": true`, or a campaign that calls new leads straight away). Without it, the lead waits in the queue.
- In a paused or not-yet-started campaign, the lead is held: you get `lead.created` and then `lead.queued` with `status: "held"`, and no call, just like live.
- Add the field `"test_late": "true"` (in `fields`) to a `call_now` lead to get `lead.late` 15 seconds after it's queued. The call starts after that. Live only marks `call_now` leads late, so a lead without `call_now` gets no `lead.late`.
- `POST /leads/{id}/opt_out` and `POST /dnc` (or `/dnc/batch`) send `lead.opted_out` for your test leads with that number, as live. The real Do Not Call list is never touched.
- `POST /calls` on a test lead plays its call again, up to 3 times in 24 hours, as live.
- A test key needs the same [permissions](https://developers.callview.ai/guides/authentication/#the-permissions) as a live one: Start calls to add a lead or use `POST /calls`, and Recordings & transcripts for the sample recording and transcript. A key's own [day limits](https://developers.callview.ai/guides/money-guards/#limits-for-one-key) never hold a test lead: pretend calls cost nothing.
- A test key can have 20 pretend calls going at once. Past that you get `429 test_flows_busy` with `Retry-After`.
- Test leads and calls are deleted after 7 days.

## Placeholders

Test replies and test events carry no real data. Where a live reply would have a person's details, you get these:

| Field | Test value |
| --- | --- |
| Lead name | `LEAD_NAME` |
| Lead email | `LEAD_EMAIL` |
| Lead address | `LEAD_ADDRESS` |
| Phone | The magic number you sent, otherwise `+15550100001` |
| Your custom fields | Your field names, each with the value `FIELD_VALUE` |
| `consent.ip` | `LEAD_IP` (the rest of `consent` is what you sent) |
| `external_id` | What you sent |
| The AI's note | `AI_NOTE` |
| `intent.excerpt` (what the lead said) | `INTENT_EXCERPT` |
| `handled_by` | `{ "id": "usr_test_sdr", "name": "SDR_NAME", "role": "sdr" }` |
| `owner` | `{ "id": "usr_test_owner", "name": "OWNER_NAME" }` |
| Recording link | `https://developers.callview.ai/samples/recording.mp3` |
| Transcript lines | `AI_LINE_1`, `LEAD_LINE_1`, `SDR_LINE_1` and so on |
| Callback time zone | `UTC` |
| Export file | `https://developers.callview.ai/samples/export.csv` |

## The other areas

| Area | With a test key |
| --- | --- |
| Do Not Call | Only `+15550100005` is "on the list". Adding or removing numbers answers as live, and your real list stays as it was. |
| Campaigns | You see each campaign's `id` and `name`. Starting or pausing one answers with the status it would have, and the real campaign stays as it is. |
| Exports | You get the sample file above. |
| Webhooks | Endpoints made with a test key are test endpoints. They get test events only, and live endpoints don't get test events. |
| Usage | `GET /usage` counts only your test requests and leads. None of it is billed. |

## Send a test event

To try your receiver without waiting for a call, send yourself any event:

```bash
curl -X POST "https://v2-api.callview.ai/api/v1/external/webhook_endpoints/$ENDPOINT_ID/test" \
  -u "$CALLVIEW_KEY_ID:$CALLVIEW_SECRET" \
  -H 'Content-Type: application/json' \
  -d '{ "type": "lead.interested" }'
```

It's that event's example, marked `"sample": true`, signed and retried like a real delivery. It works with a live key on a live endpoint too.
