Loading...

Bulk SMS XML API


In order to use the XML API you need to have an account on NaijaSMSPortal.

First you need to create your account on NaijaSMSPortal in order to start using our XML API right away. Just click here to register now.

Once you have an account you will be able to start sending XML requests to our API in the format below

<SMS>
    <auth>
        <username>your_username</username>
        <apikey>your_api_key</apikey>
    </auth>
    <message>
        <sender>Sender_Name</sender>
        <messagetext>Your_message</messagetext>
        <flash>0</flash>
    </message>
    <recipients>
        <gsm><msidn>23480...</msidn><msgid>uniqueid1...</msgid></gsm>
    </recipients>
</SMS>

Now you only have to post the above XML data using HTTP post to: https://www.naijasmsportal.com/api/sendsms.xml

 

Parameters

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

Your chosen sender name

Alphanumeric sender name: Maximum of 11 characters

Numeric sender name: Maximum of 14 characters

messagetext

The text message you wish to send

Single page message is 160 characters

Maximum of 6 pages with 918 characters

flash

0 - for normal SMS.

1 - for flash text (Only displays on the screen and will not be saved to the recipients phone)

gsm

Recipient’s mobile number in full international format

msidn - the mobile phone number

msgid - a unique id if you need to request delivery reports.

For messages which require delivery reports please use this format:

<gsm><msidn>23480...</msidn><msgid>your_unique_message_id</msgid></gsm>

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

 

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_XML The XML 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_SENDER Sender name is empty
MISSING_MESSAGE Empty message content
MISSING_RECIPIENT No valid mobile phone number was found
INVALID_MESSAGE Message is either too long or contains characters that cannot be sent.
INVALID_SENDER The sender name 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 there you added a content-type header of "application/xml" or "text/xml".
UNKNOWN_ERROR Rarely used - Errors in data specification / headers.
SUCCESS Your message was received successfully.
 

Response Format

Since we are using the XML API, each of the above responses would be sent back in an XML envelop as shown below.

<?xml version="1.0" encoding="UTF-8"?>
<response>
    <status>STATUS_STRING</status>
    <totalsent>{number of valid recipients}</totalsent>
    <cost>{number of units used}</cost>
</response>
 

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://www.naijasmsportal.com/api/balance/username/apikey

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


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


You may download this API documentation here.