sinch-mailgun-inspect
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMailgun Inspect
Mailgun Inspect
Overview
概述
Mailgun Inspect (by Sinch) is an email pre-send quality control API. Five capabilities:
| Capability | Base Path | Input |
|---|---|---|
| Accessibility | | |
| Link Validation | | |
| Image Validation | | |
| Code Analysis | | |
| Email Previews | | varies |
For full endpoint tables and request schemas, see references/api-endpoints.md.
Mailgun Inspect(由Sinch提供)是一款邮件发送前的质量控制API。具备五项功能:
| 功能 | 基础路径 | 输入参数 |
|---|---|---|
| 可访问性检测 | | |
| 链接验证 | | |
| 图片验证 | | |
| 代码分析 | | |
| 邮件预览 | | 参数不固定 |
完整的端点表格和请求模式,请查看references/api-endpoints.md。
Agent Instructions
Agent操作说明
- 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
"Complete"; treat"Completed"as terminal error."Failed" - 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.
POST /v2/preview/tests
- 确定检测范围:如果用户说“检查我的邮件”或“QC”,则并行运行所有四项基于HTML的测试。如果用户指定了具体功能(例如“检查链接”),则仅运行该功能对应的测试。
- 选择输入方式:询问用户是否有原始HTML、URL列表或图片文件,根据功能表格将请求路由到正确的端点。
- 必须轮询结果:测试创建的POST端点通常是异步的;需轮询GET端点,直到状态变为或
"Complete";将"Completed"视为终端错误。"Failed" - 选择区域:如果用户未说明,询问使用哪个区域(美国/欧盟),必须与用户的Mailgun账户区域一致。
- V2预览快捷方式:通过在请求体中添加内容检查字段,可在单次调用中触发可访问性检测、链接验证、图片验证和代码分析。当用户同时需要预览和质量检查时使用此方式。
POST /v2/preview/tests
Getting Started
快速开始
Authentication
身份验证
See the sinch-authentication skill. HTTP Basic Auth -- username , password = Mailgun Private API key.
api请查看sinch-authentication技能。采用HTTP基础认证——用户名,密码为Mailgun私有API密钥。
apiBase URLs
基础URL
| Region | Endpoint |
|---|---|
| US | |
| EU | |
| 区域 | 端点 |
|---|---|
| 美国 | |
| 欧盟 | |
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.
"status": "Processing""Completed""Complete""Completed""Failed"创建测试的POST响应可能根据端点或工作负载返回或。你必须轮询GET端点,直到状态变为或(将视为终端错误)才能获取实际结果。
"status": "Processing""Completed""Complete""Completed""Failed"Canonical Example: Accessibility Test
标准示例:可访问性测试
bash
undefinedbash
undefined1. Create test (returns 201 + test ID)
1. 创建测试(返回201状态码 + 测试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}'
-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}'
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}'
-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)
2. 轮询获取结果(重复调用直到状态为"Complete"或"Completed";"Failed"表示错误)
curl --user 'api:YOUR_API_KEY'
https://api.mailgun.net/v1/inspect/accessibility/TEST_ID
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.curl --user 'api:YOUR_API_KEY'
https://api.mailgun.net/v1/inspect/accessibility/TEST_ID
https://api.mailgun.net/v1/inspect/accessibility/TEST_ID
所有其他端点均遵循相同的“创建-轮询”模式。根据上述功能表格调整路径和请求体。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
html. For links/images, use theencoded: falsesub-endpoint. For code analysis, POST to/html-validate./v1/inspect/analyze - Have a list of URLs? Links and images accept a array of URLs -- no HTML needed.
links - Have an image file? Use .
/v1/inspect/images/upload - Using base64? Only accessibility supports . Code analysis does not use an
encoded: trueboolean; use supported request fields (encoded/html/url/mime/transfer_encoding).charset
每个功能接受不同的输入类型,请选择合适的方式:
- 拥有原始HTML? 直接使用字段。对于可访问性检测,设置
html。对于链接/图片检测,使用encoded: false子端点。对于代码分析,向/html-validate发送POST请求。/v1/inspect/analyze - 拥有URL列表? 链接和图片检测接受URL数组——无需HTML。
links - 拥有图片文件? 使用。
/v1/inspect/images/upload - 使用base64编码? 仅可访问性检测支持。代码分析不使用
encoded: true布尔值;请使用支持的请求字段(encoded/html/url/mime/transfer_encoding)。charset
Endpoint Path Gotchas
端点路径常见误区
These paths are commonly confused:
- Code analysis is -- NOT
/v1/inspect/analyze/v1/inspect/code - Email previews are at and
/v1/preview/tests-- NOT/v2/preview/tests/v1/inspect/preview - Link/image HTML input uses the sub-endpoint -- the base POST takes a URL array
/html-validate
以下路径常被混淆:
- 代码分析的端点是——而非
/v1/inspect/analyze/v1/inspect/code - 邮件预览的端点是和
/v1/preview/tests——而非/v2/preview/tests/v1/inspect/preview - 链接/图片的HTML输入需使用子端点——基础POST端点仅接受URL数组
/html-validate
Response Lifecycle
响应生命周期
- POST returns
{"meta": {"status": "Processing"}, "items": {"id": "abc123", ...}} - GET poll until status is or
"Complete"(treat"Completed"as terminal error)"Failed" - DELETE clean up when done
Accessibility POST returns 201. All other POSTs return 200.
- POST请求返回
{"meta": {"status": "Processing"}, "items": {"id": "abc123", ...}} - GET轮询直到状态变为或
"Complete"(将"Completed"视为终端错误)"Failed" - DELETE测试完成后清理资源
可访问性检测的POST请求返回201状态码。所有其他POST请求返回200状态码。
Common Patterns
常见使用模式
Full Pre-Send Check
完整发送前检查
For a complete email quality check, fire all four HTML-based tests in parallel, then poll each:
- -- body:
POST /v1/inspect/accessibility{"html": "...", "encoded": false} - -- body:
POST /v1/inspect/links/html-validate{"html": "..."} - -- body:
POST /v1/inspect/images/html-validate{"html": "..."} - -- body:
POST /v1/inspect/analyze{"html": "..."} - Poll each until complete
GET /v1/inspect/{category}/{test_id}
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.
POST /v2/preview/tests如需全面的邮件质量检查,并行触发所有四项基于HTML的测试,然后分别轮询结果:
- ——请求体:
POST /v1/inspect/accessibility{"html": "...", "encoded": false} - ——请求体:
POST /v1/inspect/links/html-validate{"html": "..."} - ——请求体:
POST /v1/inspect/images/html-validate{"html": "..."} - ——请求体:
POST /v1/inspect/analyze{"html": "..."} - 轮询每个直到完成
GET /v1/inspect/{category}/{test_id}
V2快捷方式:如果同时生成邮件预览,通过在请求体中包含内容检查字段,可在单次调用中触发所有四项内容检测。详情请查看references/api-endpoints.md § Email Previews。
POST /v2/preview/testsCI/CD Gate
CI/CD门禁
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.
jq创建测试、轮询直到完成、解析结果、若存在严重问题则终止构建。上述标准示例展示了“创建-轮询”模式。使用提取状态和结果以实现脚本化处理。
jqImage Optimization
图片优化
After validating images, optimize them:
- -- optimize all images in a test
POST /v1/inspect/images/{id}/optimize - -- optimize a single image
POST /v1/inspect/images/{id}/optimize/{image_id}
验证图片后可进行优化:
- ——优化测试中的所有图片
POST /v1/inspect/images/{id}/optimize - ——优化单张图片
POST /v1/inspect/images/{id}/optimize/{image_id}
Code Analysis Filtering
代码分析过滤
Filter results by client support when retrieving code analysis:
GET /v1/inspect/analyze/{id}?support_type=n&application_type=webValues: = y/a/n/u (yes/anomaly/no/unknown), = web/mobile/desktop.
support_typeapplication_type获取代码分析结果时,可按客户端支持情况过滤:
GET /v1/inspect/analyze/{id}?support_type=n&application_type=web参数值: = y/a/n/u(是/异常/否/未知), = web/mobile/desktop。
support_typeapplication_typeGotchas and Best Practices
常见误区与最佳实践
- Content-Type -- All requests use (not form data like Mailgun Send).
application/json - Async results -- Creates may return or
"Processing"depending on endpoint/workload. Always check the status before assuming results are available."Completed" - Accessibility returns 201 -- All other creates return 200.
- Input types differ -- Only accessibility uses +
html. Links and images take aencodedURL array. Code analysis takeslinkswithouthtml. Using the wrong body silently fails.encoded - for HTML input -- If you have HTML (not URLs), use the
/html-validatesub-endpoint for links and images./html-validate - 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
limit(default 0).skip
- Content-Type——所有请求使用(不同于Mailgun Send使用的表单数据)。
application/json - 异步结果——创建测试的响应可能根据端点或工作负载返回或
"Processing"。在假设结果可用前务必检查状态。"Completed" - 可访问性检测返回201——所有其他创建请求返回200。
- 输入类型差异——仅可访问性检测使用+
html。链接和图片检测接受encodedURL数组。代码分析接受links但无需html。使用错误的请求体将静默失败。encoded - HTML输入使用——如果拥有HTML(而非URL),链接和图片检测需使用
/html-validate子端点。/html-validate - 与Mailgun Send使用相同认证——无需单独凭证。使用相同的API密钥和基础认证。
- 区域一致性——使用与Mailgun Send账户相同的区域(美国或欧盟)。
- 分页——列表端点支持(最大值1000,默认100)和
limit(默认0)参数。skip