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).
| Status | Body |
|---|---|
201 | { id, shortUrl, url, secretKey, expiresAt }. url is the normalised target (host in punycode). |
400 | invalid_json, invalid_body or a domain code from the table below. |
409 | id_taken |
413 | payload_too_large (body over 8 KB) |
415 | unsupported_media_type |
429 | rate_limited |
503 | service_unavailable |
GET / api/ v1/ links/ :id
Returns the link's target without redirecting.
Input. None.
| Status | Body |
|---|---|
200 | { id, url, expiresAt, createdAt } |
404 | not_found |
410 | expired or link_disabled |
429 | rate_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>.
| Status | Body |
|---|---|
200 | { visits, countries: [{ code, visits }], partial }. With the key, cities too. |
403 | forbidden. Returned for any Authorization header that is not this link's key. There is no fallback to the public view. |
404 | not_found |
410 | expired or link_disabled |
429 | rate_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.
| Status | Body |
|---|---|
204 | No content. |
400 | invalid_key (no key or a malformed one) |
403 | forbidden (the key does not match the link) |
404 | not_found |
429 | rate_limited |
GET / api/ v1/ stats
Stats of the whole service. The numbers cover live links only.
Input. None.
| Status | Body |
|---|---|
200 | { links, visits, countries: [{ code, visits }], updatedAt }. The numbers are recomputed once a day and can lag by about 24 hours. |
429 | rate_limited |
Errors
Every error has the same shape:
{ "error": { "code": "id_taken", "message": "customName is already taken" } }| Status | Code | Meaning |
|---|---|---|
400 | invalid_ | The request body is not valid JSON. |
400 | invalid_ | The body does not match the schema: url missing, a field of the wrong type or an unknown field. |
400 | invalid_ | url is not a valid URL. |
400 | unsupported_ | Only http: and https: are allowed. |
400 | url_ | url is longer than 2048 characters. |
400 | credentials_ | The address contains credentials (user:password@). |
400 | own_ | The address points to this service. |
400 | private_ | A local, private or reserved address (IPv4, IPv6, localhost). |
400 | blocked_ | The address is another link shortener or is on the block list. |
400 | invalid_ | customName has 3 to 32 letters, digits, _ or -. It is stored in NFKC form, so full-width letters become plain ones. |
400 | name_ | customName is too long. |
400 | reserved_ | customName is reserved by the service. |
400 | mixed_ | customName mixes the Latin alphabet with another script or its digits. |
400 | invalid_ | expiresAt is not an existing date in ISO 8601 format. |
400 | expiry_ | expiresAt is in the past. |
400 | expiry_ | expiresAt is more than a year from now. |
400 | invalid_ | DELETE without a key or with a malformed key. |
403 | forbidden | The key does not match the link. |
404 | not_ | No such link. |
409 | id_ | customName is already taken. |
410 | expired | The link has expired. |
410 | link_ | The link was disabled for abuse. |
413 | payload_ | The request body is over 8 KB. |
415 | unsupported_ | Content-Type must be application/json. |
429 | rate_ | Rate limit exceeded. See Retry-After. |
500 | internal_ | Server error. |
503 | service_ | Checking 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.
| Route | Limit |
|---|---|
POST / | 10 per minute |
DELETE / | 10 per minute |
GET / | 120 per minute, shared with GET /:id redirects |
GET / | 60 per minute |
CORS, key and headers
GETresponses carryAccess-Control-Allow-Origin: *. The server never echoes theOriginheader and does not allow credentials.POSTandDELETEhave 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 asAuthorization: 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/statsDelete a link
curl -X DELETE -H 'Authorization: Bearer <key>' https://dzaj.de/api/v1/links/my-linkThe 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.
| v2 endpoint | v1 endpoint | What changed |
|---|---|---|
GET / | GET / | The response is { id, url, expiresAt, createdAt } instead of { fullLink }. |
GET / | GET / | The response is { visits, countries, partial }. Cities only with the key. The /:id/info page redirects (301) to /:id/stats. |
POST / | POST / | The 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 / | DELETE / | The 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 bycode.