fb pixel

Introduction

This guide helps to get you up and running with the Sakari SMS APIs within 5 minutes. You’ll learn how to authenticate your application so you can call our API’s as well as send your first SMS message.

What You’ll Need

  1. An account with Sakari. If you don’t already have an account, you can register at: https://sakari.io/signup
  2. A tool such as curl, Postman or alternative to make API calls
  3. A mobile device with working phone number capable of receiving SMSs

Step 1 – Authenticate

Our API’s are protected by OAuth V2. OAuth V2 is a industry standard for authenticating when using API’s. Sakari provides you with a client id and secret which can be exchanged for a JWT which can then be used to call our API’s.

  1. Login to https://hub.sakari.io to retrieve your API Credentials. Once logged in, click on the “cog” icon in the top right corner. This will display your account details. Towards the bottom, you will see “API Credentials”. If you haven’t requested your credentials already you should see a “Request Credentials” button. Click on this and record the account id and API credentials which are displayed.
  2. Using your preferred tool/language, make a request to the /oauth2/token endpoint

    Curl

    curl -X POST https://api.sakari.io/oauth2/token -H "Content-Type: application/json" -d 
    '{
    "grant_type": "client_credentials",
    "client_id": "12345678-1234-1234-1234-123412341234",
    "client_secret": "87654321-4321-4321-4321-432143214321"
    }'

  3. Example Response
    {
      "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb25zdW1lcklkIjoiOGNiOGM0ZWItOWZlNS00YTY1LThhNmItOTQ5YWFhNTdiZTFiIiwiaWF0IjoxNTI4MzIxNzg3LCJleHAiOjE1MzU1MjE3ODcsImF1ZCI6IkwtY1dCVDFyNU8xQk53dzJDOENOX25xa2txcV9KLVoxIiwiaXNzIjoiaHR0cHM6Ly9hcGkuc2FrYXJpLmlvIiwic3ViIjoiNWIwYzlmYjA4NmVlYjYxMWQxNDY4YjRmIn0.xjTaKtZcnasJsGVdzSdjeVdgROo0Ex9d_NkA4fyrlIM",
      "token_type": "Bearer"
    }
  4. Record the access_token from the response for use in the next step

Step 2 – Send a Message

There is one simple API call which you can use to send one message or a thousand messages. This API has the following parameters:

  1. A list of contacts
  2. Message template – you can send a static message to all the contacts or you can use placeholders to dynamically insert data based upon the contact

Actions

  1. Using the account id and access_token value from Step 1, make a request to the /v1/accounts/%ACCOUNT_ID%/messages endpoint. Ensure you replace the placeholders for %ACCOUNT_ID%, %ACCESS_TOKEN% and %MOBILE_NUMBER%

    Curl

    curl -X POST https://api.sakari.io/v1/accounts/%ACCOUNT_ID%/messages -H "Content-Type: application/json" -H "Accept: application/json" 
    -H "Authorization: Bearer %ACCESS_TOKEN%" 
    -d 
    '{
       "contacts": [{
       "mobile": {
         "number": "%MOBILE_NUMBER%"
       }
    }],
    "template": "Congratulations! You just sent your first message!"
    }'
    

Step 3 – Verify message receipt
Within a few seconds, you should receive a message to the number specified

Summary
This is just tiny piece of what our API platform at Sakari has to offer. Check out our other blog posts which will show you how to use templates to send customized messages to each contact or how to schedule messages to be sent at a later time or on a re-occuring schedule.

If there’s a feature you feel is missing, or you are running into issues, send us an email or use our live chat. Happy Messaging!