Zagl logó

API Documentation

Shorten links straight from your code. One endpoint, one bearer token.

Endpoint

POSThttps://preprod.za.gl/api/shorten
RESTJSON bodyBearer auth

Authentication

Pass your API token in the Authorization header as a bearer token. Grab it from your account dashboard after you create your first link.

Header
Authorization: Bearer YOUR_API_TOKEN

No token yet? You can call the endpoint without one. Za.gl creates an anonymous account on the fly and returns a fresh token in data.newAuthToken. Save it to manage your links later.

Request body

originalUrlrequired

string

The long URL to shorten. If you omit the protocol, https:// is added for you.

customAlias

string

Your own ending, e.g. za.gl/my-link. Must be unique, or you get a 409.

password

string

Protect the link so visitors need a password to continue.

expiresAt

string (ISO date)

When the link should stop working. Must be in the future.

expiresInMinutes / expiresInHours / expiresInDays

number

Alternative to expiresAt, expire after a relative amount of time.

waitTimer

number (0-300)

Seconds the visitor waits on the preview page before the redirect.

customGtmId

string

Your own Google Tag Manager ID (GTM-XXXXXXX) fired on the preview page.

title / description

string

Optional metadata stored with the link.

generateQR

boolean

Also return a QR code for the short URL.

Example request

POSTcURL
curl -X POST https://preprod.za.gl/api/shorten \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "originalUrl": "https://example.com/a-very-long-link",
    "customAlias": "my-link",
    "password": "optional-secret",
    "expiresAt": "2026-12-31T23:59:59.000Z",
    "waitTimer": 5
  }'

Example response

A successful call returns 200 OK with the short URL in data.shortUrl.

200 OKJSON
{
  "success": true,
  "message": "URL shortened successfully",
  "data": {
    "id": "123",
    "alias": "my-link",
    "shortUrl": "https://preprod.za.gl/my-link",
    "originalUrl": "https://example.com/a-very-long-link",
    "customAlias": "my-link",
    "domain": "za.gl",
    "title": "",
    "description": null,
    "hasPassword": true,
    "isActive": true,
    "expiresAt": "2026-12-31T23:59:59.000Z",
    "hits": 0,
    "waitTimer": 5,
    "created": "2026-06-25T10:00:00.000Z",
    "modified": "2026-06-25T10:00:00.000Z",
    "authToken": "your-account-token"
  }
}

Rate limits and errors

10 req/minUp to 10 requests per minute per client.
409The custom alias is already taken.
400Invalid URL or a past expiration date.
429You hit the rate limit or your monthly quota.