Skip to content
Developers

Shorten Magic API

Create, list, edit and delete your short links from your own code. Every request uses a personal API key from your dashboard.

Authentication

Create a key under Dashboard → API keys and send it in the Authorization header. Keys start with sb_live_. Keep them secret: anyone with your key can manage your links. Creating and editing links requires an active plan.

HTTP
Authorization: Bearer sb_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

If your server strips the Authorization header, send the key as X-Api-Key: sb_live_… instead.

Base URL:

Base URL
https://www.shortenmagic.com/api/v1

Errors

Every response is JSON with an ok field. Errors look like {"ok": false, "error": "…"}.

CodeMeaning
400Invalid URL, alias or domain.
401Missing or invalid API key.
402No active plan, or your plan's link limit is reached.
404The link doesn't exist or isn't yours.
409The custom alias is already taken.

Account

GET/account

Returns your plan status, usage in the last 30 days and the domains you can use.

Create a link

POST/links
FieldTypeDescription
urlstringRequired. The destination URL.
aliasstringOptional custom ending, 3–30 characters: letters, numbers, - and _.
domainstringOptional. One of shortenbuster.com, shortenmagic.com. Defaults to the domain you call.
cURL
curl -X POST https://www.shortenmagic.com/api/v1/links \
  -H "Authorization: Bearer $SB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://examplestore.com/campaign","alias":"fallsale"}'
Response · 201
{
  "ok": true,
  "link": {
    "code": "fallsale",
    "short_url": "https://www.shortenmagic.com/fallsale",
    "url": "https://examplestore.com/campaign",
    "domain": "shortenmagic.com",
    "clicks": 0,
    "created_at": "2026-10-19T12:00:00+00:00",
    "last_click_at": null
  }
}

List links

GET/links?page=1&per_page=50

Newest first. per_page can be up to 100. Keep requesting until meta.next_page is null.

Get a link

GET/links/{code}

Returns one of your links with its click count.

Update a link

PATCH/links/{code}

Send {"url": "…"} to change where the link points. The short link itself stays the same.

cURL
curl -X PATCH https://www.shortenmagic.com/api/v1/links/fallsale \
  -H "Authorization: Bearer $SB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://examplestore.com/winter-campaign"}'

Delete a link

DELETE/links/{code}

The short link stops working immediately.

PHP

PHP
$ch = curl_init('https://www.shortenmagic.com/api/v1/links');
curl_setopt_array($ch, [
    CURLOPT_POST           => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER     => [
        'Authorization: Bearer ' . getenv('SB_API_KEY'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS     => json_encode(['url' => 'https://examplestore.com/campaign']),
]);
$res = json_decode(curl_exec($ch), true);
echo $res['link']['short_url'] ?? $res['error'];

JavaScript (server side)

JavaScript
const res = await fetch('https://www.shortenmagic.com/api/v1/links', {
  method: 'POST',
  headers: { 'Authorization': `Bearer ${process.env.SB_API_KEY}`, 'Content-Type': 'application/json' },
  body: JSON.stringify({ url: 'https://examplestore.com/campaign' })
});
const data = await res.json();
console.log(data.link.short_url);

Call the API from your server, not from a browser page, so your key stays private.