Introduction
This page introduces the RCS API to give you an idea for how you would use the API from your own application. The walkthrough makes use of two popular command line utilities: I recommend you install these and run the commands from the scripts below as we proceed.Prerequisites
Let’s start a new terminal and set up a variable for the API:-s ensures that curl is silent and jq should format the output. You
should get something like this:
-i flag shows you more info about the response:
curl will show you more information that might help you
troubleshoot.
Basic authentication
You need an API Token as the basic auth credentials. This token is base 64 encoding of a token ID and a token secret. Contact support@kero.chat to get your API token. Here is an example:27EFC674F7A74CE4881AE4D800F92A6C-09-1:some-secret-code to base 64 and we get:
id property of one of your brand agents and place it in a new
variable:
Agent authentication
In order to send a message to a phone number you need an Agent Token. This token is a temporary authentication token that you use to send messages. The idea is to use the token until it expires. This improves the security as well as the throughput of your application. To get an agent bearer you make this call:agentToken is of primary interest to us. The expiry property shows
you when the accessToken expires. At this time you would have to fetch a new
value.
The value for expiryEpoch is expiry expressed as an
epoch value.
Notice the date format for used for expiry . This format is used for all date
values in this API.
The jq utility comes in handy to extract the token into an environment
variable:
Send text
Armed with an agent auth value we just need an MSISDN to send a message. It is a good idea to configure your own number here, so that you can see it on your device. You need the+ prefix followed by your country code and no
spaces.
content-type header whenever we use the
POST method on RCS API endpoints.
The reply contains the ID of the newly created message, expect something like
this:
test- . This is because I
used an MSISDN that begins with +0007. This special prefix is used to send
test messages; and they are not forwarded to any device. You can use these
MSISDN values to test your API calls during development.
Message query
Now that we sent a message we are ready to fetch the list of sent messages. Here, we provide criteria to pick the 3 most recent messages:/basic API, so we have to use basic auth:
sendStatus and sendStatusReason that
become available during message processing. These property values are usually
updated within a few seconds, but the magnitude of the delay depends on system
load.
For example, here is a message that failed: