blog
Email Testing With Insomnia: Build A Repeatable API Workflow For Signup, OTP, And Reset
Use Insomnia with MailSlurp to test email workflows end to end, including signup verification, OTP extraction, and password reset paths.
Insomnia is usually treated as an API client for REST and GraphQL endpoints. With MailSlurp, you can also use it as an email workflow test bench.
Instead of only checking that your app returns 200, you can verify the email that a real user would receive.
What you can test in one Insomnia workspace
- Signup verification messages
- Password reset links
- OTP and MFA codes
- Notification content and headers
Step 1: Import the MailSlurp OpenAPI spec
In Insomnia, import from URL:
https://swagger.mailslurp.com
This gives you ready-to-run request templates for inbox creation, waiting for emails, and message inspection.
Step 2: Configure environment variables once
Create an environment with at least:
{
"apiKey": "YOUR_MAILSLURP_API_KEY",
"appBaseUrl": "https://your-app.example.com",
"inboxId": "",
"inboxAddress": ""
}
Set x-api-key in requests using the environment variable.
Step 3: Build a four-request test chain
Use operation names from the imported spec in this order:
createInboxWithDefaults- Trigger your application action (signup/reset) against your app API
waitForLatestEmailgetEmail(or equivalent detail endpoint) and validate content
This pattern is enough to test most critical email journeys.
Example flow: signup verification
Request A: Create inbox
Run inbox creation and save returned values into environment variables.
Request B: Call your signup endpoint
Send email: {{ inboxAddress }} to your app signup API.
Request C: Wait for email
Use the wait endpoint with timeout to avoid race conditions.
Request D: Inspect and assert
Check:
- subject contains expected phrase
- body includes verification link
- sender domain is correct
Optional: add Insomnia test assertions
Insomnia supports test scripts on responses. Use them to fail fast when expected content is missing.
const json = insomnia.response.json();
insomnia.test("subject contains Verify", () => {
insomnia.expect(json.subject).to.contain("Verify");
});
Avoid flaky email tests
- Create a fresh inbox per test run.
- Use explicit wait timeouts.
- Assert business outcomes (valid link/code), not only message existence.
- Record message IDs for troubleshooting.
Security and compliance checks inside the same flow
After core workflow assertions, add:
This prevents shipping a flow that works functionally but fails deliverability.
Recommended route into CI
Use Insomnia for fast exploratory verification, then migrate critical checks into automated suites with Email Integration Testing and the Email Testing API.
If you need a full pre-release gate, use Email testing before you send.