Rookery
Developer docsTesting and the sandbox
Guides

Testing and the sandbox

Test keys, the sandbox inbox and magic .test addresses, for testing sends, bounces and replies without a real person ever seeing them.

Updated View as Markdown

The sandbox is a separate inbox for building and testing, like test mode in a payments API. Use a test key and the API works exactly as it does live, on the sandbox's own conversations: you can send, and see what happens, without anything leaving Rookery or touching your real mail.

Test keys

Owners and admins make them in Settings → Developers → API keys: under Works on, choose The sandbox.

  • Test keys start with rookery_test_, live keys with rookery_live_. Keys in the old format start with rk_test_ or rk_live_, and the plain rk_ keys made before test keys existed are live keys.
  • A test key sees only the sandbox inbox, sandbox@rookery.test, and what's in it. Your real inboxes, conversations and documents don't exist for it: lists leave them out, and asking for a real conversation answers 404.
  • Live keys, and people in the app, never see the sandbox.
  • The same endpoints and scopes apply. GET /me says "livemode": false for a test key.
  • Try it in the reference is made for test keys: with one, you can even try sending.

Start a test: simulate an email

The sandbox starts empty. POST /v1/sandbox/inbound makes an email arrive in it, through the real pipeline: it's threaded, checked for scams, stored, and your test webhooks hear about it. It's the only endpoint that's for test keys alone (a live key gets 403), and it needs the write scope. The sandbox takes up to 120 simulated emails a minute, across all your test keys.

With your test key in ROOKERY_API_KEY:

curl -X POST https://app.userookery.com/api/v1/sandbox/inbound \
  -H "Authorization: Bearer $ROOKERY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"from": "reply+lee@acme.test", "name": "Lee Park", "subject": "Where is my order?", "text": "Hi, order 1182 hasn'\''t arrived."}'

The answer has the new conversation_id. Senders must be on .test, so the sandbox never touches a real contact. Pass conversation_id to make the email a reply on a conversation that's already there.

Magic addresses

Reply to the conversation, and what happens depends on who it's to. The sandbox reads the address's first part, before any +, at any .test domain:

Send toWhat happens
delivered@acme.testDelivered. Nothing comes back.
bounce@acme.testA hard bounce: the email's status is failed, and there's no message.sent event.
complaint@acme.testDelivered, then marked as spam (a spam-complaint event on the conversation). Every later email to that address fails, the way a provider holds mail after a complaint.
reply+lee@acme.testDelivered, then they write back about 5 seconds later, in the same conversation (message.received).
docs@acme.testDelivered, then a reply with a PDF invoice attached arrives about 5 seconds later. It's filed as a document.
ooo@acme.testDelivered, then an automatic out-of-office reply arrives. It's a machine's mail, so there's no message.received.

Anything else at .test is delivered, and nothing comes back.

For example: simulate an email from reply+lee@acme.test, reply to it with "send": true, and Lee writes back about 5 seconds later, in the same conversation, with a message.received event. Read the timeline with GET /conversations/{id} to see each step.

.test is a domain name that's reserved and can never reach a real inbox. There are two checks: sandbox mail is never handed to the mail service at all, and the mail service itself refuses .test addresses.

How the sandbox differs from live

  • Nothing is sent. Every email from the sandbox is simulated, whoever it's to.
  • The undo window is 5 seconds, not 10 minutes, so your tests don't wait.
  • Rook doesn't run. It doesn't sort, draft (even when you assign a conversation to Rook) or read documents, so the same calls give the same answers every time and cost nothing. Scam checks still run, and attachments are still filed as documents. Sandbox mail isn't in Ask Rook's search.
  • Tag names are shared with your workspace. A tag used only in the sandbox doesn't show in your team's tag list, but a tag name you type in the sandbox is the same tag as a live one with that name.
  • Drafts wait for a yes as they do live. Nobody approves them in the sandbox yet, so to test a whole send, use a key with send and "send": true.

Webhooks in the sandbox

Sandbox events go only to test endpoints: in Settings → Developers → Webhooks, under Which events, choose Sandbox. They're signed the same way as live ones, and every event says where it came from:

{ "id": "evt_…", "type": "message.received", "workspace_id": "wsp_…", "livemode": false, "data": { … } }

Live events go only to live endpoints, with "livemode": true. Check livemode anyway: it's the simplest guard against test data in your real systems.

Coming later

  • The sandbox in the app: see the sandbox's conversations, approve drafts and open each email as the recipient would see it.
  • A predictable Rook: sorting, drafting and reading documents with fixed answers by simple rules, so a test like "an email arrives, the agent drafts, the draft waits for a yes" runs end to end.
  • Raw MIME for POST /v1/sandbox/inbound, and attachments of your own.
  • More magic addresses, like a delay and a reply on a client's page.

Tell us what you'd need at hello@userookery.com.