# Test mode

Inbox, preview, limits. Runs in your test sandbox: nothing is issued, every pass is a test preview. Authenticate with `Authorization: Bearer $PASSBOOK_KEY`. Ids in the examples are placeholders: use the ids your sandbox returns.

Everything you run in the portal runs in test mode, in your sandbox. This page says what that means and how to look at what you made.

## What a sandbox does

- Every pass is a preview. Nothing is signed, added to a wallet, pushed or mailed.
- `downloadUrl` is the test preview page. It expires after 30 days, is hidden from search and has no Add button.
- Pass detail carries `testPreview: true`. `GET /p/<token>/pass.pkpass` answers `409 SANDBOX_PREVIEW_ONLY`.
- A sandbox never holds Live. A Live key or request is refused.
- Your plan is 500 test passes, 10 templates and 3 webhook endpoints. A create past a limit is `403 SANDBOX_QUOTA` with `feature`, `limit` and `used`.
- A sandbox with no activity for 90 days closes.

## Check your key

**Check which key you use**

```sh
curl -X GET "https://passbook.mobile/api/v1/api-keys/me" \
  -H "Authorization: Bearer $PASSBOOK_KEY"
```

```ts
import { PassBook } from '@passbook/sdk';

const pb = new PassBook({ apiKey: process.env.PASSBOOK_KEY ?? '' });

const key = await pb.apiKeys.retrieveCurrent();

console.log(key.mode, key.scopes);
```

`mode` is `test`. `scopes` lists what the key may do.

## Read the test inbox

Email calls store the message instead of sending it. Send one, then list the inbox.

**Email a pass**

```sh
curl -X POST "https://passbook.mobile/api/v1/passes/0193a1b2-7c00-7000-8000-0000000000c1/resend-email" \
  -H "Authorization: Bearer $PASSBOOK_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "to": "ada@example.com"
}'
```

```ts
import { PassBook } from '@passbook/sdk';

const pb = new PassBook({ apiKey: process.env.PASSBOOK_KEY ?? '' });

await pb.passes.sendEmail('0193a1b2-7c00-7000-8000-0000000000c1', { to: 'ada@example.com' });
```

[List the test inbox](https://passbook.mobile/developers/reference/test-emails#list). Newest first; open one to read it. Nothing reaches the recipient.

## Start over

There is no reset call. Void and delete the passes you no longer want, or close the sandbox in the console: a closed sandbox is read-only, its keys stop working and it is not made again.

## Result

The inbox holds your message and the pass has a preview page. Nothing was issued.

## Operations

- [GET /api/v1/api-keys/me](https://passbook.mobile/developers/reference/api-keys#retrieveCurrent): The calling API key: id, name, scopes, organization, mode and use (`pb.apiKeys.retrieveCurrent`)
- [POST /api/v1/passes/{id}/resend-email](https://passbook.mobile/developers/reference/passes#sendEmail): Email the pass to the holder (`pb.passes.sendEmail`)
- [GET /api/v1/test-inbox](https://passbook.mobile/developers/reference/test-emails#list): List captured test emails, newest first (`pb.testEmails.list`)

More guides: https://passbook.mobile/developers/guides
