SMS.to API currently supports 2 types of sending sms which are:


Both API endpoints are following this process:

  • Capture the request from the API and pass it to our queueing system
  • Process the request asynchonously by validating numbers, correcting and adjusting number prefix where possible, performing analysis on the message and decide what is the best route to deliver the sms
  • Deliver the sms based on the route defined after the processing to guarantee the deliverability of the message to the end user's mobile phone.


However, below we will notice that each API endpoint returns a different response. Here is an example of each one:

  • API endpoint delivering 1 single sms
    • {
        "message": "Message is queued for sending! Please check report for update",
        "success": true,
        "message_id": "11ec-832f-a6f3fcfe-9fea-02420a0002ab"
      }


  • API endpoint delivering multiple sms to multiple phones or multiple sms to a list
    • {
        "message": "Message is queued for sending! Please check report for update",
        "success": true,
        "campaign_id": "11ec-832f-ecdf64f6-8109-0242ac120004"
      }

        

    If a webhook exist to receive the final status of the message, the payload for that webhook is going to be:


{
  "trackingId": "11ec-832f-a6f3fcfe-9fea-02420a0002ab",
  "messageId": "11ec-832f-a6f3fcfe-9fea-02420a0002ab",
  "phone": "+35799234567",
  "status": "FAILED",
  "parts": 1,
  "price": 0.015
}


   This makes it easy for a developer to match the message_id received on the API response with the messageId or trackingId from the webhook. (Keep in mind that if this approach is selected, we have some limitations on how many requests per second we receive which can be found on https://support.sms.to/support/solutions/articles/43000682464-api-restrictions-rules-responses).


Now in the case of API endpoint delivering multiple sms to multiple phones or multiple sms to a list, as we will see above we receive campaign_id rather message_id. The reason we don't return back message_ids in this API is becauce we are capturing as fast as possible your request and on background we are processing each phone number and message and we try our best that all the messages and phones are valid and can be delivered. This way it reduces any unecessary costs on client's end. However the only thing we cannot guarantee is in case the phone is closed and sms cannot be delivered.


Below you can see the payload from the webhook in the case of getting a campaign_id back:


{
  "trackingId": "11ec-832f-ecdf64f6-8109-0242ac120004",
  "messageId": "11dc-642f-a6f3fcfe-9f4a-02440a0502ab",
  "phone": "+35799123456",
  "status": "DELIVERED",
  "parts": 1,
  "price": 0.015
}


In the above case, in order to find if the above webhook response is related with a campaign_id, the developer must compare it with the trackingId. So based on our examples the campaign_id 11ec-832f-ecdf64f6-8109-0242ac120004 will match with trackingId 11ec-832f-ecdf64f6-8109-0242ac120004


A common question we get from our users is:


How we can match campaign_id messages coming on webhook to know for each phone the actual message status?


The answer is that this can be done by saving this unique association campaign_id + phone number on the integrated system and then when a webhook arrives perform a search based on trackingId = campaign_id and phone = phone_saved_on_db. This way the integrated system can get the actual status of the sms for that campaign.


If you have any questions, please send an email to support@sms.to