Documentation - Messages


  1. Sending a SMS messages
  2. Canceling a SMS messages
  3. Getting a SMS message information
  4. Searching SMS messages

Messages - Searching SMS messages

You can search for messages using our SMS message API
Below is some sample requests and response. For complete API documentation on searching sms messages please refer to the Swagger (Open API Specification) documentations here: SMS Gateway API Definition


API Request

Request Endpoint
Endpoint: https://smsgateway.me/api/v4/message/search
Method: POST
Request Parameters
Name Location Required Description
Authorization header true Your API token found on the settings page
search body true The search query

Request Example

Valid Fields: id, device_id, phone_number, message, status

{
  "filters": [
    [
      {
        "field": "phone_number",
        "operator": "=",
        "value": "07791064781"
      },
      {
        "field": "message",
        "operator": "=",
        "value": "hello world"
      }
    ],
    [
      {
        "field": "status",
        "operator": "=",
        "value": "pending"
      }
    ]
  ],
  "order_by": [
    {
      "field": "created_at",
      "direction": "desc"
    }
  ],
  "limit": 2,
  "offset": 0
}

Response Examples

Successful Response

A search result object consisting of results and a total result count

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\MessageApi;

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

/**
 *   Message Search
 *
 *   Valid Fields: id, device_id, phone_number, message, status
 *
 *   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.
 */
$messages = $messageClient->searchMessages(
    [
        'filters' => [
            [
                [
                    'field' => 'device_id',
                    'operator' => '=',
                    'value' => '1'
                ],
                [
                    'field' => 'status',
                    'operator' => '=',
                    'value' => 'sent'
                ]
            ],
            [
                [
                    'field' => 'status',
                    'operator' => '=',
                    'value' => 'failed'
                ]
            ]
        ],
        'order_by' => [
            [
                'field' => 'status',
                'direction' => 'DESC'
            ],
            [
                'field' => 'device_id',
                'direction' => 'ASC'
            ]
        ],
        'limit'   => 5,
        'offset'  => 5
    ]
);
print_r($messages);

Successful Response

SMSGatewayMe\Client\Model\MessageSearchResult Object
(
    [count:protected] => 59
    [results:protected] => Array
        (
            [0] => SMSGatewayMe\Client\Model\Message Object
                (
                    [id:protected] => 63384039
                    [deviceId:protected] => 89747
                    [message:protected] => test m 2
                    [status:protected] => sent
                    [log:protected] => Array
                        (
                            [0] => SMSGatewayMe\Client\Model\MessageLog Object
                                (
                                    [status:protected] => failed
                                    [occurredAt:protected] => DateTime Object
                                        (
                                            [date] => 2018-05-13 21:14:49.000000
                                            [timezone_type] => 1
                                            [timezone] => +00:00
                                        )
                                )
                        )
                    [createdAt:protected] => DateTime Object
                        (
                            [date] => 2018-05-13 21:14:49.000000
                            [timezone_type] => 1
                            [timezone] => +00:00
                        )
                    [updatedAt:protected] =>
                )
        )
)