Send SMS


How to send an sms

To send a sms you must post the following information in JSON. Using the url provided by CinetPay: https://api-notitia.cinetpay.com/sms/1/text/single

Header parameter

Key Value
Content-Type application/json
Authorization App myapikey

Body parameter

Parameter Type Mandatory Description
from String yes Represents the sender's ID and can be alphanumeric or numeric. The length of the alphanumeric Sender ID must be between 3 and 11 characters (example: company name). The length of the numeric sender ID must be between 3 and 14 characters.
to Array yes Table of message destination addresses. If you want to send a message to a destination, a single string is supported instead of an array. The destination addresses must be in international format (Example: 41793026727).
text String yes Text of the message that will be sent

Example

Php example

 <?php

    function curlPost()
    {
        $curl = curl_init();

        curl_setopt_array($curl, array(
        CURLOPT_URL => 'https://api-notitia.cinetpay.com/sms/1/text/single',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS =>'{
            "from":"CinetPayDemo",
            "to":["2250758712792"],
            "text":"Ceci est un text pour les sms"
        }',
        CURLOPT_HTTPHEADER => array(
            'Authorization: App 7c95244ccfd654bdb51bf52821b25gh67f-fbf9cc4d-1cfd-482e-a921-694bb499db80',
            'Content-Type: application/json'
        ),
        ));

        $response = curl_exec($curl);

        curl_close($curl);
        echo $response;

        return json_decode($response);
    }

    curlPost(); 

Response query

Example of a successful response

{
    "messages": [
        {
            "to": "2250758712792",
            "status": {
                "groupId": 1,
                "groupName": "PENDING",
                "id": 7,
                "name": "PENDING_ENROUTE",
                "description": "Message sent to next instance"
            },
            "messageId": "34426316966003536518",
            "smsCount": 1
        }
    ]
}

Example of an error response

If you try to send a message without authorization, you will receive a 401 Unauthorized error.

{
  "requestError": {
    "serviceException": {
      "messageId": "UNAUTHORIZED",
      "text": "Invalid login details"
    }
  }
}

If you try and don't have enough credit, you will get this message

{
    "messages": [
        {
            "to": "2250758712792",
            "status": {
                "groupId": 5,
                "groupName": "REJECTED",
                "id": 12,
                "name": "REJECTED_NOT_ENOUGH_CREDITS",
                "description": "Not enough credits"
            },
            "messageId": "34431579683903536497",
            "smsCount": 1
        }
    ]
}