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 - Searching contacts

You can search for contacts using our SMS contact API
Below is some sample requests and response. For complete API documentation on searching contacts 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/search
Method: POST
Request Parameters
Name Location Required Description
Authorization header true Your API token found on the settings page
query body true The search query

Request Example

{
  "filters": [
    [
      {
        "field": "name",
        "operator": "=",
        "value": "John Doe"
      }
    ],
    [
      {
        "field": "phone_numbers.phone_number",
        "operator": "=",
        "value": "+447791064782"
      }
    ]
  ],
  "order_by": [
    {
      "field": "name",
      "direction": "desc"
    }
  ],
  "limit": 5,
  "offset": 5
}

Response Examples

Response Code: 200

{
  "results": [
    {
      "id": 59484211,
      "device_id": 500,
      "phone_number": "07791064781",
      "message": "Hello World",
      "status": "pending",
      "log": [
        {
          "status": "pending",
          "occurred_at": "2018-05-05T16:54:05+00:00"
        }
      ],
      "created_at": "2018-05-05T16:54:05+00:00"
    },
    {
      "id": 59484212,
      "device_id": 600,
      "phone_number": "07791064782",
      "message": "Hello World",
      "status": "pending",
      "log": [
        {
          "status": "pending",
          "occurred_at": "2018-05-05T16:54:05+00:00"
        }
      ],
      "created_at": "2018-05-05T16:54:05+00:00"
    }
  ],
  "count": 120
}

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;

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

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

/**
 *   Contact Search
 *
 *   Valid Fields: id, name, phone_numbers.phone_number
 *
 *   Filters is a multidimensional array.
 *   Each array inside of $filters is a query group.
 *   An 'and' is done for items within the same group. and an 'or' between groups.
 */
$contacts = $contactClient->searchContacts(
    [
        'filters' => [
            [
                [
                    'field'    => 'name',
                    'operator' => '=',
                    'value'    => 'John Doe'
                ]
            ],
            [
                [
                    'field'    => 'phone_numbers.phone_number',
                    'operator' => '=',
                    'value'    => '07791064781'
                ]
            ]
        ],
        'order_by' => [
            [
                'field' => 'name',
                'direction' => 'DESC'
            ],
            [
                'field' => 'id',
                'direction' => 'ASC'
            ]
        ],
        'limit'   => 5,
        'offset'  => 5
    ]
);
print_r($contacts);

Successful Response

SMSGatewayMe\Client\Model\ContactSearchResult Object
(
    [count:protected] => 59
    [results:protected] => Array
        (
            [0] => SMSGatewayMe\Client\Model\Contact Object
                (
                    [id:protected] => 12590982
                    [name:protected] => John Doe
                    [phoneNumbers:protected] => Array
                        (
                            [0] => 07791064781
                            [1] => 07791064786
                            [2] => 07791064787
                        )
                )
        )
)