Developers

Integrate SMS Links into your existing messaging workflow with a straightforward API for authentication, campaign setup, link generation, and reporting.

Step 1

Authenticate

Start by authenticating with the SMS Links API. The login request returns an access token that is required for campaign, link, and analytics endpoints.

Use the account credentials created during signup. Store returned tokens securely and include the access token as a Bearer token in subsequent API requests.

View authentication API reference

                  
<?php
// Authentication payload
$auth = json_encode(array(
  'email'      => '[email protected]',
  'password'    => 'vgPnpNkuvT',
));

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => array(
      'Content-Type: application/json'
  ),
  CURLOPT_URL => 'http://localhost:3000/auth/login',
  CURLOPT_POSTFIELDS => $auth,
));

$auth = json_decode(curl_exec($curl));
                   
                 

A successful authentication request returns the following token payload:

                  
// Example response
// var_dump($auth);
// object(stdClass)#2 (4) {
//   ["access_token"]  => string(305) "eysInR5cCI6Ikp....."
//   ["expires_in"]    => int(3600)
//   ["refresh_token"] => string(44) "kavvzVYXz_uSfe5X...."
//   ["token_type"]    => string(6) "Bearer"
// }
                   
                 

Step 2

Create a Campaign

Once authenticated, create a campaign to group the shortened links for a specific message, promotion, or workflow. Campaigns provide the reporting container used to review performance across the links generated for that activity.

View create campaign API reference

                  
// Create a campaign.
$url = $baseUrl . 'api/v1/campaign';

// Include the access token returned during authentication.
$headers = [
  'Content-Type: application/json',
  'Authorization: Bearer ' . $auth->access_token
];

// Define the campaign payload.
// Use this value when no expiry is required: '0000-00-00T00:00:00.000Z'
$campaignData = [
  'name' => 'Summer Sale 2026',
  'description' => 'Q3 marketing campaign for summer promotions',
  'expiry' => '2026-08-19T16:01:27.657Z'
];

curl_setopt_array($ch, [
  CURLOPT_URL => $url,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => json_encode($campaignData),
  CURLOPT_HTTPHEADER => $headers,
]);

$campaign = json_decode(curl_exec($ch));
                   
                 

A successful request creates the campaign and returns its details.

The key field is the campaign ID. Use this value when generating links, retrieving campaign analytics, or listing the links attached to the campaign.

After the campaign is created, you can generate shortened links for distribution.

                  
var_dump($campaign);
object(stdClass)#3 (8) {
  ["id"]=>
  string(8) "0c232e6f"
  ["tenant_id"]=>
  string(36) "400b379b-7ca7-4f8b-9d7b-5b6e283ee139"
  ["name"]=>
  string(16) "Summer Sale 2026"
  ["description"]=>
  string(43) "Q3 marketing campaign for summer promotions"
  ["expiry"]=>
  string(24) "2026-08-19T16:01:27.657Z"
  ["created_at"]=>
  string(27) "2026-02-28T09:48:12.481955Z"
  ["updated_at"]=>
  string(27) "2026-02-28T09:48:12.481955Z"
  ["utm"]=>
  object(stdClass)#4 (9) {
    ["id"]=>
    string(0) ""
    ["source"]=>
    string(0) ""
    ["medium"]=>
    string(0) ""
    ["campaign"]=>
    string(0) ""
    ["source_platform"]=>
    string(0) ""
    ["term"]=>
    string(0) ""
    ["content"]=>
    string(0) ""
    ["creative_format"]=>
    string(0) ""
    ["marketing_tactic"]=>
    string(0) ""
  }
}
                   
                 

Step 3

Create Shortened Links

Generate shortened links against the campaign ID returned in the previous step. Each generated URL redirects to your destination while recording engagement against the campaign.

View create links API reference

                  
$url = $baseUrl . 'api/v1/campaign/' . $campaign->id . '/links';    // Replace $campaign->id with your campaign ID

// Minimum payload required to generate links.
$linkData = [
  "link"   => "https://example.com/summer-sale",    // Destination URL
  "count"  => 3,                                    // Number of links to generate
  "expiry" => "2027-02-19T14:33:52.815Z"            // Link expiry. Use "0000-00-00T00:00:00.000Z" when no expiry is required.
];

curl_setopt_array($ch, [
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => json_encode($linkData),
  CURLOPT_HTTPHEADER => $headers
]);

$links = json_decode(curl_exec($ch));
                   
                 

The response includes the requested number of shortened links, including their destination URL, tracking hash, expiry, and short URL.

Use these short URLs in your SMS provider, CRM, automation platform, or internal messaging system. If you need implementation support, our team can help with integration planning and API usage.

Once the links are in use, campaign analytics can be retrieved from the API.

                  
object(stdClass)#5 (2) {
  ["count"]=>
  int(3)
  ["links"]=>
  array(3) {
    [0]=>
    object(stdClass)#6 (11) {
      ["id"]=>
      string(36) "45a1f80c-aea9-469a-bd65-6a68a8841482"
      ["tenant_id"]=>
      string(36) "400b379b-7ca7-4f8b-9d7b-5b6e283ee139"
      ["campaign_id"]=>
      string(8) "0c232e6f"
      ["tenant_user_id"]=>
      string(36) "10240ac5-aa60-4f63-9396-918b258cb2f8"
      ["hash"]=>
      string(8) "QcFNUMLm"
      ["link"]=>
      string(31) "https://example.com/summer-sale"
      ["unique_click_count"]=>
      int(0)
      ["expiry"]=>
      string(24) "2027-02-19T14:33:52.815Z"
      ["created_at"]=>
      string(27) "2026-02-28T09:48:12.491204Z"
      ["updated_at"]=>
      string(27) "2026-02-28T09:48:12.491204Z"
      ["short_url"]=>
      string(31) "https://localhost:3001/QcFNUMLm"
    }
    [1]=>
    object(stdClass)#7 (11) {
      ["id"]=>
      string(36) "63625f66-1990-471d-b910-13316756e7ce"
      ["tenant_id"]=>
      string(36) "400b379b-7ca7-4f8b-9d7b-5b6e283ee139"
      ["campaign_id"]=>
      string(8) "0c232e6f"
      ["tenant_user_id"]=>
      string(36) "10240ac5-aa60-4f63-9396-918b258cb2f8"
      ["hash"]=>
      string(8) "mzmuStCT"
      ["link"]=>
      string(31) "https://example.com/summer-sale"
      ["unique_click_count"]=>
      int(0)
      ["expiry"]=>
      string(24) "2027-02-19T14:33:52.815Z"
      ["created_at"]=>
      string(27) "2026-02-28T09:48:12.493779Z"
      ["updated_at"]=>
      string(27) "2026-02-28T09:48:12.493779Z"
      ["short_url"]=>
      string(31) "https://localhost:3001/mzmuStCT"
    }
    [2]=>
    object(stdClass)#8 (11) {
      ["id"]=>
      string(36) "bbf7b85e-06a4-477d-a0dc-e0bb21705436"
      ["tenant_id"]=>
      string(36) "400b379b-7ca7-4f8b-9d7b-5b6e283ee139"
      ["campaign_id"]=>
      string(8) "0c232e6f"
      ["tenant_user_id"]=>
      string(36) "10240ac5-aa60-4f63-9396-918b258cb2f8"
      ["hash"]=>
      string(8) "dQjHKIMc"
      ["link"]=>
      string(31) "https://example.com/summer-sale"
      ["unique_click_count"]=>
      int(0)
      ["expiry"]=>
      string(24) "2027-02-19T14:33:52.815Z"
      ["created_at"]=>
      string(27) "2026-02-28T09:48:12.496403Z"
      ["updated_at"]=>
      string(27) "2026-02-28T09:48:12.496403Z"
      ["short_url"]=>
      string(31) "https://localhost:3001/dQjHKIMc"
    }
  }
                   
                 

Step 4

Get Campaign Analytics

Use the campaign analytics endpoint to monitor performance after your shortened links have been distributed. Provide the campaign ID to retrieve clicks, unique engagement, and related reporting data.

View campaign analytics API reference

                  
$url = $baseUrl . 'api/v1/campaign/' . $campaign->id . '/analytics';    // Replace $campaign->id with your campaign ID

curl_setopt_array($ch, [
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => $headers
]);

$analytics = json_decode(curl_exec($ch));
                   
                 

The analytics response provides a campaign-level performance summary.

                  
object(stdClass)#11 (7) {
  ["total_clicks"]=>
  int(4)
  ["unique_clicks"]=>
  int(3)
  ["unique_user_agents"]=>
  int(3)
  ["clicked_links"]=>
  int()
  ["total_links"]=>
  int(5)
  ["engagement_rate"]=>
  int(0)
  ["country_breakdown"]=>
  array(0) {
  }
}
                   
                 

This summary can be used for dashboards, reports, or internal attribution workflows.

For more detailed analysis, you can also retrieve the individual links associated with a campaign.

View campaign links API reference

                  
$url = $baseUrl . 'api/v1/campaign/' . $campaign->id . '/links'; // Replace $campaign->id with your campaign ID

curl_setopt_array($ch, [
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => $headers
]);

$links = json_decode(curl_exec($ch));
                   
                 

The api/v1/campaign/CAMPAIGN_ID/links endpoint returns a paginated list of campaign links and their metadata.

                  
object(stdClass)#13 (2) {
  ["links"]=>
  array(3) {
    [0]=>
    object(stdClass)#10 (11) {
      ["id"]=>
      string(36) "59d84b26-47a5-4ec0-b854-c7e801c94887"
      ["tenant_id"]=>
      string(36) "400b379b-7ca7-4f8b-9d7b-5b6e283ee139"
      ["campaign_id"]=>
      string(8) "b22db3c4"
      ["tenant_user_id"]=>
      string(0) ""
      ["hash"]=>
      string(8) "zPkZuYZT"
      ["link"]=>
      string(31) "https://example.com/summer-sale"
      ["unique_click_count"]=>
      int(0)
      ["expiry"]=>
      string(24) "2027-02-19T14:33:52.815Z"
      ["created_at"]=>
      string(27) "2026-03-01T20:08:16.394765Z"
      ["updated_at"]=>
      string(27) "2026-03-01T20:08:16.394765Z"
      ["short_url"]=>
      string(31) "https://localhost:3001/zPkZuYZT"
    }
    [1]=>
    object(stdClass)#11 (11) {
      ["id"]=>
      string(36) "531765e1-9a50-48f9-81cb-6c93244ef830"
      ["tenant_id"]=>
      string(36) "400b379b-7ca7-4f8b-9d7b-5b6e283ee139"
      ["campaign_id"]=>
      string(8) "b22db3c4"
      ["tenant_user_id"]=>
      string(0) ""
      ["hash"]=>
      string(8) "gzbHrBer"
      ["link"]=>
      string(31) "https://example.com/summer-sale"
      ["unique_click_count"]=>
      int(0)
      ["expiry"]=>
      string(24) "2027-02-19T14:33:52.815Z"
      ["created_at"]=>
      string(26) "2026-03-01T20:08:16.39231Z"
      ["updated_at"]=>
      string(26) "2026-03-01T20:08:16.39231Z"
      ["short_url"]=>
      string(31) "https://localhost:3001/gzbHrBer"
    }
    [2]=>
    object(stdClass)#12 (11) {
      ["id"]=>
      string(36) "91c69632-cafc-4a44-83e9-a9ce122ce2f9"
      ["tenant_id"]=>
      string(36) "400b379b-7ca7-4f8b-9d7b-5b6e283ee139"
      ["campaign_id"]=>
      string(8) "b22db3c4"
      ["tenant_user_id"]=>
      string(0) ""
      ["hash"]=>
      string(8) "pTfnmWqV"
      ["link"]=>
      string(31) "https://example.com/summer-sale"
      ["unique_click_count"]=>
      int(0)
      ["expiry"]=>
      string(24) "2027-02-19T14:33:52.815Z"
      ["created_at"]=>
      string(27) "2026-03-01T20:08:16.390288Z"
      ["updated_at"]=>
      string(27) "2026-03-01T20:08:16.390288Z"
      ["short_url"]=>
      string(31) "https://localhost:3001/pTfnmWqV"
    }
  }
  ["pagination"]=>
  object(stdClass)#14 (6) {
    ["has_next"]=>
    bool(false)
    ["has_prev"]=>
    bool(false)
    ["page"]=>
    int(1)
    ["page_size"]=>
    int(1000)
    ["total_count"]=>
    int(3)
    ["total_pages"]=>
    int(1)
  }
}
                   
                 
SMSLinks

© 2026 SMS Links Ltd. All rights reserved.