How to Send Events to the SendPulse

To send an event, you will need:

  • the request URL;
  • the email address or phone number of the contact (required parameter, used to identify the contact);
  • contact parameters (optional parameters, used as variables to personalize the messages to be sent);
  • system parameter (an optional parameter used to identify the flow to which the data is sent).

You can send events to SendPulse with and without authorization.

To copy the URL to which you want to send the event, go to the "Autoflows" tab, and click Event Manager.

Click on the name of the created event.

Select a query method.

If you are using the SendPulse library on GitHub, the event must be passed with authorization using the URL from the "REST API POST" tab. You can get the keys for authorization in the "API" tab of your account settings.

If you are not using the library and need to pass events without authorization, use the URL from the "POST raw" tab.

Copy the URL from the necessary tab.

You can also pass the flow ID with the automation_id parameter to identify requests and pass personalized data to different flows using the same event link.

Note: when you pass an event, the parameter must be passed using the "Number" parameter type and the parameter must not be inside an array. When you create an event, it is not necessary to create the automation_id parameter.

To get the automation_id value, copy it in the address bar of the desired flow page.

For example, with a flow ID, you can send a trigger email from an online store in different languages. In one flow, you will have the English version and add it to the CRM for working with your English-speaking customers, add the certain customer manager name with a sender’s email address. In another flow, you will have the Polish email version, saving it to another CRM and another sender.

Example for PHP with cURL (without authentication):

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://events.sendpulse.com/events/id/eb561baa181247d1cd378c4ead632877/7043663',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
  "email": " test1@test1.com",
  "phone": "+123456789",
  "product_name": "product_name value",
  "product_id": 123,
  "product_link": "product_link value",
  "product_price": "product_price value",
  "product_img_url": "product_img_url value",
  "event_date": "2021-05-28"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Example for Python(without authentication):

import requests

url = "https://events.sendpulse.com/events/id/eb561baa181247d1cd378c4ead632877/7043663"

payload="{\n  \"email\": \"test1@test1.com\",\n  \"phone\": \"+123456789\",\n  \"product_name\": \"product_name value\",\n  \"product_id\": 123,\n  \"product_link\": \"product_link value\",\n  \"product_price\": \"product_price value\",\n  \"product_img_url\": \"product_img_url value\",\n  \"event_date\": \"2021-05-28\"\n}"
headers = {
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Example for PHP (with authorization using the library):

<?php

use Sendpulse\RestApi\ApiClient;
use Sendpulse\RestApi\Storage\FileStorage;

define('API_USER_ID', '');
define('API_SECRET', '');
define('PATH_TO_ATTACH_FILE', __FILE__);

$SPApiClient = new ApiClient(API_USER_ID, API_SECRET, new FileStorage());

// Start event automation360
$eventName = 'registration';
$variables = [
    "email" => "test1@test1.com",
    "phone" => "+123456789",
    "var_1" => "var_1_value"
];

var_dump($SPApiClient->startEventAutomation360($eventName,$variables));

Example for Python (with authorization using the library):

# -*-coding:utf8-*-

""" SendPulse REST API usage example

Documentation:
    https://login.sendpulse.com/manual/rest-api/
    https://sendpulse.com/api
"""

from pysendpulse.pysendpulse import PySendPulse

if __name__ == "__main__":
    REST_API_ID = ''
    REST_API_SECRET = ''
    TOKEN_STORAGE = 'memcached'
    MEMCACHED_HOST = '127.0.0.1:11211'
    SPApiProxy = PySendPulse(REST_API_ID, REST_API_SECRET, TOKEN_STORAGE, memcached_host=MEMCACHED_HOST)

    # Start event
    params = {
        "email": "test1@test1.com",
        "phone": "+123456789",
        "var_1": "var_1_value"
        }

    SPApiProxy.send_event('registration', params);
Rate this article about "How to Send Events to the SendPulse"

User Rating: 5 / 5

    Popular in Our Blog

    Try SendPulse today for free