Documentation - Messages


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

Messages - Canceling a SMS messages

Sometimes you may want to cancel messages you've requested to be sent. You can cancel outgoing messages using our SMS Message API
Below is some sample requests and response. For complete API documentation on canceling a 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/cancel
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 SMS messages the API should send

Request Example

ID list of messages that you wish to cancel

[
  {
    "id": 59484209
  },
  {
    "id": 59484210
  },
  {
    "id": 59484211
  }
]

Response Examples

Successful Response

A list of messages that has been cancled

Response Code: 200

[
  {
    "id": 59484209,
    "device_id": 1,
    "phone_number": "07791064781",
    "message": "Hello World",
    "status": "canceled",
    "log": [
      {
        "status": "pending",
        "occurred_at": "2018-05-05T16:51:22+00:00"
      },
      {
        "status": "canceled",
        "occurred_at": "2018-05-05T16:52:33+00:00"
      }
    ],
    "created_at": "2018-05-05T16:51:22+00:00"
  },
  {
    "id": 59484210,
    "device_id": 2,
    "phone_number": "07791064782",
    "message": "Hello World",
    "status": "canceled",
    "log": [
      {
        "status": "pending",
        "occurred_at": "2018-05-05T16:51:22+00:00"
      },
      {
        "status": "canceled",
        "occurred_at": "2018-05-05T16:52:33+00:00"
      }
    ],
    "created_at": "2018-05-05T16:51:22+00:00"
  },
  {
    "id": 59484211,
    "device_id": 2,
    "phone_number": "07791064782",
    "message": "Hello World",
    "status": "canceled",
    "log": [
      {
        "status": "pending",
        "occurred_at": "2018-05-05T16:51:22+00:00"
      },
      {
        "status": "canceled",
        "occurred_at": "2018-05-05T16:52:33+00:00"
      }
    ],
    "created_at": "2018-05-05T16:51:22+00:00"
  }
]

Validation Error

When a validation exception occurs

Response Code: 400

{
  "status": "fail",
  "message": "failed validation",
  "data": [
    {
      "key": "id",
      "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\MessageApi;
use SMSGatewayMe\Client\Model\CancelMessageRequest;

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

// Cancel SMS Message
$cancelMessageRequest1 = new CancelMessageRequest([
    'id' => 63402677
]);
$cancelMessageRequest2 = new CancelMessageRequest([
    'id' => 63402678
]);
$canceledMessaged = $messageClient->cancelMessages([
    $cancelMessageRequest1
    $cancelMessageRequest2
]);
print_r($canceledMessaged);

Successful Response

Array
(
    [0] => SMSGatewayMe\Client\Model\Message Object
        (
            [id:protected] => 63402677
            [deviceId:protected] => 90295
            [message:protected] => test1
            [status:protected] => canceled
            [log:protected] => Array
                (
                    [0] => SMSGatewayMe\Client\Model\MessageLog Object
                    (
                        [status:protected] => pending
                        [occurredAt:protected] => DateTime Object
                            (
                                [date] => 2018-05-14 21:13:07.000000
                                [timezone_type] => 1
                                [timezone] => +00:00
                            )

                    )
                    [1] => SMSGatewayMe\Client\Model\MessageLog Object
                    (
                        [status:protected] => canceled
                        [occurredAt:protected] => DateTime Object
                            (
                                [date] => 2018-05-14 21:15:07.000000
                                [timezone_type] => 1
                                [timezone] => +00:00
                            )

                    )
                )

            [createdAt:protected] => DateTime Object
                (
                    [date] => 2018-05-14 21:13:07.000000
                    [timezone_type] => 1
                    [timezone] => +00:00
                )

            [updatedAt:protected] => DateTime Object
                (
                    [date] => 2018-05-14 21:15:07.000000
                    [timezone_type] => 1
                    [timezone] => +00:00
                )
        )

    [1] => SMSGatewayMe\Client\Model\Message Object
        (
            [id:protected] => 63402678
            [deviceId:protected] => 90295
            [message:protected] => test2
            [status:protected] => canceled
            [log:protected] => Array
                (
                    [0] => SMSGatewayMe\Client\Model\MessageLog Object
                    (
                        [status:protected] => pending
                        [occurredAt:protected] => DateTime Object
                            (
                                [date] => 2018-05-14 21:13:07.000000
                                [timezone_type] => 1
                                [timezone] => +00:00
                            )

                    )
                    [1] => SMSGatewayMe\Client\Model\MessageLog Object
                    (
                        [status:protected] => canceled
                        [occurredAt:protected] => DateTime Object
                            (
                                [date] => 2018-05-14 21:15:07.000000
                                [timezone_type] => 1
                                [timezone] => +00:00
                            )

                    )
                )

            [createdAt:protected] => DateTime Object
                (
                    [date] => 2018-05-14 21:13:07.000000
                    [timezone_type] => 1
                    [timezone] => +00:00
                )

            [updatedAt:protected] => DateTime Object
                (
                    [date] => 2018-05-14 21:15:07.000000
                    [timezone_type] => 1
                    [timezone] => +00:00
                )
        )

)