Skip to content

Create Email Preview Test V2

Request

This call creates a new email test and submits it to our system for processing.
All requests must contain a subject property and one source property (either html or url). All other properties are optional. In the following table, each property and its default value is shown.
If content-checking variables (such as those for link validation, image validation, or accessibility) are set in the body of the request, the endpoint will run content-checking on the email content.
The response will include an id property that should be used to request the results or trigger further processes on the email content.
For enterprise customers, the response will also include the customer_id and reference_id that were submitted with the test.

Security
basicAuth
Bodyapplication/jsonrequired
subjectstringrequired
htmlstring
mimestring
urlstring
transfer_encodingstring
charsetstring
reference_idstring
customer_idstring
clientsArray of strings
image_blockingboolean
headersobject
spamobject or null
content_checkingobject(github.com-mailgun-emailpreview-clients-preview-TestRequestContentChecking)
user_idstring
folder_idstring
project_namestring
curl -i -X POST \
  -u '<username>:<password>' \
  https://api.mailgun.net/v2/preview/tests \
  -H 'Content-Type: application/json' \
  -d '{
    "subject": "Example subject",
    "html": "<html>...</html>",
    "transfer_encoding": "base64",
    "charset": "utf-8",
    "customer_id": "1",
    "clients": [
      "client1",
      "client2"
    ],
    "content_checking": {
      "link_validation": true,
      "image_validation": true,
      "accessibility": true,
      "code_analysis": true
    }
  }'

Responses

A 200 response

Bodyapplication/json
idstring
reference_idstring
customer_idstring
spamobject or null
warningsArray of objects(github.com-mailgun-emailpreview-clients-preview-Warning)
content_checkinggithub.com-mailgun-emailpreview-clients-preview-ContentCheckingResult (object) or null
Any of:
Response
{ "id": "exampleTestID", "customer_id": "1", "warnings": [ {} ], "content_checking": { "link_validation": {}, "image_validation": {}, "accessibility": {}, "code_analysis": {} } }