Dev Life
Sinch Mailgun is a developer-focused email service that offers a RESTful API for sending, receiving, and tracking messages at scale. To experiment with these endpoints or troubleshoot an integration without writing code, you can use Postman, a popular API testing tool. Recently, in another article, we talked about how to integrate Sinch Mailgun with Postman. In this article, we’ll focus more on usage.
Postman provides a fast and visual way to experiment with APIs. This makes it ideal for debugging and learning, or validating credentials without having to write any code. In this guide, you’ll use Postman to test and troubleshoot the Sinch Mailgun email API.
Before you get started, you need the following:
A Sinch Mailgun account: You need an active domain, or you can use the sandbox domain. You also need an API key.
The Postman app: Download and install the Postman app. Basic familiarity with requests and environments is helpful but not required.
To start, import the Sinch Mailgun collection and environment so you can start testing immediately. In Postman, click the Import button and use the collection link to add the Sinch Mailgun collection:
Alternatively, fork the Sinch Mailgun API from the Public API Network. Make sure you include the matching Sinch Mailgun environment:
Next, you need to configure the environment variables. Open the Sinch Mailgun environment by selecting the Gear icon and then Manage Environments > Mailgun. Enter your details exactly as shown:
| VARIABLE | DESCRIPTION |
API_KEY | Your Sinch Mailgun API key) |
| BASE_URL | https://api.mailgun.net/v3 (US) or https://api.eu.mailgun.net/v3 (EU) |
| mydomain | Your domain or sandbox domain (eg sandbox12345.mailgun.org) |
| token | Leave empty. This is used by the collection to generate the Basic Auth automatically. |
Leave token blank. The collection auto-generates it from your API_KEY using a pre-request script and handles authentication for you. Make sure you select Sinch Mailgun in the environment drop-down:
To verify the setup, in the Domains folder of the collection, open Get domains and click Send. A successful response looks like this:
{
"total_count": 1,
"items": [
{
"created_at": "Sat, 06 Jan 2024 10:27:15 GMT",
"id": "65992b03de",
"is_disabled": false,
"name": "sandbox93abbcf3db544a.mailgun.org",
"state": "active"
}
]
}
If you see this, your Postman environment is ready. If not, double-check your API key and mydomain value.
Now that you’re all set up, let’s explore a few common Sinch Mailgun API scenarios. We’ll cover some basics, like sending an email and retrieving mailing lists. Then, you’ll learn how to validate email addresses and fetch event logs.
Testing email delivery confirms that your API key and domain are set up correctly. In Postman’s Sinch Mailgun API collection, open the Send message request under Messages.
The request uses your environment variables to form the URL:POST https://api.mailgun.net/v3/{{mydomain}}/messages
Postman includes a header Authorization: Basic {{token}}. This encodes your API key.
To define the form data, switch to the Body tab and choose form-data. At a minimum, you need the following:from=postmaster@{{mydomain}}
to=youremail@example.com
subject=Hello from Mailgun via Postman
text=This is a test email sent using Postman
These fields ensure the message is addressed correctly, contains content, and confirms that your domain and API key are properly set up. If you’re using a sandbox domain, the to address must be authorized in your Sinch Mailgun dashboard. To test without actual delivery, add the following:o:testmode=yes
Now, click Send. A successful response looks like this:{ "id": "<20250626043309.2b24bd37f21ec40e@sandbox93abbc.mailgun.org>", "message": "Queued. Thank you." }
The id is your message identifier. You can use this ID with the Events API to trace delivery status.
Sinch Mailgun allows you to group recipients under mailing list addresses, such as newsletter@yourdomain.com. You can use Postman to confirm your lists and their members.
To list all mailing lists, open Get mailing lists in the Mailing Lists folder and send a GET request to the following:{{BASE_URL}}/lists
A valid response looks like this:
{
"total_count": 1,
"items": [
{
"address": "developers@mydomain.net",
"name": "Developers",
"description": "Describe the mailing list",
"access_level": "readonly",
"members_count": 2,
"created_at": "Tue, 25 June 2025 20:50:27 -0000"
}
]
}
The items array contains each list’s email address, name, access level, and subscriber count. An empty array indicates no mailing lists. More information on this endpoint is available in the Sinch Mailgun API docs.
To list members of a specific mailing list, duplicate the previous request in Postman or use Get list members. Then, adjust the URL to the following:{{BASE_URL}}/lists/newsletter@yourdomain.com/members
This returns a response showing each member’s email address and their subscription status:
{
"total_count": 2,
"items": [
{
"address": "user1@example.com",
"name": "User One",
"subscribed": true
},
{
"address": "user2@example.com",
"name": "User Two",
"subscribed": true
}
]
}
This verifies that your mailing lists and subscribers are correctly configured and, in turn, helps confirm that the lists are populated before sending campaigns.
The Sinch Mailgun Email Validation API lets you check if an address is real before sending to it. This reduces bounces and keeps your lists clean. In this section, you’ll focus on single‐address validation, but bulk validation with a CSV or JSON upload is also possible.
To create the request, start a new GET request in Postman and enter the following:https://api.mailgun.net/v4/address/validate?address=test@example.com
Click Send. For a valid address, you see the following:
{
"address": "existingemail@realdomain.com",
"is_disposable_address": false,
"is_role_address": false,
"reason": [],
"result": "deliverable",
"risk": "low"
}
echo "test";
If the mailbox does not exist, you see this:
{
"address": "nonexistentemail@realdomain.com",
"is_disposable_address": false,
"is_role_address": false,
"reason": ["mailbox_does_not_exist"],
"result": "undeliverable",
"risk": "high"
}
The result field shows whether Sinch Mailgun considers the address deliverable. The reason array explains failures and risks, and helps you filter out invalid emails to reduce bounce rates.
For checking multiple addresses at once, Sinch Mailgun supports a bulk validation endpoint that accepts a CSV or JSON file upload; see the official docs for more information.
After sending an email, you can confirm what happened. The Sinch Mailgun Events API helps you track how the message was processed. You can use it to see whether an email was accepted, delivered, opened, bounced, or rejected.
Open Get Events in the Events folder. Make sure your Sinch Mailgun environment is active, then click Send. The request endpoint should look like this:GET /v3/{{mydomain}}/events
The response contains an items array of event objects. Each item in the items array contains details about a specific event. Here is an example of a rejected event from a sandbox domain:
{
"event": "rejected",
"id": "OMTXD3-sSmKIQa1gSKkYVA",
"reject": {
"reason": "Sandbox subdomains are for test purposes only. Please add your own domain...",
"description": ""
},
"message": {
"headers": {
"to": "joan@example.org",
"from": "john@sandbox12345.mailgun.org",
"subject": "Test Subject",
"message-id": "20180622220256.1.B31A451A2E5422BB@sandbox12345.mailgun.org"
},
}
}
This response shows that the message was rejected because it was sent to an unauthorized recipient using a sandbox domain. You also see other events:"accepted": Sinch Mailgun received and queued the message."delivered": The message was delivered to the recipient’s server."failed": Delivery failed due to a server error, DNS issue, or another problem."opened": The recipient’s email client triggered the Sinch Mailgun invisible tracking pixel."bounced" – The recipient’s server rejected the message. Check the severity field to distinguish soft (temporary) from hard (permanent) bounces.
More details can be found in the Sinch Mailgun event reference documentation.
To make events easier to inspect, you can filter them. Postman allows you to add query parameters in the Params tab. Here are some useful options:event=delivered returns only delivered messages.message-id=<id> filters for a specific message. You can find this ID in the response from the Send message request.
For example, after sending a test email, copy its id from the send response. Then filter events like this:GET /v3/{{mydomain}}/events?message-id=<id>
These steps help you trace each message’s status. For a full list of event types and fields, check out the Sinch Mailgun event reference documentation. These analytics are especially important when using bulk email solutions like Sinch Mailgun as they help to monitor deliverability and identify issues early. This is critical to ensure your domain maintains a strong sender reputation.
Important note on deprecation: The /events endpoint is being phased out in favor of the newer Logs API. Although the current API is still operational, it may be removed in future versions. The Logs API follows a similar structure and can be tested in the same way.
So far, you’ve used Postman to test the Sinch Mailgun API manually. This is useful for quick checks, but Postman also supports automation using JavaScript-based test scripts. They run after each request and can be used to validate responses or pass values between requests. Postman bundles Chai for BDD-style assertions.
This feature allows you to build test suites that behave like lightweight QA workflows. Automating tests helps validate email workflows without manual effort.
If you want to test the Send message endpoint, you can use Postman’s Scripts tab to verify that the request was successful:
Add the following script in the Scripts tab:pm.test("Status code is 200", function () { pm.response.to.have.status(200); }); pm.test("Sinch Mailgun queued the message successfully", function () { const resData = pm.response.json(); pm.expect(resData.message).to.eql("Queued. Thank you."); });
This script checks for a successful HTTP status and confirms that the Sinch Mailgun response contains the expected message. If either test fails, Postman will mark the request as failed in the test results panel.
You can chain requests by saving values from one response and reusing them in another. For example, after sending an email, you may want to capture its id and use it to query the Events API.
In the Send Message request, under the Tests tab, add the following:const resData = pm.response.json(); pm.environment.set("sent_message_id", resData.id);
Now, in the Get Events request, add a query parameter:message-id={{sent_message_id}}
When you run the collection, Postman automatically substitutes the saved message ID. You can also add tests to verify the response:pm.test("At least one event is present for the sent message", function () { const events = pm.response.json().items; pm.expect(events.length).to.be.above(0); });
This workflow is especially useful for checking delivery outcomes during regression testing.
Postman scripts extend your manual tests into repeatable workflows without needing a full CI system. By writing assertions in the Scripts tab, you can automatically verify responses and pass data between requests.
When you’re ready to automate, export the collection and run it with the Newman CLI as part of a simple build or smoke-test job. This setup is ideal for early QA, rapid prototyping, and sharing API checks across your team. For more script examples and patterns, check out Postman’s Test Examples guide.
Testing Sinch Mailgun in Postman can sometimes produce errors. Here’s a compact list of common issues and how to resolve them:
401/403 auth errors: Check that you’re using the private API key, not the public validation key. Postman should be using HTTP Basic Auth with api as the username and your key as the password. If in doubt, recopy it from your Sinch Mailgun dashboard.
400 Bad Request: This issue usually means a missing or incorrect parameter. Sinch Mailgun often tells you what went wrong in the response. Double-check required fields, like to, from, and subject, and ensure there are no typos.
404 Not Found: This error is most likely caused by an incorrect or missing domain in the URL (eg {{mydomain}} is blank or wrong). There is also a possibility that you may have made a request to an invalid API endpoint. Make sure to check that the endpoint and your environment variable match a valid domain in your Sinch Mailgun account.
429 Too Many Requests: You’re hitting a rate limit. Slow down your requests or wait for your quota to reset. Free or unverified accounts have lower limits, especially on validation and sending. Rate limiting (aka throttling) helps to prevent abuse and ensures fair resource usage for all users. Sinch Mailgun enforces this to keep the service reliable.
5xx Server Errors: These are issues on the Sinch Mailgun end. Wait and retry later. If persistent, check the Sinch Mailgun Status page or contact support.
Reading responses: Sinch Mailgun JSON responses can be verbose. Use Postman’s raw or Pretty view to explore deeply nested fields. You can also use console.log() in the Tests tab to inspect data, like this:const events = pm.response.json().items; events.forEach((e) => console.log(e.event));
When in doubt, search the exact error message in the Sinch Mailgun docs or forums. Their error codes are descriptive, and the solution is usually one click away.
Postman offers a practical way to interact with the Sinch Mailgun API. In this guide, you covered some of the more common usages – sending emails, retrieving mailing lists, validating email addresses, and inspecting events.
For engineers and QA teams, Postman is a reliable diagnostic tool that makes it easy to test credentials and replicate production behavior. Its scripting features and flexible environment support integrate smoothly into existing workflows. You can use it to confirm integration details before deployment and again when things go wrong. It’s a fast and reliable way to stay in control of your email workflows.
Send me the Mailgun newsletter. I expressly agree to receive the newsletter and know that I can easily unsubscribe at any time.