Generic HTTP

Learn how to integrate any third-party Email Service Provider with CleverTap using the Generic HTTP method.

Overview

The Generic HTTP feature enables flexible integration with any third-party Email Service Provider (ESP) using the HTTP protocol. It supports sending email campaigns using custom payloads, headers, and dynamic fields. It also enables callback tracking for delivery success, failures, and user interactions such as clicks or unsubscribes.

Set Up Email Provider in CleverTap

To configure any third-party ESP using the Generic HTTP provider in your CleverTap account, perform the following steps:

  1. Go to Settings > Channels > Email.
  2. Click + Provider and select Generic HTTP from the Provider dropdown.
  3. Enter the following provider details:
Provider Setup

Provider Setup

FieldDescription
NicknameA unique name for identifying the configuration.
Callback URLThe Callback URL is used to receive bounce, delivery, and subscription information from the ESP to CleverTap. This is a read-only field that is auto-populated with CleverTap's callback URL. Ensure that you add this URL to your ESP dashboard settings to send callback data to CleverTap.
Request TypeChoose between GET or POST.
HTTP EndpointAPI endpoint of the ESP. Must start with http:// or https://.
AuthenticationChoose None or Basic. Provide credentials if using Basic authentication.
HeadersAdd static or dynamic headers. For more information, refer to Headers.
ParametersApplicable for the POST method. Define the request payload in JSON format; supports both single and batch message delivery. For more information, refer to Body Parameters.
Batch parameter
  • Applicable for the POST method.
  • Enable to send up to 1000 emails in one API call. Before enabling this option, confirm the batch size supported by your ESP.
  • For more information, refer to Body Parameters.

    Default From Address
  • This is a mandatory field only if the feature is enabled for your account.
  • Enter the default email address you want to use for sending your email campaigns.
  • The email address will be pre-populated under the From Email Address field as a default value when creating an Email campaign.

  • Note: Adding Default From Address to your email campaigns is currently in Private Beta. For more information, refer to Sender Details.
    Default Reply to Address
  • This field is available only if the feature is enabled for your account.
  • Enter the default email address to which you want your users to reply to the campaign.
  • The email address will be used to pre-populate the Reply-to Email Address field as a default value when creating an Email campaign.

  • Note: Adding Default Reply-to Email Address for your email campaigns is currently in Private Beta. For more information, refer to Sender Details.
    Email Preference Center
  • Select System from the dropdown to use a pre-built preference center with a sample preview.
  • Select Custom URL to add your hosted unsubscription page URL.
  • Select None if you want to manage the email preferences directly on your own.
  • For more information, refer to Manage Email Preferences.
    1. Click Save and click Send Test Email to verify the setup.

    Set Up Message Payload

    You can configure headers and define the JSON payload structure for sending emails through your Generic HTTP provider, which supports dynamic values and batching.

    Headers

    Specify headers to pass authentication details (such as API keys or credentials) and campaign-level metadata. Authentication headers are typically static, for example, a username/password or token, and should be added as fixed key-value pairs. If your provider requires additional metadata (such as campaign identifiers) to be sent as headers, use dynamic placeholders to populate those at runtime.

    You can either specify one of the following types of headers:

    • Static Headers: In this case, you must specify fixed values. For example, Authorization: Bearer <API_KEY> or Content-Type: application/json.

    • Dynamic Headers: Dynamic headers allow you to personalize your HTTP request payload with campaign-level and user-level values at send time. These placeholders are defined using the $$ prefix and are replaced with actual values during message delivery. For instance, you can include placeholders such as $$UserName or $$CampaignID in the request headers. These are dynamically populated with actual values defined during campaign setup. To learn about Dynamic Replacement Parameters, refer to System Dynamic Replacements and Custom Dynamic Replacements.

      Dynamic Headers - POST Method

      Dynamic Headers - POST Method

      In the following example, "UserName": "$$UserName" is a dynamic placeholder used in the payload. The part that follows the $$ (in this case, UserName) must match the key you define in the Request Headers section during campaign setup.

      CleverTap uses this mapping to replace the placeholder with the corresponding value at the time of sending the campaign.

    Define Parameters - Generic HTTP via POST Method

    Configure Parameters For POST Method

    When using the GET method, parameters are passed via the Request Query Parameters section. This section allows you to define dynamic values that CleverTap sends into the query string of your HTTP endpoint.

    ๐Ÿšง

    Note

    Do not use dynamic placeholders such as $$HTML or any large body content in the query string of the request. Including such content can significantly increase the URL length and may lead to request failures.

    Provider Setup for Generic HTTP - GET Method

    Provider Setup for Generic HTTP - GET Method

    In the following example, you define a value for PromoCode during campaign creation.

    Define Request Query Parameters - For GET Method

    Define Request Query Parameters - For GET Method

    Body Parameters

    For a POST request type, these parameters are included in the request body to define recipient details and message content. You can also configure batch processing to send multiple messages in a single request.

    Sample Request Without Batching

    {
      "peid": "1202159255273620968",
      "tmid": "1202159255273620968",
      "cid": "$$CampaignID",
      "fromName": "$$FromName",
      "fromAddress": "$$FromAddress",
      "to": "$$To",
      "cc": "$$cc",
      "bcc": "$$bcc",
      "mid": "$$MessageID",
      "uid": "$$userid",
      "variables": "$$TemplateVariables",
      "typeB": "$$HTML",
      "plaintext": "$$Plaintext",
      "amp": "$$AMPHTML",
      "replyTo": "$$ReplyToAddress",
      "tid": "$$Subject"
    }
    

    Sample Request With Batching

    If your provider supports batching, structure your payload as shown below. In the following example, the msgs array holds multiple personalized email messages. Ensure all dynamic parameters that require user-level or campaign-level personalization (such as $$CampaignID) are included within each object inside msgs.

    {
      "peid": "1202159255273620968",       // Static Global key-value pair
      "tmid": "1202159255273620968",       // Static Global key-value pair
      "msgs": [
        {
          "seq": 1,													// Static parameter
          "cid": "$$CampaignID",           
          "type": "$$FromName",
          "typeA": "$$FromAddress",
          "to": "$$To",
          "cc": "$$cc",
          "bcc": "$$bcc",
          "mid": "$$MessageID",
          "uid": "$$userid",		// Dynamic custom parameter, value for userID key should be provided during campaign setup
          "typeB": "$$HTML",
          "plaintext": "$$Plaintext",
          "amp": "$$AMPHTML",
          "replyTo": "$$ReplyToAddress",
          "tid": "$$Subject"
        },
        {
          "seq": 2,
          "cid": "$$CampaignID",
          "type": "$$FromName",
          "typeA": "$$FromAddress",
          "to": "$$To",
          "cc": "$$cc",
          "bcc": "$$bcc",
          "mid": "$$MessageID",
          "uid": "$$userid",
          "typeB": "$$HTML",
          "plaintext": "$$Plaintext",
          "amp": "$$AMPHTML",
          "replyTo": "$$ReplyToAddress",
          "tid": "$$Subject"
        }
      ]
    }
    

    ๐Ÿ“˜

    Batch Size Limit

    CleverTap supports a maximum batch size of 1000 records in a single request.

    System Dynamic Replacements

    You can use the following dynamic replacements within your payload. At send time, CleverTap replaces each placeholder with the corresponding value.

    KeyDescriptionMandatory
    $$ToA dynamic replacement parameter replaced by CleverTap with the recipientโ€™s email address.Mandatory
    $$SubjectA dynamic replacement parameter replaced by CleverTap with the subject line of the email.Mandatory
    $$FromNameA dynamic replacement parameter replaced by CleverTap with the senderโ€™s display name.Mandatory
    $$FromAddressA dynamic replacement parameter replaced by CleverTap with the senderโ€™s email address.Mandatory
    $$HTMLA dynamic replacement parameter replaced by CleverTap with the HTML content of the email.Mandatory
    $$MessageIDA dynamic replacement parameter replaced by CleverTap with a unique identifier in the outgoing Email payload to the provider endpoint. The provider must send the same value in the callback request to CleverTap's callback URL in the meta key. This is mandatory for DLR (delivered and delivery-related errors such as bounces, unsubscribe, spam, and so on) tracking.Mandatory for delivery tracking
    $$ccA dynamic replacement parameter replaced by CleverTap with the CC recipient email addresses.

    Note: Adding CC recipients to email campaign is currently in Private Beta. CleverTap recommends using the $$cc field only if your account has CC support enabled for email campaigns. If the feature is not enabled or CC recipients are not configured during campaign setup, CleverTap still includes the key in the payload with a blank value. For more information, refer to CC/BCC.
    Optional
    $$bccA dynamic replacement parameter replaced by CleverTap with the BCC recipient email addresses.

    Note: Adding BCC recipients to email campaign is currently in Private Beta. CleverTap recommends using the $$cc field only if your account has CC support enabled for email campaigns. If the feature is not enabled or CC recipients are not configured during campaign setup, CleverTap still includes the key in the payload with a blank value. For more information, refer to CC/BCC.
    Optional
    $$ReplyToAddressA dynamic replacement parameter replaced by CleverTap with the reply-to email address.Optional
    $$PlaintextA dynamic replacement parameter replaced by CleverTap with the plain-text version of the email.Optional
    $$AMPHTMLA dynamic replacement parameter replaced by CleverTap with the AMP version of the email.

    Note: AMP for Email is available only with Email Booster Max/Advanced Email add-on. Contact your Customer Success Manager to upgrade your plan.
    Optional
    $$CampaignIDA dynamic replacement parameter replaced by CleverTap with the CleverTap campaign ID.Optional

    Custom Dynamic Replacements

    Custom dynamic replacements allow you to pass additional metadata, such as user preferences or campaign-level attributes, into your payload. These placeholders are defined during campaign setup and are replaced by CleverTap at send time.

    {
      "cid": "432",                            // Global Key-Value pair
      "msgs": [                               // Start of batched message array
        {
          "from": "$$FromName",             // System Dynamic Parameter: sender display name
          "senderaddr": "$$FromAddress",   // System Dynamic Parameter: sender email address
          "to": "$$To",                   // System Dynamic Parameter: recipient email address
          "mid": "$$MessageID",          // System Dynamic Parameter: unique message ID (used in callbacks)
          "name": "$$name",            // Custom Dynamic Parameter: recipientโ€™s name (user-level personalization)
          "uid": "$$userID",    // Custom Dynamic Parameter: userโ€™s ID (user-level personalization)
          "content": "$$HTML",      // System Dynamic Parameter: HTML email body
          "heading": "$$Subject"   // System Dynamic Parameter: email subject
        }
      ]
    }
    

    In a batching scenario, the JSON payload consists of the following two parts

    • Global Key-Value Pairs: Apply uniformly across the entire batch, do not support personalization. In the above example, cid : 432 is a global key-value pair.

    • Message-level Key-Value Pairs: Specific to individual messages within the batch, supports personalization. In the above example, all the parameters within the msgs array are message body key-value pairs.

      Campaign Creation in case of Batching

      Campaign Creation in case of Batching

      When the campaign is sent, CleverTap resolves all placeholders and sends the payload to your email service provider (refer to the following sample JSON payload):

    {
      "cid": "43a",
      "discountPercentage": "$$DiscountPercentage",
      "msgs": [
        {
          "from": "Acme Deals",
          "senderaddr": "[email protected]",
          "to": "[email protected]",
          "mid": "[email protected]|1568798080|1730799638|20241105|0|wzrk_default|-17005910|",
          "name": "Sara",
          "uid": "user_9021",
          "content": "<html><body>Hello Sara, enjoy your exclusive 20% discount today!</body></html>",
          "heading": "Your 20% Discount Awaits!"
        }
      ]
    }
    

    Set Up Callbacks

    CleverTap enables real-time tracking of delivery status and user interactions, such as bounces, unsubscribes, spam reports, and clicks, through HTTP callbacks sent to CleverTap's Callback URL displayed during provider setup.

    During provider setup, you must include a key in your outgoing payload (for example, mid) with $$MessageID as its value. CleverTap replaces this dynamic placeholder with a unique identifier for each message sent. This identifier must be returned in the callback payload to allow CleverTap to attribute the callback to the appropriate campaign and user profile.

    Sample Callback Request

    The following is an example payload structure of a callback request that can be sent to the CleverTap callback URL:

    {
      "version": "v2",
      "events": {
        "success": [
          {
            "type": "delivered",	//Indicates the message was delivered to the intended recipient 
            "email": "[email protected]",	//recipient email address
            "meta": "[email protected]|1568798080|1730799638|20241105|0|wzrk_default|-17005910|"
          }
        ],
        "failed": [ 
          {
            "type": "unsubscribed", // Indicates the user has unsubscribed		
            "email": "[email protected]",		// The email address of the affected user
            "meta": "[email protected]|1568798080|1730714617|20241104|0|wzrk_default|-17005907|",
            "description": "User Unsubscribed"
          },
          {
            "type": "hard_bounce",
            "email": "[email protected]",
            "meta": "[email protected]|1568798080|1730799638|20241105|0|wzrk_default|-17005910|",
            "description": "Hard bounce detected"
          },
          {
            "type": "soft_bounce",
            "email": "[email protected]",
            "meta": "[email protected]|1568798080|1730714617|20241104|0|wzrk_default|-17005905|",
            "description": "Recipient Inbox Full"
          },
          {
            "type": "spam",
            "email": "[email protected]",
            "meta": "[email protected]|1568798080|1730714617|20241104|0|wzrk_default|-17005904|",
            "description": "Marked as spam"
          }
        ]
      }
    }
    

    Ensure your callback payload includes the following keys:

    keysDescriptionRequired
    versionIndicates the version of the callback payload schema. Must be set to v2.Yes
    typeType of event for tracing user engagement (for example, delivered, clicked, hard_bounce, unsubscribed).Yes
    emailRecipient email address.Yes
    metaRequired for delivery tracking (DLR). CleverTap sends a unique identifier in place of $$MessageID for every outgoing message. The ESP must return this exact identifier in the meta field of the callback payload. This ensures CleverTap correctly attributes the event to the corresponding user and campaignYes
    descriptionAn optional description about the event.No

    Incoming Payload Mapping to System Events

    CleverTap maps the incoming payloads with their respective system events. You can view these on the CleverTap dashboard.

    Callback TypeMaps to CleverTap System EventSample Payload Structure
    deliveredMaps to the Notification Delivered system event. The event property CT Source specifies the email provider used to send the campaign, for example, Generic email indicates that the campaign was sent using a generic email provider configuration.{
    "type": "delivered",
    "email": "[email protected]", "timestamp": 1425744000,
    "meta": "..."
    }
    hard_bounceMaps to the Notification Failed system event and also raises a Channel Unsubscribed event. The user is unsubscribed from future email campaigns. The description key in the callback payload is mapped to:
  • The Error event property in the Notification Failed event.
  • The Type event property in the Channel Unsubscribed event.
  • {
    "type": "hard_bounce",
    "email": "[email protected] ",
    "meta": "...",
    "description": "Invalid recipient address"
    }
    soft_bounceMaps to the Notification Failed system event. The description key is mapped to the error event property. In this case, the user is not unsubscribed from future email campaigns. {
    "type": "soft_bounce",
    "email": "[email protected] ",
    "meta": ".."
    "description": "Soft bounce detected"
    }
    unsubscribedMaps to the Channel Unsubscribed system event. The description key is mapped to the Type event property. Also, the user is unsubscribed from future email campaigns.{
    "type": "unsubscribed",
    "email": "[email protected]",
    "meta": "...",
    "description": "User unsubscribed"
    }
    spamMpas to the Channel Unsubscribed system event. The description key is mapped to the Type event property. Also, the user is unsubscribed from future email campaigns.{
    "type": "spam",
    "email": "[email protected] ",
    "meta": "..",
    "description"Spam detected""
    }
    clickedMaps to the Notification Clicked system event. You must use this only if you are not using CleverTap's default click tracking (to avoid duplicate click numbers).{
    "type": "clicked",
    "email": "[email protected]",
    "meta": "...",
    "description": "Link clicked"
    }

    Response Codes

    CleverTap sends the following status codes and descriptions as a response to the ESP upon receiving callbacks:

    Status CodeError MessageDescription
    200Callback received and processed.
    400Bad request. Some mandatory parameter was missing.Occurs when any of the mandatory keys are missing from the payload or when there are issues with the payload format.
    5xxServer errorCleverTap internal server error. Contact CleverTap support if the issue persists.

    The following is the sample response sent by CleverTap to the provider upon processing the callback payload successfully:

    {
      "TOTAL_EVENTS": 4,
      "PROCESSED_EVENTS": 4,
      "UNPROCESSED_EVENTS": []
    }
    

    ๐Ÿ“˜

    Retry Mechanism for Errors

    In case of HTTP 5XX errors, we recommend retrying after 10 minutes with exponential backoff as CleverTap does not deduplicate requests.