Sandbox
Test your Conversations integration without real recipients. Send an email with captureReplies: true to the test address success@simulator.amazonses.com, then create replies to it whenever you need them.
All examples assume you've set the API key in the constructor. For multi-tenant usage, pass { apiKey } as the last argument to any method. See Configuration.
Simulate a Reply
const sent = await outbound.email.send({
toEmail: 'success@simulator.amazonses.com',
fromEmail: 'admissions@yourcompany.com',
emailSubject: 'Your application',
htmlBody: '<p>Hi, reply to this email with any questions.</p>',
captureReplies: true,
});
const result = await outbound.sandbox.simulateReply({
messageId: sent.messageId!,
text: 'Yes! What are the fees?',
});
const { thread, messages } = await outbound.conversations.getThread(result.threadId);A simulated reply goes through the same processing as a real one. It is added to a conversation and classified, a reply is checked for requests to stop, and it fires the reply or auto_reply webhook with details.simulated: true. Its conversation and messages carry simulated: true, and you can filter on them with listThreads({ simulated: true }).
Some things never happen for simulated replies:
- They are never added to your suppression list, even with
autoSuppressOptOutson. A request to stop is onlyflagged. - They do not count toward campaign reply totals or engagement scores.
- Simulated conversations are deleted 30 days after their last message.
Parameters
| Field | Type | Required | Description |
|---|---|---|---|
messageId | string | Yes | The messageId of an email sent with captureReplies: true to success@simulator.amazonses.com |
text | string | No | Plain-text body. Default 'This is a simulated reply.'. Cut off after 20,000 characters |
html | string | No | HTML body. Cut off after 200,000 characters |
subject | string | No | Default Re: <original subject> |
fromEmail | string | No | Who the reply comes from. Defaults to the address the email was sent to. Must be a sandbox test address such as success@simulator.amazonses.com. Use a different test address to simulate a reply from someone else, recorded as participant: 'external' |
type | 'reply' | 'auto_reply' | No | auto_reply sends the reply as an automatic one, like an out-of-office message. Default 'reply' |
Response
{
simulated: true,
threadId: '0199f1c2-5a4e-7c1d-9a3b-2f6e8d4c1a10',
replyId: '0199f1c3-1d2e-7a4b-9c8d-6e5f4a3b2c1d',
kind: 'reply'
}| Field | Description |
|---|---|
simulated | Always true |
threadId | The conversation the reply was added to. Pass it to conversations.getThread() |
replyId | ID of the new message in the conversation |
kind | How the reply was classified, usually reply or auto_reply. See Message Kinds |
Possible Errors
| Error | Status | Cause |
|---|---|---|
BadRequestError | 400 | messageId is missing, type is not reply or auto_reply, text or html is not a string, or fromEmail is not a sandbox test address |
ForbiddenError | 403 | Conversations is not enabled for your account |
NotFoundError | 404 | No email with this messageId for your account |
OutboundError | 422 | The email was not sent to a sandbox test address, was not sent with captureReplies: true, has not been sent yet (This message has not been sent yet. Try again in a few seconds), or the reply could not be added to a conversation |
Simulate an Inbound Email
Test a mailbox without sending real mail. simulateInbound() delivers an email to one of your mailboxes, as if someone outside had written to it. The mailbox must belong to your account.
const result = await outbound.sandbox.simulateInbound({
to: 'claude-otp+gmail@inbound.example.com',
from: 'noreply@accounts.example.org',
subject: 'Your login code is 482913',
text: 'Your login code is 482913.',
});
const { message } = await outbound.mailboxes.getMessage(result.messageId);A simulated email goes through the same processing as a real one. The mailbox's allowedSenders, its enabled setting and the hourly limit all apply, and duplicate checks do too. If the mailbox accepts it, the message is stored, and the inbound webhook fires with details.simulated: true. The message has simulated: true too.
Parameters
| Field | Type | Required | Description |
|---|---|---|---|
to | string | Yes | The address of one of your mailboxes. A +tag is allowed |
from | string | No | The sender's address. Default sender@example.com. Use one plain email address |
subject | string | No | Default Simulated inbound email. Up to 500 characters |
text | string | No | Plain-text body. Default This is a simulated inbound email.. Up to 20,000 characters |
html | string | No | HTML body. Up to 200,000 characters |
Response
Status 201.
{
simulated: true,
mailboxId: '0199f2a4-6b1e-7c3d-8e2f-4a5b6c7d8e9f',
messageId: '0199f2b7-1c3a-7e9d-b5f4-8a2c6d0e1f23'
}| Field | Description |
|---|---|
simulated | Always true |
mailboxId | The mailbox that received the email. Pass it to Get Mailbox or List Messages |
messageId | ID of the stored message. Pass it to Get Message |
Possible Errors
| Error | Status | Cause |
|---|---|---|
BadRequestError | 400 | to must be an email address when to cannot be read as an address. from must be one email address when from is not one address. <field> must be at most N characters when subject, text or html is too long. The length is checked before the value is trimmed. Also when a field does not exist, or subject, text or html is not a string |
ForbiddenError | 403 | Inbound is not enabled for your account |
NotFoundError | 404 | No mailbox of yours has the address <to>. to is not one of your mailboxes |
OutboundError | 422 | The email was not delivered. The mailbox does not allow from, it is turned off, the hourly limit was reached, or the email is a duplicate of one already stored |
Testing Common Cases
An out-of-office reply. It is classified as auto_reply and fires the auto_reply webhook:
await outbound.sandbox.simulateReply({
messageId,
type: 'auto_reply',
subject: 'Automatic reply: Your application',
text: 'I am out of the office until Monday.',
});A request to stop. The message comes back with optOut.detected: true, optOut.phrase: 'remove me' and optOut.action: 'flagged':
await outbound.sandbox.simulateReply({
messageId,
text: 'Please remove me from this list.',
});A reply with HTML, to check how your app renders getMessageHtml():
await outbound.sandbox.simulateReply({
messageId,
text: 'Here are my documents.',
html: '<p>Here are my <strong>documents</strong>.</p>',
});