CampaignPeek CampaignPeek logo

API

Authentication

All requests to the API must include an API key in the Authorization header. You can create an API key in the CampaignPeek dashboard.

Authorization: Bearer YOUR_API_KEY

Content Type

All requests must use application/json as the Content-Type header.

Content-Type: application/json

Parse Email Endpoint (POST)

The parse endpoint parses an email message and analyses it.

POST /api/parse_email

Parameters:

Parameter Type Required Default Description
message_content (DEPRECATED) string true N/A DEPRECATED: Use base64_message_content instead. The raw, unmodified email message content as a string (e.g. the contents of a .eml file)
base64_message_content string true N/A (required) The raw, unmodified email message content as a base64 encoded string (e.g. the contents of a .eml file)
skip_animated_gif_check boolean false true If true, the animation check will be skipped (this API is slower if it checks for animated gifs)

Example Request:

// Node.js Example import axios from 'axios'; import fs from 'fs'; const api_key = 'YOUR_API_KEY'; const raw_eml = fs.readFileSync('./example.eml', 'utf8'); const base64_message_content = Buffer.from(raw_eml).toString('base64'); const headers = { 'Content-Type': 'application/json', 'Authorization': `Bearer ${api_key}` } const data = { base64_message_content: base64_message_content, skip_animated_gif_check: false } const url = `https://campaignpeek.com/api/parse_email`; axios.post(url, data, { headers }) .then(response => { console.log(response.data); }) .catch(error => { console.error('Error:', error); });

Response object:

Parameter Type Description
email_service_provider_name string The name of the email service provider of the email message. If no ESP is detected, this will be null.
email_service_provider_url string The URL of the email service provider of the email message. If no ESP is detected, this will be null.
email_sending_infrastructure_name string Some ESPs use another service as their sending infrastructure provider. This is the name of that service. If no sending infrastructure is detected, this will be null.
email_sending_infrastructure_url string The URL of the email sending infrastructure provider of the email message. If no sending infrastructure is detected, this will be null.
preview_text string The preview text of the email message
gmail_markup_and_annotations boolean Whether the email message's HTML content contains Gmail's markup and annotations features
gmail_markup_and_annotations_features array An array of the specific Gmail Markup / Annoations features that are detected in the email message's HTML content. If gmail_markup_and_annotations is false, this will be null.
dark_mode boolean Whether the email message has dark mode specific styles
word_count integer The number of words in the email
link_count integer The number of links in the email
text_link_count integer The number of text links (i.e. links that are not images)
image_link_count integer The number of image links (i.e. links that are images)
image_count integer The total number of images in the email
png_image_count integer The number of images where the src attribute contains a .png extension
jpg_image_count integer The number of images where the src attribute contains a .jpg or .jpeg extension
gif_image_count integer The number of images where the src attribute contains a .gif extension
svg_image_count integer The number of images where the src attribute contains a .svg extension
unknown_image_count integer The number of images where the src attribute does not contain a .png, .jpg, .jpeg, or .gif extension
animated_gif boolean Whether the email message contains one or more animated GIFs. Note: if the skip_animated_gif_check parameter is used, this will be null.
input_checkbox_hack boolean Whether the email's HTML contains an checkbox input. This is interesting because in email they are commonly used to provide an interactive experience.
input_radio_hack boolean Whether the email's HTML contains an radio input. This is interesting because in email they are commonly used to provide an interactive experience.
css_keyframe_animation boolean Whether the email's HTML contains a CSS keyframe animation.
css_transition_animation boolean Whether the email's HTML contains a CSS transition animation.
size integer The size of the email message in bytes
technologies_detected array An array of the technologies that are detected in the email message's HTML content.
outlook_optimized boolean Whether the email's HTML contains code that targets Outlook specifically.
likely_hand_coded boolean Whether the email's HTML content is likely to be hand-coded. This is not guaranteed, but it's a good indicator.
responsive boolean Whether the email's HTML content styles contain code that target different screen sizes.
spf string The result of the SPF verification from the email headers
dkim string The result of the DKIM verification from the email headers
dmarc string The result of the DMARC verification from the email headers
subject_length integer The length of the email subject
subject_emojis array An array of emojis found in the email subject
subject_emoji_count integer The number of emojis found in the email subject
amp boolean Whether or not an AMP version of this email was sent.
amp_features array An array of the specific AMP features that are detected in the email message's AMP content. If amp is false, this will be null.

Example Response:

{ "email_service_provider_name": "MessageGears", "email_service_provider_url": "https://www.messagegears.com", "email_sending_infrastructure_name": null, "email_sending_infrastructure_url": null, "preview_text": "Hello, how are you? ", "gmail_markup_and_annotations": true, "gmail_markup_and_annotations_features": [ { "type": "Organization" }, { "type": "EmailMessage" }, { "type": "DiscountOffer" }, { "type": "PromotionCard" } ], "dark_mode": true, "word_count": 1037, "link_count": 27, "text_link_count": 11, "image_link_count": 16, "image_count": 17, "png_image_count": 15, "jpg_image_count": 0, "gif_image_count": 0, "svg_image_count": 0, "unknown_image_count": 2, "animated_gif": null, "input_checkbox_hack": false, "input_radio_hack": false, "css_keyframe_animation": false, "css_transition_animation": false, "size": 101471, "technologies_detected": [ { "key": "marigold_liveclicker", "name": "Marigold Liveclicker", "url": "https://meetmarigold.com/product/marigold-liveclicker/" }, { "key": "validity_everest", "name": "Validity Everest", "url": "https://www.validity.com/everest/" } ], "outlook_optimized": true, "likely_hand_coded": true, "responsive": true, "spf": "pass", "dkim": "pass", "dmarc": "pass", "subject_length": 17, "subject_emojis": [ { "emoji": "👋", "short_name": "wave" } ], "subject_emoji_count": 1, "amp": true, "amp_features": { "tags_used": { "amp-img": 17, "amp-mustache": 2 } } }

Error Responses

The API may return the following error codes:

Status Code Error Description
400 Bad Request The request was invalid. This could be due to missing required parameters, invalid parameter values, or malformed JSON.
401 Unauthorized Authentication failed. Check that you're providing a valid API key in the Authorization header.
429 Too Many Requests You have exceeded the rate limit for API requests. Please slow down your request rate.
500 Internal Server Error Something went wrong on our end. If this persists, please contact support.

Example Error Response:

{ "error": "Bad Request", "message": "message_content parameter is required" }