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"}}'


using System.Net;

...

WebClient client = new WebClient()
client.Headers.Add("Content-Type", "application/json");
client.Headers.Add("apikey", YOUR_API_KEY);
client.Headers.Add("workspace", YOUR_WORKSPACE_ID);

string body = "{\"destination\":\"https://www.youtube.com/channel/UCHK4HD0ltu1-I212icLPt3g\",\"domain\":{\"fullName\":\"rebrand.ly\"}}";

try
{
    string response = client.UploadString("https://api.rebrandly.com/v1/links", "POST", body);
    //call is successfull, you can read the response 
}
catch (Exception ex)
{
    //request failed
}
{% 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 %}

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.