# Test mode

A **Test** key (`dt_test_...`) answers like a production one, with example data. Nothing is stored, no message is sent and nothing is charged.

- Each call is checked by the same rules as production: a wrong field gives the same `422 validation_failed`.
- The answer has the real shape, with `"test": true` and the `DoneTalk-Test: true` header.
- `GET /me` answers for real, to check the key.
- Scopes, the rate limit and `Idempotency-Key` work as in production.

## Simulate an error

Send the `DoneTalk-Simulate` header with an error code to get exactly the answer production would give:

```bash
curl -X POST https://api.donetalk.com/v1/c/demo/campaigns \
  -H "Authorization: Bearer $DONETALK_KEY" \
  -H "DoneTalk-Simulate: template_not_approved" \
  -H "Content-Type: application/json" \
  -d '{"name": "Test"}'
```

Accepted codes: `unauthorized`, `api_key_invalid`, `api_key_expired`, `api_key_address_not_allowed`, `insufficient_scope`, `not_available_to_api_keys`, `not_available_to_test_keys`, `permission_denied`, `integration_template_only`, `not_found`, `campaign_not_found`, `contact_not_found`, `validation_failed`, `campaign_not_editable`, `template_not_approved`, `campaign_audience_empty`, `contact_exists`, `window_closed`, `idempotency_key_reused`, `idempotency_in_progress`, `rate_limited`, `internal_error`.

## Magic phones

In any phone field, these numbers cause a known behaviour:

| Phone | What happens |
|---|---|
| `+550000000400` | `validation_failed` (422) |
| `+550000000404` | `contact_not_found` (404) |
| `+550000000409` | `contact_exists` (409) |
| `+550000000429` | `rate_limited` (429) |
| `+550000000500` | `internal_error` (500) |
| `+550000000131` | message.failed / campaign.recipient.failed: `131026` |
| `+550000000470` | message.failed / campaign.recipient.failed: `131047` |

## Test webhooks

A send with a test key (a message, a campaign) delivers to the company's webhooks the sequence production would, a few seconds apart: sent, delivered, read and, for a campaign, replied and completed. With a failing magic phone, the failure arrives. The envelope carries `"test": true`.

## Demo company

To try without an account, use the `demo` company with the public key:

```bash
export DONETALK_KEY=dt_test_demo_zRZ6twAhj4u9dZT0hEBrNFzr
curl https://api.donetalk.com/v1/c/demo/me -H "Authorization: Bearer $DONETALK_KEY"
```

It only simulates: nothing real can be done with it.
