Webhook

A webhook is a mechanism for asynchronously receiving event notifications.


WebHooks

After you submit an email delivery request to Aurora SendCloud, the system synchronously returns the request result (such as whether the request was accepted). The final delivery result of the email (such as whether it was successfully delivered) and other interaction events (such as opens and clicks) are asynchronously pushed to your specified server via webhook.

Instead of requiring you to poll for updates, Aurora SendCloud actively pushes data to you in real-time when key events occur. This enables subsequent processes like data synchronization, statistical analysis, and triggering business workflows.

How It Works

Event Occurs: When an email-related event occurs (such as an email being opened, a recipient clicking a link, or the email bouncing), Aurora SendCloud generates corresponding data.

Trigger Notification: Aurora SendCloud immediately sends an HTTP POST request to the URL you configured in your account settings.

Data Transfer: The event data is contained within the body of the POST request, typically encoded in JSON format.

Receive & Process: Your server receives the request, parses the data, and handles subsequent business logic (such as updating a database or sending an internal alert) based on the event type.

Supported Event Types

Currently, Aurora SendCloud supports notifications for the following event types (partial list of common events):

Event TypeDescription
requestSend request event
deliveredMessage successfully delivered to the recipient's mail server
openRecipient opened the email
clickRecipient clicked a link in the email
unsubscribeRecipient clicked the unsubscribe link
spam-reportRecipient reported the email as spam
invalid_emailInvalid email address
soft_bounceSoft bounce (temporary delivery failure)
routeRouting status event

For the complete official list of event types and their detailed payload formats, please refer to the [Webhook Event Format Documentation].

Configuration & Usage Steps

Set the Webhook URL: Log in to the Aurora SendCloud platform, navigate to the Webhook settings page, and specify the API endpoint URL on your server that will receive the events.

Validate the Endpoint: Ensure your server can correctly handle any validation requests sent by Aurora SendCloud to confirm URL accessibility.

Parse Event Data: Write code to parse the JSON data in the POST request body and handle it accordingly based on the event type (such as identified by an event field).

Return Success Status: After successfully receiving and processing the data, your server should return a 2xx HTTP status code (such as 200 OK) to Aurora SendCloud. If a non-2xx status code is returned, Aurora SendCloud may attempt to retry the notification based on its retry policy.

Important Notes

Retry Mechanism: If your server is unreachable or does not return a successful response, Aurora SendCloud will typically retry the notification after a delay, up to a predefined retry limit.

Security Verification: It is highly recommended to implement security checks in your endpoint code (such as verifying the request source IP against a whitelist or validating a signature) to ensure requests are genuinely from Aurora SendCloud and prevent spoofing.

Processing Performance: Ensure your receiving endpoint can respond quickly (such as within 50ms) to avoid timeouts that might cause Aurora SendCloud to misinterpret the delivery as a failure.


Webhook Event Description

Request ( request )

ParameterTypeDescription
eventstringevent type: “request”
messagestringmessage content
maillistTaskIdlongtask ID will be generated when you send emails with address list
mail_list_task_idlongtask ID will be generated when you send emails with address list
messageIdstringmessageId
apiUserstringAPI_USER
categorystringmessage ID
recipientArraylistrecipients
emailIdslistemailId array
labelIdintcustom label ID
labelNamestringcustom label name
recipientSizeintcount of requests
timestamplongtimestamp
tokenstringrandom string of 50 characters
signaturestringsignature string
userHeadersstringcustom header with start of “SC-Custom”

Delivery ( deliver )

parametertypedescription
eventstringevent type: "deliver"
messagestringmessage content
apiUserstringAPI_USER
categorystringAPI_USER
maillistTaskIdlongtask ID will be generated when you send emails with address list
mail_list_task_idlongtask ID will be generated when you send emails with address list
emailIdstringunique ID of each email
outIpstringoutbound IP address
recipientstringrecipients
labelIdintcustom label ID
labelNamestringcustom label name
timestamplongtimestamp
tokenstringrandom string of 50 characters
signaturestringsignature string
userHeadersstringcustom header with start of "SC-Custom"

Open ( open )

parametertypedescription
eventstringevent type: "open"
messagestringmessage content
apiUserstringAPI_USER
categorystringAPI_USER
maillistTaskIdlongtask ID will be generated when you send emails with address list
mail_list_task_idlongtask ID will be generated when you send emails with address list
emailIdstringunique ID of each email
recipientstringrecipients
labelIdintcustom label ID
labelNamestringcustom label name
ipstringopened IP address
explorerNamestringbrowser name
explorerVerstringbrowser version
oSNamestringOS name
oSVerstringOS version
timestamplongtimestamp
tokenstringrandom string of 50 characters
signaturestringsignature string
userHeadersstringcustom header with start of "SC-Custom"

Click ( click )

parametertypedescription
eventstringevent type: "type"
messagestringmessage content
apiUserstringAPI_USER
categorystringAPI_USER
maillistTaskIdlongtask ID will be generated when you send emails with address list
mail_list_task_idlongtask ID will be generated when you send emails with address list
emailIdstringunique ID of each email
recipientstringrecipients
labelIdintcustom label ID
labelNamestringcustom label name
urlstringclicked links
ipstringclicked IP addresses
explorerNamestringbrowser name
explorerVerstringbrowser version
oSNamestringOS name
oSVerstringOS version
timestamplongtimestamp
tokenstringrandom string of 50 characters
signaturestringsignature string
userHeadersstringcustom header with start of "SC-Custom"

Unsubscribe ( unsubscribe )

parametertypedescription
eventstringevent type: "unsubscribe"
messagestringmessage content
apiUserstringAPI_USER
categorystringAPI_USER
labelIdintcustom label ID
labelNamestringcustom label name
maillistTaskIdlongtask ID will be generated when you send emails with address list
mail_list_task_idlongtask ID will be generated when you send emails with address list
emailIdstringunique ID of each email
recipientstringrecipients
ipstringIP address
explorerNamestringexplorer name
explorerVerstringexplorer version
oSNamestringOS name
oSVerstringOS version
timestamplongtimestamp
tokenstringrandom string of 50 characters
signaturestringsignature string
userHeadersstringcustom header with start of "SC-Custom"

Spam Reporting ( report_spam )

parametertypedescription
eventstringevent type: "report_spam"
messagestringmessage content
apiUserstringAPI_USER
categorystringAPI_USER
labelIdintcustom label ID
labelNamestringcustom label name
emailIdstringunique ID of each email
recipientstringrecipients
timestamplongtimestamp
tokenstringrandom string of 50 characters
signaturestringsignature string
userHeadersstringcustom header with start of "SC-Custom"

Invalid Email ( invalid )

parametertypedescription
eventstringevent type: "invalid"
messagestringmessage content
apiUserstringAPI_USER
categorystringAPI_USER
labelIdintcustom label ID
labelNamestringcustom label name
maillistTaskIdlongtask ID will be generated when you send emails with address list
mail_list_task_idlongtask ID will be generated when you send emails with address list
emailIdstringunique ID of each email
outIpstringoutbound IP address
recipientstringrecipients
timestamplongtimestamp
tokenstringrandom string of 50 characters
signaturestringsignature string
userHeadersstringcustom header with start of "SC-Custom"
substatdescstringinvalid subclass description
substatintegerinvalid subclass

Substat's Return Code and Description

subStatsubStatDesc
401in SendCloud blacklist
402unsubscribe
403server unreachable
404address format error
405IP and domain rejected
406address does not exist
407spam
408sender / recipient rejected
409others

Soft Bounce ( soft_bounce )

parametertypedescription
eventstringevent type: "soft_bounce"
apiUserstringAPI_USER
categorystringAPI_USER
labelIdintcustom label ID
labelNamestringcustom label name
maillistTaskIdlongtask ID will be generated when you send emails with address list
mail_list_task_idlongtask ID will be generated when you send emails with address list
emailIdstringunique ID of each email
outIpstringoutbound IP address
recipientstringrecipients
timestamplongtimestamp
tokenstringrandom string of 50 characters
signaturestringsignature string
userHeadersstringcustom header with start of "SC-Custom"
substatdescstringsoft drop back subclass description
substatintegersoft drop back subclass
causestringreasons for soft credit withdrawal

Substat's Return Code and Description

subStatsubStatDesc
503service not available
505ip or domain rejected
506email address does not exist
507spam
508sender / recipient rejected
509others

Mail Routing (route)

parametertypedescription
eventstringevent type: "route"
messagestringmessage content "mx route"
timestamplongtimestamp
fromstringsender email address
fromnamestringsender name
tostringrecipients address
tonamestringrecipient name
x_mx_mailfromstringenvelope sender
x_mx_rcpttostringActual recipient address
headersstringemail headers, formatted with JSON
htmlstringcontent in html format of routing email
textstringcontent in text format of routing email
subjectstringsubject
raw_message_urlstringThe download link of the route email, the suffix of the download file is '.eml', and the link is valid for 15 days
raw_messagestringraw email
tokenstringrandom string of 50 characters
signaturestringsignature string
userHeadersstringCustom header with start of "SC-Custom"
referencestringIf there is a value, it is: Message-ID of the email sent by SendCloud
emailIdstringThe unique id of the parent email. This field allows the reply email to be associated with the parent email. This value is parsed from reference and In-Reply-To.
labelIdintParent email customized label ID
labelNamestringParent email customized label Name

Note:

  1. When you do not pass in a custom Message-ID, the Message-ID in reference is automatically generated according to the platform rules, and the prefix of the Message-ID is the same as the prefix of the emailid. When you pass in a custom Message-ID through an SMTP request, the Message-ID in reference will be the Message-ID you passed in. When the reply email does not match the parent email, it will be empty.
  2. eg:"reference":"[email protected] (opens new window) " #ifaxin.com is the send domain name.
  3. Java parsing EML file example,click here download


Code examples

Python example

import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;

import org.apache.commons.codec.binary.Hex;

public boolean verify(String appkey, String token, long timestamp,
            String signature) throws NoSuchAlgorithmException, InvalidKeyException {
    Mac sha256HMAC = Mac.getInstance("HmacSHA256");
    SecretKeySpec secretKey = new SecretKeySpec(appkey.getBytes(),"HmacSHA256");
    sha256HMAC.init(secretKey);
    StringBuffer buf = new StringBuffer();
    buf.append(timestamp).append(token);
    String signatureCal = new String(Hex.encodeHex(sha256HMAC.doFinal(buf
            .toString().getBytes())));
    return signatureCal.equals(signature);
}
import hashlib, hmac
def verify(appkey, token, timestamp, signature):
    return signature == hmac.new(
        key=appkey,
        msg='{}{}'.format(timestamp, token),
        digestmod=hashlib.sha256).hexdigest()
function verify($appkey,$token,$timestamp,$signature){
    $hash="sha256";
    $result=hash_hmac($hash,$timestamp.$token,$appkey);
    return strcmp($result,$signature)==0?1:0;
}

Experience Now

If you don’t have url to receive data,try services of requestb.in or request this to experience WebHook.

  1. Click Create a RequestBin to generate an url
  2. Configure the URL in SendCloud to receive event data from WebHook
  3. After an operation (request, deliver, open), you can see all POST data of the event in requestb.in