API documentation

Short.bg API

The API lets registered users create short links through external applications, integrations, and browser extensions. Requests require an API key from your account.

Sign up Get API key

Authentication

Send your API key as a Bearer token in the HTTP header Authorization. Generate the key from your dashboard. You can replace it at any time.

POST http://short.bg/api/ext/verify

Checks whether the API key is valid.

POST http://short.bg/api/ext/shorten

Creates a short link for the user who owns the key.

Link creation parameters

Field Type Description
original_url required A public HTTP/HTTPS URL of up to 2048 characters.
custom_slug optional Custom code: 3-10 characters, Latin letters and numbers only.
expires_at optional A future expiration date and time.
password optional A password for a protected link, at least 6 characters long.

Success response

{
  "short_url": "https://short.bg/AbC1",
  "slug": "AbC1",
  "qr_code_url": "https://api.qrserver.com/v1/create-qr-code/?size=180x180&data=..."
}

PHP example

$token = 'YOUR_API_KEY';

$response = Http::withToken($token)
    ->acceptJson()
    ->post('http://short.bg/api/ext/shorten', [
        'original_url' => 'https://example.com/very/long/link',
        'custom_slug' => 'promo2026',
    ]);

echo $response->json('short_url');

JavaScript example

const token = 'YOUR_API_KEY';

const response = await fetch('http://short.bg/api/ext/shorten', {
  method: 'POST',
  headers: {
    Accept: 'application/json',
    Authorization: `Bearer ${token}`
  },
  body: new URLSearchParams({
    original_url: 'https://example.com/very/long/link',
    custom_slug: 'promo2026'
  })
});

const data = await response.json();
console.log(data.short_url);

Python example

import requests

token = 'YOUR_API_KEY'

response = requests.post(
    'http://short.bg/api/ext/shorten',
    headers={
        'Accept': 'application/json',
        'Authorization': f'Bearer {token}',
    },
    data={
        'original_url': 'https://example.com/very/long/link',
        'custom_slug': 'promo2026',
    },
    timeout=10,
)

response.raise_for_status()
print(response.json()['short_url'])

Errors

For an invalid API key, the API returns 401. For invalid data, it returns 422 with an errors object containing the messages for each field.