API

1.Introduction

The Textdelivery API allows for interactions with the Textdelivery Platform.

The API endpoint is located here: https://v2.textdeliver.com/api/v1

All API requests should use the above URL as their base url.
All API requests must be made over HTTPS. Calls made over plain HTTP will fail. API requests without authentication will also fail.

2.Contacts

2.1.Get all contact lists

Example Request

<?php
//Set up API path and method
$base_url = "https://v2.textdeliver.com/api/v1/";
$route = "contact-lists";
$url = $base_url . $route;
$post = false;

//Create request data string
$data = http_build_query([
    'access_token' => '3A0GTRFIJHYE',
]);

//Execute cURL request
$ch = curl_init();
if ($post) {
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
} else {
    $url = $url . "?" . $data;
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$output = curl_exec($ch);
curl_close($ch);

//Output Response
echo json_decode($output);

Example Response

[
  {
    "id": 8,
    "name": "Test list",
    "company_name": "",
    "welcome_sms_text": "You have been successfully subscribed to the list. Msg&data rates may apply.",
    "help_sms_text": "",
    "created_at": "2017-01-01 08:00:00"
  }
]

This GET request returns all contact lists

ARGUMENTS

access_token

The Textdeliver API Key

2.2.Get contacts from contact list

Example Request

<?php
//Set up API path and method
$base_url = "https://v2.textdeliver.com/api/v1/";
$route = "contact-lists/{CONTACT LIST ID}/contacts";
$url = $base_url . $route;
$post = false;

//Create request data string
$data = http_build_query([
    'access_token' => '3A0GTRFIJHYE',
]);

//Execute cURL request
$ch = curl_init();
if ($post) {
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
} else {
    $url = $url . "?" . $data;
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$output = curl_exec($ch);
curl_close($ch);

//Output Response
echo json_decode($output);

Example Response

[
  {
    "first_name": "Mark",
    "last_name": "Thompson",
    "number": "+19191234567",
    "email": "markthompson15@gmail.com"
  }
]

This GET request returns contact

ARGUMENTS

access_token
The Textdeliver API Key
full_info
Value 1 or 0
If choosed will return all contact object
numbers
Value 1 or 0
If choosed will return only phone numbers

 

2.3.Create contacts to contact list

Example Request

<?php
//Set up API path and method
$base_url = "https://v2.textdeliver.com/api/v1/";
$route = "contact-lists/{CONTACT LIST ID}/contacts";
$url = $base_url . $route;
$post = true;

//Create request data string
$data = http_build_query ([
    "access_token" => "3A0GTRFIJHYE",
    "data"         => [
        [
            "first_name" => "Mark",
            "last_name"  => "Thompson",
            "number"     => "+19191234567",
            "email"      => "markthompson15@gmail.com",
            "timezone"   => "America/Los_Angeles",
            "country"    => "United States",
            "state"      => "California",
            "city"       => "Los Angeles",
            "address_1"  => "Beverly Hills",
            "address_2"  => "",
            "zip"        => "90211",
            "avatar"     => "https://pbs.twimg.com/profile_images/686990896555012096/_WdDlRwG_400x400.jpg",

        ],
    ],
]);

//Execute cURL request
$ch = curl_init();
if ($post) {
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
} else {
    $url = $url . "?" . $data;
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$output = curl_exec($ch);
curl_close($ch);

//Output Response
echo json_decode($output);

Example Response

{
    "status":200,
    "message":"Contacts are successfully added"
}

This POST request creates new contacts

ARGUMENTS

access_token
The Textdeliver API Key
data
Array of contact objects

 

2.4.Remove contacts from contact list

Example Request

<?php
//Set up API path and method
$base_url = "https://v2.textdeliver.com/api/v1/";
$route = "contacts/remove";
$url = $base_url . $route;
$post = true;

//Create request data string
$data = http_build_query ([
    "access_token" => "3A0GTRFIJHYE",
    "contact_list_id" => 123,
    "contacts" => [
        '+19191234567'
    ],
]);

//Execute cURL request
$ch = curl_init();
if ($post) {
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
} else {
    $url = $url . "?" . $data;
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$output = curl_exec($ch);
curl_close($ch);

//Output Response
echo json_decode($output);

Example Response

{
    "status":200,
    "message":"Contacts are successfully deleted"
}

This POST request remove contacts

ARGUMENTS

access_token
The Textdeliver API Key
contact_list_id
Integer
contacts
Array of phone numbers.