Language
Theme

dzajco API v1

A public JSON API to create, read and delete links. Base URL: https://dzaj.de.

Endpoints

POST /api/v1/links

Creates a link. Needs the header Content-Type: application/json.

Input. JSON: url (required), customName (optional), expiresAt (ISO 8601 or null).

Responses
StatusBody
201{ id, shortUrl, url, secretKey, expiresAt }. url is the normalised target (host in punycode).
400invalid_json, invalid_body or a domain code from the table below.
409id_taken
413payload_too_large (body over 8 KB)
415unsupported_media_type
429rate_limited
503service_unavailable

GET /api/v1/links/:id

Returns the link's target without redirecting.

Input. None.

Responses
StatusBody
200{ id, url, expiresAt, createdAt }
404not_found
410expired or link_disabled
429rate_limited

GET /api/v1/links/:id/stats

Stats of a link. Without an Authorization header you get the public view, with the right key the owner's view.

Input. Optional Authorization: Bearer <key>.

Responses
StatusBody
200{ visits, countries: [{ code, visits }], partial }. With the key, cities too.
403forbidden. Returned for any Authorization header that is not this link's key. There is no fallback to the public view.
404not_found
410expired or link_disabled
429rate_limited

DELETE /api/v1/links/:id

Removes the link and its stats from the service. A summary is kept in an internal archive for 30 days (see the privacy policy).

Input. Authorization: Bearer <key>. The body is ignored.

Responses
StatusBody
204No content.
400invalid_key (no key or a malformed one)
403forbidden (the key does not match the link)
404not_found
429rate_limited

GET /api/v1/stats

Stats of the whole service. The numbers cover live links only.

Input. None.

Responses
StatusBody
200{ links, visits, countries: [{ code, visits }], updatedAt }. The numbers are recomputed once a day and can lag by about 24 hours.
429rate_limited

Errors

Every error has the same shape:

{ "error": { "code": "id_taken", "message": "customName is already taken" } }
Errors
StatusCodeMeaning
400invalid_jsonThe request body is not valid JSON.
400invalid_bodyThe body does not match the schema: url missing, a field of the wrong type or an unknown field.
400invalid_urlurl is not a valid URL.
400unsupported_schemeOnly http: and https: are allowed.
400url_too_longurl is longer than 2048 characters.
400credentials_not_allowedThe address contains credentials (user:password@).
400own_hostThe address points to this service.
400private_targetA local, private or reserved address (IPv4, IPv6, localhost).
400blocked_targetThe address is another link shortener or is on the block list.
400invalid_namecustomName has 3 to 32 letters, digits, _ or -. It is stored in NFKC form, so full-width letters become plain ones.
400name_too_longcustomName is too long.
400reserved_namecustomName is reserved by the service.
400mixed_scriptcustomName mixes the Latin alphabet with another script or its digits.
400invalid_expiryexpiresAt is not an existing date in ISO 8601 format.
400expiry_in_pastexpiresAt is in the past.
400expiry_too_farexpiresAt is more than a year from now.
400invalid_keyDELETE without a key or with a malformed key.
403forbiddenThe key does not match the link.
404not_foundNo such link.
409id_takencustomName is already taken.
410expiredThe link has expired.
410link_disabledThe link was disabled for abuse.
413payload_too_largeThe request body is over 8 KB.
415unsupported_media_typeContent-Type must be application/json.
429rate_limitedRate limit exceeded. See Retry-After.
500internal_errorServer error.
503service_unavailableChecking the block list failed. Try again later.

Limits

Limits count per IP address in a 60-second window. Over the limit you get 429 with a Retry-After header. Each location counts on its own, so the limits guard against abuse rather than count exactly.

Limits
RouteLimit
POST /api/v1/links10 per minute
DELETE /api/v1/links/:id10 per minute
GET /api/v1/links/:id120 per minute, shared with GET /:id redirects
GET /api/v1/links/:id/stats, GET /api/v1/stats60 per minute

CORS, key and headers

  • GET responses carry Access-Control-Allow-Origin: *. The server never echoes the Origin header and does not allow credentials.
  • POST and DELETE have no CORS. Call them from a server or from the same domain.
  • You get the key (secretKey) once, in the 201 response. It has 22 characters (base64url). Keys of links moved over from v2 have 12 characters (A-Z, a-z, 0-9, _, -) and work the same way. Send it as Authorization: Bearer <key> (the scheme name is case-insensitive). Never in the URL or the query string.
  • Every link has its own key. The 201 response, the owner's stats response and the result page carry Cache-Control: no-store.
  • JSON responses carry Content-Security-Policy: default-src 'none'.

Examples

Create a link

curl -X POST https://dzaj.de/api/v1/links \
  -H 'Content-Type: application/json' \
  -d '{"url":"https://example.com/long/path","customName":"my-link","expiresAt":null}'

201 response:

{
  "id": "my-link",
  "shortUrl": "https://dzaj.de/my-link",
  "url": "https://example.com/long/path",
  "secretKey": "Zx3k...22 characters",
  "expiresAt": null
}

Public and owner stats

curl https://dzaj.de/api/v1/links/my-link/stats
curl -H 'Authorization: Bearer <key>' https://dzaj.de/api/v1/links/my-link/stats

Delete a link

curl -X DELETE -H 'Authorization: Bearer <key>' https://dzaj.de/api/v1/links/my-link

The partial field in the stats is true when the latest visits could not be read. Data from earlier days is complete then.

Moving from v2

The old /api/urls paths have no alias. /dzajapi redirects (301) here. Update your calls as in the table.

Moving from v2
v2 endpointv1 endpointWhat changed
GET /api/urls/{shortUrl}GET /api/v1/links/:idThe response is { id, url, expiresAt, createdAt } instead of { fullLink }.
GET /api/urls/{shortUrl}/infoGET /api/v1/links/:id/statsThe response is { visits, countries, partial }. Cities only with the key. The /:id/info page redirects (301) to /:id/stats.
POST /api/urlsPOST /api/v1/linksThe expire field is now expiresAt (ISO 8601 or null). The 201 response is { id, shortUrl, url, secretKey, expiresAt }, without message. Validation errors are 400 instead of 422, a taken name is 409. Content-Type: application/json is required.
DELETE /api/urls/{shortUrl}DELETE /api/v1/links/:idThe key goes in the Authorization: Bearer <key> header, not in a { secretKey } body and never in the URL. Success is 204 with no content.
  • Errors look like { error: { code, message } } instead of { error: "..." }. Tell them apart by code.