Sending messages using the API
Use the Falu Messaging API to send messages
Besides using the Dashboard, you can also send messages directly through API calls to the endpoint https://api.falu.io/v1/messages
. Below, we will detail how you can send a message to a mobile number in Kenya using Postman as our API client.
Your workspace needs to be in Live mode to send messages using the Messages API. Only then will you get the API keys required to perform this transaction.
Sending a message using the Falu Messaging API
The following steps represent a typical workflow of sending a message using the API.
1. Get your secret key
Log into your Dashboard and head over to the Developers menu and copy your secret key.
Keep your keys secure by periodically rolling them. To do so, click on Roll/update secret under Actions
in the API Keys section of your Dashboard.
2. Configure your message
In this guide, we will use Postman as our API client for sending the message. You can also use other platforms such as the terminal/ command prompt, ReqBin, or Restfox.
As covered in the Messaging API Docs, the top-level messaging endpoint is https://api.falu.io/v1/messages
.
A sample cURL POST request to send a message is therefore:
In Postman, our request looks as follows:
3. Send your message
Confirm the details provided in your message and hit send!
A successful API call must have the following parameters:
To
- the recipient of the message.Body
- the message's contents.Stream
- the stream Falu should use to send the message. For more information, refer to streams documentation. Optionally, you can use a template to compose your message. You must then include the template ID or its alias in your parameters. For more details, check out templates documentation.
4. Monitor the status of your message
If your request was successfully sent, you should get a 200 OK status response.