Mailgun Inspect
Overview
Mailgun Inspect (by Sinch) is an email pre-send quality control API. Five capabilities:
| Capability | Base Path | Input |
|---|
| Accessibility | /v1/inspect/accessibility
| + |
| Link Validation | | URL array (or for HTML) |
| Image Validation | | URL array (or / ) |
| Code Analysis | | (no field) |
| Email Previews | (V1) / (V2) | varies |
For full endpoint tables and request schemas, see references/api-endpoints.md.
Agent Instructions
- Determine scope: If user says "check my email" or "QC" → run all four HTML-based tests in parallel. If they name a specific capability (e.g., "check links") → run only that one.
- Choose input method: Ask if they have raw HTML, a list of URLs, or an image file. Route to the correct endpoint per the capability table.
- Always poll: Test-creation POST endpoints are typically async; poll GET until status is or ; treat as terminal error.
- Region: Ask which region (US/EU) if not already known. Must match their Mailgun account.
- V2 preview shortcut: can trigger accessibility, link validation, image validation, and code analysis in a single call by adding content-checking fields to the body. Use this when the user wants previews + quality checks together.
Getting Started
Authentication
See the
sinch-authentication skill. HTTP Basic Auth -- username
, password = Mailgun Private API key.
Base URLs
Async Workflow -- Critical
Create responses may return
or
depending on endpoint/workload. You
must poll the GET endpoint until status is
or
(treat
as terminal error) to get actual results.
Canonical Example: Accessibility Test
bash
# 1. Create test (returns 201 + test ID)
curl --user 'api:YOUR_API_KEY' \
-X POST https://api.mailgun.net/v1/inspect/accessibility \
-H "Content-Type: application/json" \
-d '{"html": "<html><body><h1>Hello</h1><img src=\"logo.png\"></body></html>", "encoded": false}'
# 2. Poll for results (repeat until status is "Complete" or "Completed"; "Failed" = error)
curl --user 'api:YOUR_API_KEY' \
https://api.mailgun.net/v1/inspect/accessibility/TEST_ID
All other endpoints follow the same create-then-poll pattern. Adapt the path and request body per the capability table above.
Key Concepts
Choosing the Right Input Method
Each capability accepts different input types. Pick the right one:
- Have raw HTML? Use the field directly. For accessibility, set . For links/images, use the sub-endpoint. For code analysis, POST to .
- Have a list of URLs? Links and images accept a array of URLs -- no HTML needed.
- Have an image file? Use
/v1/inspect/images/upload
.
- Using base64? Only accessibility supports . Code analysis does not use an boolean; use supported request fields (////).
Endpoint Path Gotchas
These paths are commonly confused:
- Code analysis is -- NOT
- Email previews are at and -- NOT
- Link/image HTML input uses the sub-endpoint -- the base POST takes a URL array
Response Lifecycle
- POST returns
{"meta": {"status": "Processing"}, "items": {"id": "abc123", ...}}
- GET poll until status is or (treat as terminal error)
- DELETE clean up when done
Accessibility POST returns 201. All other POSTs return 200.
Common Patterns
Full Pre-Send Check
For a complete email quality check, fire all four HTML-based tests in parallel, then poll each:
POST /v1/inspect/accessibility
-- body: {"html": "...", "encoded": false}
POST /v1/inspect/links/html-validate
-- body:
POST /v1/inspect/images/html-validate
-- body:
- -- body:
- Poll each
GET /v1/inspect/{category}/{test_id}
until complete
V2 shortcut: If also generating email previews,
can trigger all four content checks in one call by including content-checking fields in the request body. See
references/api-endpoints.md § Email Previews.
CI/CD Gate
Create test, poll until complete, parse results, fail build on critical issues. See the canonical example above for the create-and-poll pattern. Use
to extract status and results for scripting.
Image Optimization
After validating images, optimize them:
POST /v1/inspect/images/{id}/optimize
-- optimize all images in a test
POST /v1/inspect/images/{id}/optimize/{image_id}
-- optimize a single image
Code Analysis Filtering
Filter results by client support when retrieving code analysis:
GET /v1/inspect/analyze/{id}?support_type=n&application_type=web
Values:
= y/a/n/u (yes/anomaly/no/unknown),
= web/mobile/desktop.
Gotchas and Best Practices
- Content-Type -- All requests use (not form data like Mailgun Send).
- Async results -- Creates may return or depending on endpoint/workload. Always check the status before assuming results are available.
- Accessibility returns 201 -- All other creates return 200.
- Input types differ -- Only accessibility uses + . Links and images take a URL array. Code analysis takes without . Using the wrong body silently fails.
- for HTML input -- If you have HTML (not URLs), use the sub-endpoint for links and images.
- Same auth as Mailgun Send -- No separate credentials. Same API key, same Basic Auth.
- Region consistency -- Use the same region (US or EU) as your Mailgun Send account.
- Pagination -- List endpoints support (max 1000, default 100) and (default 0).
Links