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> required | Event name |
payload { email: string<email>; amount: number; } required | Event payload |
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",
"amount": 10000
}
}'
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 \"amount\": 10000\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",
"amount": 10000
}}`,
}
(, )
.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",
"amount": 10000
}
}');
$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 \"amount\": 10000\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"
}