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 - Updating an existing contact

You can override a current contacts information with new ones using the contact API
Below is some sample requests and response. For complete API documentation on updating an existing 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/{id}
Method: PUT
Request Parameters
Name Location Required Description
Authorization header true Your API token found on the settings page
id path true The id of the contact the API should update
contact body true JSON payload with the information of contacts the API should create

Request Example

{
  "name": "John Doe",
  "phone_numbers": [
    "+447791064783",
    "+447791064784",
    "+447791064812"
  ]
}

Response Examples

Successful Response

Response Code: 200

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

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

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

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

// Update Contact
$updateContactRequest = new UpdateContactRequest(
    [
        'name'         => 'Johnathon Doe',
        'phoneNumbers' => [
            '07791064785',
            '07791064786'
        ]
    ]
);
$contact = $contactClient->updateContact(12586272, $updateContactRequest);
print_r($contact);

Successful Response

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