The purpose of the subscriptions service is to send notifications. To send them, you need to remember your account id and the service type (notification type) and all the required parameters defined in your subscription type.

This service is a POST to the API. You create a new notification.

Highlights:

  1. This is a POST request.

  2. The URL is https://api2-ww-us-001.yalochat.com/notifications/api/v1/accounts/@account_id/bots/@flow_id/notifications, and for India Only: https://api2-in-001.yalochat.com/notifications/api/v1/accounts/@account_id/bots/@flow_id/notifications

  3. The payload is as follows:

{
  "type": "TEMPLATE_ID",
  "users": [
    {
      "phone": "+50212345678",
      "nonce": "UNIQUE ID TO AVOID DUPLICATED SENDINGS"
      "params": {
        "EXAMPLE_KEY": "EXAMPLE_VALUE"
      }
    }
  ]
}
  • type: is the template id.
  • users: is the list of users to notify. Each element is a JSON object.
    • phone: is the phone number to send the notification.
    • nonce: if you have a unique id (transaction id, purchase id, put that string here, if not, send it empty. It allows identifying already sent notifications. Because we avoid sending this if another notification with the same nonce is created.
    • params: all the data used by the template.
  1. If you send the notification and all the required params are included, you will receive a WhatsApp notification.
1216
curl -X POST \
https://api2-ww-us-001.yalochat.com.com/api/v1/accounts/<accountid>/bots/<flow_id>/notifications \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{ 
	"type": "<hsm>",
	"users": [
		{
			"phone": "<phone>",
			"nonce": "<nonce>",
			"params": {
				"param_1": "<param_value_1>",
				"param_2": "<param_value_2>",
			},
			"labels":[
				{
					"key_1":"<key_1>",
					"value_1":"<value_1>"
				},
				{
					"key_2":"<key_2>",
					"value_2":"<value_2>"
				}
			]	
		}
	]
}'
{
    "success": true
}
{
  "success": false,
  "reason": "Required parameters are not present in the request"
}
{
  "success": false,
  "reason": {
    "error": <error-code>,
    "description": <description>
  }
}

Authentication

Yalo's APIs use a API Token authentication protocol, in which you send your credential through the headers. For example, see the cURL call below:

curl -L -X POST 'https://api2-ww-us-001.yalochat.com/notifications/api/v1/accounts/@account_id/bots/@flow_id/notifications' \                       
-H 'Authorization: Bearer API_TOKEN_HERE' \
-H 'Content-Type: application/json' \
--data-raw '{
  "type": "TEMPLATE_IDENTIFIER",
  "users": [
    {
      "phone": "+50212345678",
      "params": {
      }
    }
  ]
}'