How do I use my API key?


Below you will find all the information you need to start using your API key. If you have any questions, please feel free to leave a comment at the end.

Where can I see what my API key is?

You can get your API key by going here.

Where can I see what my user ID is?

You can get your user ID by going here.

How do I send an SMS Using my API Key?

To send an SMS, simply call the API as follows:

https://www.namhost.com/api/sms/[USER_ID]/[API_KEY]?cell_nr=27812345678&message=Your+Url+Encoded+Message

So, if your API key was "abcdefghijklmnop" and your user ID was "90032489322", then you would call it like this:

https://www.namhost.com/api/sms/90032489322/abcdefghijklmnop?cell_nr=27812345678&message=Your+Url+Encoded+Message

What is an URL Encoded Message?

Due to the fact that the API is http based, it requires calls be made to it in a way this it understands. In other words, instead of calling it with:

&message=this is my message

You would call it using:

&message=this+is+my+message

For more information on url encoding strings, we recommend reading this.

The Response?

After you have made the call, you will get a result in JSON. Here is an example of what it could look like:

{"success":true,"errors":[],"message_id":123969775,"message":"SMS Successfully Queued","remainingCredits":2933774}

The string you see above is known as a "JSON String". (Click here if you want to know more about JSON).

To make the string easier to read, here it is formatted:

{
     success: true,
     errors: [ ],
     message_id: 600969775,
     message: "SMS Successfully Queued",
     remainingCredits: 915
}

Here is a description of each field in the result object:

successIf true, it means the message was successfully sent. 
errorsIf anything went wrong, the errors would be contained here, and the success field would be marked as false
message_idThis is the ID we have saved for the message in our system. In future, it will be a way to link up messages and do extra queries on sent messages.
remainingCreditsAfter the message was sent, this is how many credits were remaining.