Skip to content
val.io

API reference

Create short links and read their statistics from your own code. The API is part of the Pro plan.

Getting started

Create a key under Settings → API keys. A key is shown once, when you create it, so store it somewhere safe. Send it with every request:

Authorization: Bearer vio_your_key_here

All endpoints live under https://val.io/api/v1. Request and response bodies are JSON.

curl https://val.io/api/v1/links \
  -H "Authorization: Bearer $VALIO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/journal/spring-collection"}'

Each key may make 120 requests a minute. Past that, requests are answered with 429 and a Retry-After header.

Field Type Meaning
code string The part after val.io/.
short_url string The full short link.
url string Where the link leads.
title string or null Your own label for the link.
tags string[] Lowercase tags.
created_at string ISO 8601 timestamp.
expires_at string or null When the link stops working.
clicks number Clicks by people, all time.
bot_hits number Requests from crawlers and link previews, all time.
last_clicked_at string or null The most recent click by a person.
has_password boolean Whether visitors must enter a password.
max_clicks number or null The link stops working after this many clicks.
rules object[] Routing rules, see below.
utm object source, medium and campaign read from the destination.

POST /links

Field Required Meaning
url yes An http or https address, up to 2,048 characters.
custom_code no 3–32 letters, numbers, - or _. Left out, a random code is generated.
title no Up to 120 characters.
tags no Up to 8 tags, as an array or a comma-separated string.
expires_at no ISO 8601 timestamp, or Unix time in milliseconds. Must be in the future.
password no 4–128 characters.
max_clicks no A whole number of at least 1.
rules no Up to 8 routing rules.

Answers 201 with { "data": link }. If custom_code is already in use the answer is 409.

Routing rules

A rule sends matching visitors to a different address. Rules are checked in order and the first match wins; everyone else goes to url. Each rule needs a url and at least one condition:

  • device — one of ios, android, mobile, tablet, desktop
  • country — a two-letter country code such as DE
{
  "url": "https://example.com/app",
  "rules": [
    { "device": "ios", "url": "https://apps.apple.com/app/id123456789" },
    { "device": "android", "url": "https://play.google.com/store/apps/details?id=com.example" },
    { "country": "DE", "url": "https://example.com/de/app" }
  ]
}

GET /links

Query Default Meaning
limit 50 Links per page, up to 100.
offset 0 How many links to skip.
q Search in codes, titles and destinations.
tag Only links with this tag.

Answers { "data": [link, …], "total": 128, "limit": 50, "offset": 0 }, newest first.

GET /links/{code} answers { "data": link }.

PATCH /links/{code} takes any of the fields from “Create a link” except custom_code, and changes only the ones you send. Send null to clear title, expires_at, password or max_clicks, and an empty array to clear tags or rules.

DELETE /links/{code} answers 204. The link stops working straight away and its click history is erased.

GET /links/{code}/stats

Query Default Meaning
range 30d 7d, 30d, 90d, 12m or all.
bots Set to 1 to count crawlers and link previews too.
{
  "data": {
    "code": "spring",
    "range": "30d",
    "from": "2026-10-30T00:00:00.000Z",
    "to": "2026-11-29T00:00:00.000Z",
    "interval": "day",
    "totals": {
      "clicks": 2482,
      "unique_visitors": 1811,
      "bot_hits": 96,
      "previous_period_clicks": 2104
    },
    "series": [{ "start": "2026-10-30T00:00:00.000Z", "clicks": 38, "unique_visitors": 27 }],
    "countries": [{ "name": "DE", "clicks": 812 }],
    "cities": [{ "name": "Berlin", "country": "DE", "clicks": 240 }],
    "referrers": [{ "name": "direct", "clicks": 934 }],
    "devices": [{ "name": "desktop", "clicks": 1490 }],
    "browsers": [{ "name": "Chrome", "clicks": 1203 }],
    "operating_systems": [{ "name": "Windows", "clicks": 988 }]
  }
}

All times are UTC. series has one entry per day, or per month for 12m and for long all ranges; interval says which. Breakdowns list the eight largest values.

Errors

Errors use the HTTP status and a body of the form { "error": { "code": "…", "message": "…" } }. The message is written for people and says what to change.

Status Code Meaning
400 invalid_request A field is missing or not valid.
401 unauthorized The key is missing, wrong or revoked.
403 pro_required The account is not on Pro.
404 not_found No link with that code in your account.
409 conflict The custom code is already taken.
429 rate_limited More than 120 requests in a minute.