How to use Nexmo
Nexmo is one of the providers supported by Delivery API. We are currently only supporting SMS as the type of message that can be delivered via Nexmo.
To add Nexmo as one of your providers in your Delivery API account, two Nexmo identifiers are required:
- the Nexmo API key
- the Nexmo API secret.
These identifiers can be found in this page once you have logged into your own Nexmo account.
The values for the Key and the Secret can be added to your Delivery API account via the console or by using an API call as explained here.
In the next example we will show you how to use the API to add Nexmo as a new provider, considering your key to be ‘examplekey’ and your secret value to be ‘secret’.
$ curl https://api.dapi.io/v1/providers/nexmo \
-u 'USER_ID:USER_SECRET' \
-H 'Content-Type: application/json' \
-X PUT \
-d '{
"API_KEY": "examplekey",
"API_SECRET": "secret",
}'
To use your own account, you need to change the values “USER_ID” and “USER_SECRET” into the values of your own account as can be found in the Delivery API console. Also the values for your ‘examplekey’ and ‘secret’ need to be replaced by the values as can be found in your own Nexmo account (as described above).
If everything is successful the API will return a 200 status code. Once Nexmo has been added as one of your providers, you can start sending messages via Delivery API to Nexmo.
The following example is sending a sms message with the text “Congratulations! You send this sms via Delivery API using Nexmo” to the mobile phone ‘+31612345678’.
$ curl https://api.dapi.io/v1/messages \
-u 'USER_ID:USER_SECRET' \
-H 'Content-Type: application/json' \
-X PUT \
-d '{
"provider": "nexmo",
"type": "sms",
"arguments": {
"from": "DeliveryAPI",
"to": "+31612345678",
"text": "Congratulations! You send this sms via Delivery API using Nexmo"
}
}'
Change the ‘to’ number with your own mobile number, and you will receive your first sms using Nexmo as the provider.
More examples on what you can do via the API and with more programming languages can be found in the API reference