Loading...

WhatsApp JSON API


In order to use the JSON API you need to have an account on EBulkSMS.

You may register an account and start testing our API right away. Click here to get started

Once you have an account you need to connect your WhatsApp number to start sending JSON requests to our API in the format below.

{
    "WA": {
        "auth": {
            "username": "your_username",
            "apikey": "your_api_key"
        },
        "message": {
            "subject": "A title for your message",
            "messagetext": "Your actual message goes here.",
        },
        "recipients":
        [
            "2348012345678",
            ...
        ]
    }
}

Now you only have to post the above JSON data using HTTP post to: https://api.ebulksms.com/sendwhatsapp.json

 

Parameters

Name Description
username Your login username on eBulkSMS (same as your email address)
apikey This is generated for you here.
subject

A title to identify this message on the platform

Alphanumeric text

messagetext

The text message you wish to send

Maximum of 1,600 characters

recipients

Recipient’s mobile number in full international format

VERY IMPORTANT!!! Ensure you specify the "application/json" Content-Type header. If you do not send this header you may get some unexpected errors.

 

If for any reason you post an XML request to the JSON API the response would be a 500 server error in an unformatted string.

 

API Responses


The following responses will indicate if your message was received - success, or if there was an error in your request - failure.

Importantly, you must be aware that errors that have to do with recipient numbers are permanent and such messages should not be resent.

For errors relating to the message format and actual message you could modify the message and resend it.

The same applies to the sender name. As much as possible avoid using special characters in the sender name.

 
Status Description
INVALID_JSON The JSON format is not valid.
MISSING_USERNAME Username field is empty
MISSING_APIKEY API Key field is empty
AUTH_FAILURE The username and API key combination is not correct.
MISSING_SUBJECT Subject is empty
MISSING_MESSAGE Empty message content
MISSING_RECIPIENT No mobile phone number was found
INVALID_RECIPIENT An invalid mobile phone number was found
INVALID_MESSAGE Message is either too long or contains characters that cannot be sent.
INVALID_SENDER The subject entered is not valid or is missing.
INSUFFICIENT_CREDIT Your account balance is too low to send the message.
UNKNOWN_CONTENTTYPE Check you post method to ensure you have included a content-type header of "application/json" or "text/json".
UNKNOWN_ERROR Rarely used - Errors in data specification / headers.
SUCCESS Your message was received successfully.
 

Other Error Responses

If for any reason you post an XML request to the JSON API the response would be a 500 server error in an unformatted string.

 

Response Format

Since we are using the JSON API, each of the above responses would be sent back with a JSON format as shown below.

{
    "response": {
        "status": "STATUS_STRING",
        "totalsent": "<number of recipients>",
        "cost": "<units charged>"
    }
}
 

Checking SMS Credit Balance


You may check your SMS balance using the API with a simple HTTP GET request. Just make a request to this URL:

https://api.ebulksms.com/balance/username/apikey

Here you will replace username and apikey with your username(email) and generated API key respectively.


For sample code on how to implement this in PHP please click here.


You may download this API documentation here.