Skip to content

Send Push Notification

Post
bash
https://api.bunce.so/v1/messaging/transactional/send/push-notification

Send

If successful, your response includes a message that your message has been sent 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

title string requiredMessage Title
email string<email> nullableRecipient email. Required if recipient customer_id is not sent
customer_id string nullableRecipient Customer ID. Required if recipient email is not sent
message_type string requiredMessage Type
message string requiredMessage Text
provider string requiredProvider to use for sending the Push Notification.
Supported providers:
firebase
device_token string nullableRecipient Device token to recieve the message. Required if customer does not already exist or does not have a device token
device_type string nullableRecipient device type. Required if customer does not already exist or does not have a device token.
Supported device types:
android ios windows
bash
curl --request POST \
  --url https://api.bunce.so/v1/messaging/transactional/send/push-notification \
  --header 'Content-Type: application/json' \
  --header 'X-Authorization: sk_live_************************' \
  --data '{
    "title": "Another Event",
    "customer_id" : "837473484584359745",
    "message_type" : "otp",
    "message" : "Push notification from API",
    "provider": "firebase",
    "device_token": "ahjscuasahscg873ygw78usbvca83r7wf3wvefuq783r4",
    "device_type" : "android"
}'
go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io/ioutil"
)

func main() {

	url := "https://api.bunce.so/v1/messaging/transactional/send/push-notification"

  payload := strings.NewReader("{\n    \"title\": \"Another Event\",\n    \"customer_id\": \"837473484584359745\",\n    \"message_type\": \"otp\",\n    \"message\": \"Push notification from API\",\n    \"provider\": \"firebase\",\n    \"device_token\": \"ahjscuasahscg873ygw78usbvca83r7wf3wvefuq783r4\",\n    \"device_type\": \"android\"\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
const  = {
  : 'POST',
  : {
    'X-Authorization': 'sk_live_************************',
    'Content-Type': 'application/json',
  },
  : '{"title":"Another Event","customer_id":"837473484584359745","message_type":"otp","message":"Push notification from API","provider":"firebase","device_token":"ahjscuasahscg873ygw78usbvca83r7wf3wvefuq783r4","device_type":"android"}',
}

(
  'https://api.bunce.so/v1/messaging/transactional/send/push-notification',
  ,
)
  .(() => .())
  .(() => .())
  .(() => .())
php
<?php

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

$body = new http\Message\Body;
$body->append('{
    "title": "Another Event",
    "customer_id" : "837473484584359745",
    "message_type" : "otp",
    "message" : "Push notification from API",
    "provider": "firebase",
    "device_token": "ahjscuasahscg873ygw78usbvca83r7wf3wvefuq783r4",
    "device_type" : "android"
}');

$request->setRequestUrl('https://api.bunce.so/v1/messaging/transactional/send/push-notification');
$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/messaging/transactional/send/push-notification"))
    .header("X-Authorization", "sk_live_************************")
    .header("Content-Type", "application/json")
    .method("POST", HttpRequest.BodyPublishers.ofString("{\n    \"title\": \"Another Event\",\n    \"customer_id\": \"837473484584359745\",\n    \"message_type\": \"otp\",\n    \"message\": \"Push notification from API\",\n    \"provider\": \"firebase\",\n    \"device_token\": \"ahjscuasahscg873ygw78usbvca83r7wf3wvefuq783r4\",\n    \"device_type\": \"android\"\n}"))
    .build();
HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());

Response

json
{
  "success": true,
  "data": null,
  "message": "Push notification message sent successfully"
}