Documentation - Contacts


  1. Creating a new contact
  2. Updating an existing contact
  3. Adding a phone number to an existing contact
  4. Removing a phone number from an existing contact
  5. Getting a contacts information
  6. Searching contacts

Contacts - Creating a new contact

You can create new contacts on SMS gateway using the contact API.
Below is some sample requests and response. For complete API documentation on creating a new contact please refer to the Swagger (Open API Specification) documentations here: SMS Gateway API Definition


API Request

Request Endpoint
Endpoint: https://smsgateway.me/api/v4/contact
Method: POST
Request Parameters
Name Location Required Description
Authorization header true Your API token found on the settings page
Content body true JSON payload with the information of contacts the API should create

Request Example

List of contacts to create

[
  {
    "name": "John Doe",
    "phone_numbers": [
      "+447791065791",
      "+447791064782"
    ]
  },
  {
    "name": "Jane Doe",
    "phone_numbers": [
      "+447791064783",
      "+447791064784"
    ]
  }
]

Response Examples

Successful Response

A list of contacts that are now created

Response Code: 200

[
  {
    "id": 1,
    "name": "John Doe",
    "phone_numbers": [
      "+447791064781",
      "+447791064782"
    ]
  },
  {
    "id": 2,
    "name": "John Doe",
    "phone_numbers": [
      "+447791064783",
      "+447791064784"
    ]
  }
]

Validation Error

When a validation exception occurs

Response Code: 400

{
  "status": "fail",
  "message": "failed validation",
  "data": [
    {
      "key": "name",
      "errors": [
        "This value should not be blank."
      ]
    },
    {
      "key": "phone_numbers",
      "errors": [
        "This value should not be blank."
      ]
    }
  ]
}

Error Response

When a request can not be processed

Response Code: 40x | 500

{
  "status": "fail",
  "message": "Could not process request",
  "data": {
    "exception": "Error message"
  }
}

SDK Examples

You can use our Swagger generated PHP SDK to help integrate with our service. If you wish to use SMS Gateway Me with a different platform you may generate your own client using the swagger file.

Installation Instructions: PHP SMS Gateway SDK
Swagger Definition: SMS Gateway API Definition


Request Example

<?php

require 'vendor/autoload.php';

use SMSGatewayMe\Client\ApiClient;
use SMSGatewayMe\Client\Configuration;
use SMSGatewayMe\Client\Api\ContactApi;
use SMSGatewayMe\Client\Model\CreateContactRequest;

// Configure client
$config = Configuration::getDefaultConfiguration();
$config->setApiKey('Authorization', 'your-token-here');
$apiClient = new ApiClient($config);

// Create contact client
$contactClient = new ContactApi($apiClient);

// Create Contact
$createContactRequest1 = new CreateContactRequest(
    [
        'name'         => 'John Doe',
        'phoneNumbers' => [
            '07791064781',
            '07791064782'
        ]
    ]
);
$createContactRequest2 = new CreateContactRequest(
    [
        'name'         => 'Jane Doe',
        'phoneNumbers' => [
            '07791064783',
            '07791064784'
        ]
    ]
);
$createContactRequest3 = new CreateContactRequest(
    [
        'name'         => 'Kid Doe',
        'phoneNumbers' => [
            '07791064785',
            '07791064786'
        ]
    ]
);
$contacts = $contactClient->createContacts([$createContactRequest1, $createContactRequest2, $createContactRequest3]);
print_r($contacts);

Successful Response

Array
(
    [0] => SMSGatewayMe\Client\Model\Contact Object
        (
            [id:protected] => 12590982
            [name:protected] => John Doe
            [phoneNumbers:protected] => Array
                (
                    [0] => 07791064781
                    [1] => 07791064782
                )
        )

    [1] => SMSGatewayMe\Client\Model\Contact Object
        (
            [id:protected] => 12590983
            [name:protected] => Jane Doe
            [phoneNumbers:protected] => Array
                (
                    [0] => 07791064783
                    [1] => 07791064784
                )
        )

    [2] => SMSGatewayMe\Client\Model\Contact Object
        (
            [id:protected] => 12590984
            [name:protected] => Kid Doe
            [phoneNumbers:protected] => Array
                (
                    [0] => 07791064785
                    [1] => 07791064786
                )
        )
)