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);
  • parameters to be sent by contact (optional parameters, used as variables to personalize the messages to be 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.

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": "e.bilovol@sendpulse.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\": \"e.bilovol@sendpulse.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 (4)

    Other useful articles

    Popular in Our Blog

    Try SendPulse today for free