API for services

Services can create short links over HTTP. Requests and responses are JSON, calls are authenticated with a service token that carries the scope shortener.create.

Base URL

  • Production: https://cats.sunamo.cz/sho/
  • Local development: https://localhost:5014/

Authentication

Every call sends the service token in the Authorization header. Service tokens come from one shared token system for all services on sunamo.cz, not only the shortener.

Authorization: Bearer <token>
  • The administrator issues a token on the page (admin only): https://sunamo.cz/en/api-tokens
  • A token carries scopes - the list of things the service may do. This API needs the scope shortener.create. The catalog of all scopes is shown when issuing a token.
  • A token is valid for at most 365 days; the administrator chooses the validity when issuing it.
  • The administrator can revoke a token at any time; a revoked token is rejected with 401 within 5 seconds. The list shows all issued tokens, valid and invalid.
  • The full token is shown only once. Keep it as a secret (not in a repository, not in a URL).

Create a short link

POST Shortener/CreateShortUrl. Only longUrl is required; customShort (lowercase letters, digits, hyphen, up to 32 characters) and comment are optional; deleteAfterFirstClick (true/false) deletes the link after its first open. The same address for the same owner returns the existing code.

curl -X POST https://cats.sunamo.cz/sho/Shortener/CreateShortUrl \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"longUrl":"https://example.com/a/very/long/address","customShort":"optional-code","comment":"optional note"}'

Response 200:

{
  "id": 42,
  "code": "rqy26dd",
  "longUrl": "https://example.com/a/very/long/address",
  "enabled": true,
  "createdAt": "2026-11-11T20:28:04Z",
  "clicks": 0,
  "comment": null
}

Create many short links

POST Shortener/CreateShortUrlBatch with up to 100 addresses. Results come in the same order as the input; each item has either code or error.

curl -X POST https://cats.sunamo.cz/sho/Shortener/CreateShortUrlBatch \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"urls":["https://example.com/one","https://example.com/two"]}'
[
  { "input": "https://example.com/one", "code": "k3j9x0a", "error": null },
  { "input": "https://example.com/two", "code": null, "error": "Adresa nemá platný protokol (http:// nebo https://)" }
]

Building the short URL

The API returns only the code. The short URL is the address of sunamo.cz with the code in the query q; opening it redirects to the long address.

https://sunamo.cz/?q=<code>

Local development: http://localhost:4005/?q=<code>

Errors

HTTPMeaning
400Invalid request. The body is {"error": "..."} with the reason (empty or too long address, missing http:// or https://, address already shortened, code already taken or reserved).
401Missing, invalid, expired or revoked token.
403The token does not carry the scope shortener.create, or the call is not available to service tokens (only creating links is).