Skip to content

Trigger an event

This allows you to trigger an event for your customers

Post
bash
https://api.bunce.so/v1/events/trigger

Trigger an event.

If successful, your response includes a boolean value specifying if the event has been triggered successfully. If there is an error with any of the parameters, it will return a 422 HTTP status code with details in an error object.

Request

Body Parameters required

event_id string<uuid> requiredEvent name
payload { email: string<email, required> } requiredEvent payload

Payload must contain email and other paramenters keys that was added when the event was created

For parameter values with timestamp data type, values are expected to be in YYYY-MM-DDTHH:MM:SSZ (UTC) format. values for timestamp data type not in the format will be skipped.


bash
curl --request POST \
  --url https://api.bunce.so/v1/events/trigger \
  --header 'Content-Type: application/json' \
  --header 'X-Authorization: sk_live_************************' \
  --data '{
    "event_id": "9bb6215c-e2b1-4e51-abff-3a96ca185088",
    "payload": {
        "email": "johndoe@example.com",
        "date_purchased" : "2012-09-03T14:30:00Z"
    }
}'
go
import (
	"fmt"
	"strings"
	"net/http"
	"io/ioutil"
)

url := "https://api.bunce.so/v1/events/trigger"

payload := strings.NewReader("{\n \"event_id\": \"9bb6215c-e2b1-4e51-abff-3a96ca185088\",\n \"payload\": {\n \"email\": \"johndoe@example.com\",\n \"date_purchased\": 2012-09-03T14:30:00Z\n    }\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("X-Authorization", "sk_live_************************")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res)
fmt.Println(string(body))
js
import  from 'node-fetch'

let  = 'https://api.bunce.so/v1/events/trigger'

let  = {
  : 'POST',
  : {
    'X-Authorization': 'sk_live_************************',
    'Content-Type': 'application/json',
  },
  : `{"event_id": "9bb6215c-e2b1-4e51-abff-3a96ca185088",
    "payload": {
        "email": "johndoe@example.com",
        "date_purchased" : "2012-09-03T14:30:00Z"
    }}`,
}

(, )
  .then(() => .json())
  .then(() => .())
  .catch(() => .('error:' + ))
php
<?php

$client = new http\Client;
$request = new http\Client\Request;

$body = new http\Message\Body;
$body->append('{
    "event_id": "9bb6215c-e2b1-4e51-abff-3a96ca185088",
    "payload": {
        "email": "johndoe@example.com",
        "date_purchased" : "2012-09-03T14:30:00Z"
    }
}');

$request->setRequestUrl('https://api.bunce.so/v1/events/trigger');
$request->setRequestMethod('POST');
$request->setBody($body);

$request->setHeaders([
  'X-Authorization' => 'sk_live_************************',
  'Content-Type' => 'application/json'
]);

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
java
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.bunce.so/v1/events/trigger"))
    .header("X-Authorization", "sk_live_************************")
    .header("Content-Type", "application/json")
    .method("POST", HttpRequest.BodyPublishers.ofString("{\n \"event_id\": \"9bb6215c-e2b1-4e51-abff-3a96ca185088\",\n    \"payload\": {\n \"email\": \"johndoe@example.com\",\n \"date_purchased\": 2012-09-03T14:30:00Z\n }\n}"))
    .build();

HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());

System.out.println(response.body());

Response

json
{
  "success": true,
  "data": true,
  "message": "Event successfully triggered"
}