curl php python javascript c# java

Introduction

Welcome to the NGH SMS API! You can use our API to send SMS, receive DLRs and fetch your account balance.

We have language bindings in Shell, C#, Python, JavaScript, PhP and Java! You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right.

To test the SMS API, you will need a valid API account. If you don't have one yet, click here to register for a FREE account.

Authentication

To authorize, use this payload alongside other JSON params:




  {
    "api_key": k_RdFidnulkkY7UVfmNtPZgL9C11J,
    "api_secret": s_rtRdFkkllfmNtPZgL9C11J,
   }


                    

Make sure to replace with your actual API key and secret.

NGH SMS API uses API key and API secret to allow access to the API. You can register a new API key and secret at our developer portal.

The API expects the API key and secret to be included in all API requests as part of the parameters supplied as follows:

api_Key: k_RdFidnulkkY7UVfmNtPZgL9C11J

api_secret: s_gTWNjzxXUKddffO8aio1vXC_jLOIiJ

SMS

Send Single SMS

 curl --location 'https://extranet.nghcorp.net/api/send-sms' \
--header 'Content-Type: application/json' \
--data '{ 
    "from": "senderid",
    "to": 22892470847,
    "text": "text sms",
    "reference": 1212,
    "api_key": "api_key",
    "api_secret": "api_secret"
}'

The above command returns JSON structured like this:

{
  "status": 200,
  "status_desc": "Success",
  "messageid": "23344555",
  "credits": 501
   
}

This endpoint sends to a single number

HTTP Request

POST https://extranet.nghcorp.net/api/send-sms

Query Parameters

Parameter Description Type Option
api_Key Key provided String Mandatory
api_secret Secret to be provided String Mandatory
to Destination number Numeric Mandatory
from Source address String Mandatory
text Your message String Mandatory
reference Unique identifier String Mandatory

Query Response (JSON Payload)

Parameter Description Type Option
Status 200 - Success
400 - Failed
Numeric Mandatory
status_desc Status description String Mandatory
message_id Reference on the server side String Optional
balance Credits Balance Numeric Optional

Send Multiple SMS

 
curl --location 'https://extranet.nghcorp.net/api/send-multiple' \
--header 'Content-Type: application/json' \
--data '{
    "credentials":{
           "api_key":"k_3uieonhsd",
           "api_secret":"s_kshdhjsd8hsd"
           },
    "messages":[
        {
            "from":"SENDER",
            "to":["2287945223342","2287945223341"],
            "content":"message 1"
            },
        {
            "from":"SENDER2",
            "to":228794521178,
            "content":"message 2"
            }
]
}'

The above command returns JSON structured like this:

 [
  
{
    "status": 200,
    "description": "Submitted",
    "to": "2287945223342",
    "from": SENDER,
    "id": 1689574280,
    "cost": 1
  },

  "status": 200,
    "description": "Submitted",
    "to": "2287945223341",
    "from": SENDER,
    "id": 1689574281,
    "cost": 1,
  },
{
    "status": 405,
    "description": "Invalid param - from",
    "to": "228794521178",
    "from": SENDER2,
  }]

This endpoint sends multiple SMS at the same time.

HTTP Request

POST https://extranet.nghcorp.net/api/send-multiple

Post Parameters

Parameter Description Type Option
credentials
  1. api_key
  2. api_secret
JSON payload All params mandatory
messages
  1. from
  2. to
  3. content
JSON payload All params mandatory

Query Response (JSON Payload)

Parameter Description Type Option
Status numeric status eg 200, 403 Numeric Mandatory
status_desc Status description String Mandatory
message_id Reference on the server side String Optional
cost SMS cost Numeric Optional
to Destination mobile String Mandatory
from Sender ID String Optional
text Message sent string Optional

Receive Delivery Reports

 

https://clienturl.com/dlr/receive?mobile_number=228999999&message_id=1212&status=1

The below GET call to your URL to should return http status code 200

 
 Received 

                    

This section specifies how to receive delivery reports

HTTP Request

GET http://your-url.com/dlr/

URL Parameters

Parameter Description Type Option
message_id The unique identifier for the message which you received from our system String Mandatory
status The actual status of the message. Refer to the table below Numeric Mandatory
mobile_number The destination mobile number String Mandatory

Status Codes

Status Meaning
1 Success
2 Failed
3 Blacklisted

Fetch Balance

 curl --location 'https://extranet.nghcorp.net/api/send-sms' \
--header 'Content-Type: application/json' \
--data '{ 
    "api_key": "api_key",
    "api_secret": "api_secret"
}'

The above command returns JSON structured like this:

 {
  
"status": 200,
"status_desc": balance fetched successfully
"balance" : 455
}

This section specifies how to retrieve your account balance

HTTP Request

POST https://extranet.nghcorp.net/api/balance

Query Parameters

Parameter Description Type Option
api_Key Key provided String Mandatory
api_secret Secret to be provided String Mandatory

Response Parameters

Parameter Description Type Option
status If the request was successful or not String Mandatory
status_desc Status description String Mandatory
balance Remaining Balance Numeric Mandatory

SMPP SMS

The API uses the following connection parameters:

Parameter Meaning
host URL or IP of the smpp server
port the smpp port
username System ID unique to your account
password Authentication password

Errors

The API uses the following error codes:

Error Code Meaning
100 Only POST is allowed.
101 Invalid JSON
102 Missing credentials
103 Invalid credentials
104 No data
105 Missing from parameter.
106 Sender ID error
107 Missing message.
108 Missing to number
109 Invalid to number
110 Route not found
111 Insufficient credit
112 Billing problem
113 Unable to send sms - internal error