Documentation - Contacts - Create New Contact

  1. Create New Contact
  2. List of Contacts
  3. Fetch Single Contact

# Create new contact

You can use the SMS Gateway API to add contacts to your account programmatically. Contacts make it easier to view your messages on the admin console or to query your messages using our API. A post request is required to with the contact's information to our sms gateway to add a new contact.

API Reference

API Endpoint
Method: POST
Request Parameters
Parameter Required Description
email YES Your username for the site
password YES Your password for the site
name YES The contact's name
number YES The contact's number
Success Response
Status Code: 201 Created
Content Type: application/json
Output format: See Example
Failed Response
Status Code: 422 Unprocessable Entity
Content Type: application/json
Output format: See Example

PHP Example

The below example uses the Android SMS Gateway API PHP library which is available for download - This library requires PHP CURL to be enabled.
Please note that although this is PHP example using the SMS Gateway library you may make requests in any language using the parameters above.

  • <?php
  • include "smsGateway.php";
  • $smsGateway = new SmsGateway('', 'password');
  • $result = $smsGateway->createContact('Mr Foo Bar', '+44771234567');
  • ?>

The result will contain a associative multidimensional array. The first item being status which is the response code returned from the SMS Gateway API. The second item being response which will be the array version of the response examples of which can be found below.

Success Example

  • {
  • "success": true,
  • "result": {
    • "user_id': 1
    • "name": "Mr Foo Bar"
    • "number": "+4412345678"
    • "created_at": "+4412345678"
    • "updated_at": "+4412345678"
  • }
  • }

Error Example

  • {
  • "success": false,
  • "errors": {
    • "name": ["The name field is required."]
    • "number": ["The name field is required."]
  • }
  • }