Rebrandly for Developers

Use our API to create, track and share custom short links that incorporate your brand domain name.

Get Started

API for custom short URLs - Code snippet

Copy-and-paste in your application/script to create a custom short URL:

let linkRequest = {
  destination: "https://www.youtube.com/channel/UCHK4HD0ltu1-I212icLPt3g",
  domain: { fullName: "rebrand.ly" }
  //, slashtag: "A_NEW_SLASHTAG"
  //, title: "Rebrandly YouTube channel"
}

let requestHeaders = {
  "Content-Type": "application/json",
  "apikey": "YOUR_API_KEY",
  "workspace": "YOUR_WORKSPACE_ID"
}

$.ajax({
  url: "https://api.rebrandly.com/v1/links",
  type: "post",
  data: JSON.stringify(linkRequest),
  headers: requestHeaders,
  dataType: "json",
  success: (link) => {
    console.log(`Long URL was ${link.destination}, short URL is ${link.shortUrl}`);
  }
});
let request = require("request");
let linkRequest = {
  destination: "https://www.youtube.com/channel/UCHK4HD0ltu1-I212icLPt3g",
  domain: { fullName: "rebrand.ly" }
  //, slashtag: "A_NEW_SLASHTAG"
  //, title: "Rebrandly YouTube channel"
}

let requestHeaders = {
  "Content-Type": "application/json",
  "apikey": "YOUR_API_KEY",
  "workspace": "YOUR_WORKSPACE_ID"
}

request({
    uri: "https://api.rebrandly.com/v1/links",
    method: "POST",
    body: JSON.stringify(linkRequest),
    headers: requestHeaders
}, (err, response, body) => {
  let link = JSON.parse(body);
  console.log(`Long URL was ${link.destination}, short URL is ${link.shortUrl}`);
}
<?php
  [...]
  $domain_data["fullName"] = "rebrand.ly";
  $post_data["destination"] = "https://www.youtube.com/channel/UCHK4HD0ltu1-I212icLPt3g";
  $post_data["domain"] = $domain_data;
//$post_data["slashtag"] = "A_NEW_SLASHTAG";
//$post_data["title"] = "Rebrandly YouTube channel";
  $ch = curl_init("https://api.rebrandly.com/v1/links");
  curl_setopt($ch, CURLOPT_HTTPHEADER, array(
      "apikey: YOUR_API_KEY",
      "Content-Type: application/json",
      "workspace: YOUR_WORKSPACE_ID"
  ));
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post_data));
  $result = curl_exec($ch);
  curl_close($ch);
  $response = json_decode($result, true);
  print "Short URL is: " . $response["shortUrl"];
?>
import requests
import json

linkRequest = {
  "destination": "https://www.youtube.com/channel/UCHK4HD0ltu1-I212icLPt3g"
  , "domain": { "fullName": "rebrand.ly" }
# , "slashtag": "A_NEW_SLASHTAG"
# , "title": "Rebrandly YouTube channel"
}

requestHeaders = {
  "Content-type": "application/json",
  "apikey": "YOUR_API_KEY",
  "workspace": "YOUR_WORKSPACE_ID"
}

r = requests.post("https://api.rebrandly.com/v1/links", 
	data = json.dumps(linkRequest),
	headers=requestHeaders)

if (r.status_code == requests.codes.ok):
	link = r.json()
	print("Long URL was %s, short URL is %s" % (link["destination"], link["shortUrl"]))
POST https://api.rebrandly.com/v1/links
Content-Type: application/json
apikey: YOUR_API_KEY
workspace: YOUR_WORKSPACE_ID

{"destination": "https://www.youtube.com/channel/UCHK4HD0ltu1-I212icLPt3g", "domain": { "fullName": "rebrand.ly"}}
curl https://api.rebrandly.com/v1/links \
  -H 'Content-Type: application/json' \
  -H 'apikey: YOUR_API_KEY' \
  -H 'workspace: YOUR_WORKSPACE_ID' \
  -d '{"destination": "https://www.youtube.com/channel/UCHK4HD0ltu1-I212icLPt3g","domain":{"fullName":"rebrand.ly"}}'

//Install-Package Newtonsoft.Json
using Newtonsoft.Json;
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
	
var payload = new
{
    destination = "https://www.youtube.com/channel/UCHK4HD0ltu1-I212icLPt3g",
    domain = new
    {
        fullName = "rebrand.ly"
    }
    //, slashtag = "A_NEW_SLASHTAG"
    //, title = "Rebrandly YouTube channel"
};

using (var httpClient = new HttpClient { BaseAddress = new Uri("https://api.rebrandly.com") })
{
    httpClient.DefaultRequestHeaders.Add("apikey", "YOUR_API_KEY");
    httpClient.DefaultRequestHeaders.Add("workspace", "YOUR_WORKSPACE_ID");

    var body = new StringContent(
        JsonConvert.SerializeObject(payload), UnicodeEncoding.UTF8, "application/json");

    using (var response = await httpClient.PostAsync("/v1/links", body))
    {
        response.EnsureSuccessStatusCode();

        var link = JsonConvert.DeserializeObject<dynamic>(
            await response.Content.ReadAsStringAsync());

        Console.WriteLine($"Long URL was {payload.destination}, short URL is {link.shortUrl}");
    }
}
{% assign rebrandly_api_key = "YOUR_API_KEY" %}
{% assign rebrandly_workspace_id = "YOUR_WORKSPACE_ID" %}
{% assign branded_domain = "rebrand.ly" %}
{% assign search_example = "youtube" }

{% capture destination %}
https://www.google.com/search?q={{search_example | url_encode}}
{% endcapture %}

{% connected_content https://api.rebrandly.com/v1/links/new?apikey={{rebrandly_api_key}}&domain[fullName]={{branded_domain}}&workspace[id]={{rebrandly_workspace_id}}&destination={{destination | url_encode}} :save response %}

{% if response.__http_status_code__ == 200 %}
    {% assign short_url = response.shortUrl %}
{% else %}
    {% abort_message() %}
{% endif %}
set @rbAPIKey = "YOUR_API_KEY"
set @rbWorkspace = "YOUR_WORKSPACE_ID"
set @rbDomain = "YOUR_DOMAIN_NAME"

var @shortUrl, @rebrandlyUrl, @link
set @url = URLEncode("https://google.com")
set @rbAPIHost = "api.rebrandly.com"
set @rbAPIEndpoint = Concat("https://", @rbAPIHost, "/v1/links/new")
set @rbAPIParameters = Concat("apikey=", @rbAPIKey, "&workspace=", @rbWorkspace, "&domain[fullName]=", @rbDomain, "&destination=“, @url)
set @rbAPICall = Concat(@rbAPIEndpoint, "?", @rbAPIParameters)
set @rbResponseJSON = HTTPGet(rbAPICall)
<script runat="server">
    var rbResponse = eval("(" + Variable.GetValue("@rbResponseJSON") + ")");
    var shortUrl = "https://" + rbResponse.shortUrl
</script>

API for custom short URLs - Code snippet


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.