Skip to content
Start here

Generate preview for a non-detection message

client.emailSecurity.investigate.preview.create(PreviewCreateParams { account_id, id } params, RequestOptionsoptions?): PreviewCreateResponse { screenshot }
POST/accounts/{account_id}/email-security/investigate/preview

Generates a preview image for a message that was not flagged as a detection. The message is rendered from the copy in the recipient’s mailbox, so this requires an active integration and only works while the message is still in the recipient’s inbox. Returns a base64-encoded PNG screenshot of the email body. For messages with a detection, use the detection preview endpoint instead.

Security
API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
Accepted Permissions (at least one required)
Cloud Email Security: Write
ParametersExpand Collapse
params: PreviewCreateParams { account_id, id }
account_id: string

Path param: Identifier.

maxLength32
id: string

Body param: Unique identifier for a message retrieved from investigation.

ReturnsExpand Collapse
PreviewCreateResponse { screenshot }
screenshot: string

A base64 encoded PNG image of the email.

Generate preview for a non-detection message

import Cloudflare from 'cloudflare';

const client = new Cloudflare({
  apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});

const preview = await client.emailSecurity.investigate.preview.create({
  account_id: '023e105f4ecef8ad9ca31a8372d0c353',
  id: '4Njp3P0STMz2c02Q-2024-01-05T10:00:00-12345678',
});

console.log(preview.screenshot);
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "result": {
    "screenshot": "screenshot"
  },
  "success": true
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "result": {
    "screenshot": "screenshot"
  },
  "success": true
}