Links API
Keys
Authorization: Bearer lk_live_…orlk_test_…, one integration per system.- Links made with a test key open only at
https://links.wchi.app/test/<name>, never on wchi.app.
| Permission | Allows |
|---|---|
| links:read | List and read links, their history, and whether a name is free |
| links:write | Make, change, turn off and turn on links |
| links:choose_name | Choose a link's name; without it, every name is generated. Granted by an admin |
| stats:read | Read click counts |
Calls
| POST | /api/v1/links | Make a link: target; optional title, notes, expires_at; name only with links:choose_name |
| GET | /api/v1/links | This integration's links: status, q, limit, cursor |
| GET | /api/v1/links/{name} | One link |
| PATCH | /api/v1/links/{name} | Change target, title, notes, expires_at; an absent field is left alone, null clears it |
| POST | /api/v1/links/{name}/disable | Turn off |
| POST | /api/v1/links/{name}/enable | Turn back on |
| GET | /api/v1/links/{name}/history | Every change, newest first |
| GET | /api/v1/links/{name}/stats | Clicks, previews and unique visitors by Manila day: from, to |
| GET | /api/v1/names/{name} | Free, taken, reserved or invalid |
| GET | /api/v1/openapi.json | OpenAPI 3.1 |
Making a link
curl https://links.wchi.app/api/v1/links \
-H "Authorization: Bearer lk_live_…" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{ "target": "https://forms.office.com/r/…", "title": "Free lunch sign-up" }'
201
{ "link": { "name": "k7xq2m", "short_url": "https://wchi.app/k7xq2m",
"target": "https://forms.office.com/r/…", "status": "active", … } }Rules
- Every POST carries an
Idempotency-Key. A retry with the same key and body returns the first answer and makes nothing; the same key with a different body is a 422. - Names are 1 to 64 letters, digits and hyphens. Case doesn't matter. Generated names are 6 characters.
- Targets are http or https, and never another short link.
- A link is never deleted. Turned off or expired, it answers “This link is no longer active”.
- Lists page with
next_cursor. Up to 60 new links a minute per integration; then 429 withRetry-After. - The visitor's query string is added to the target: wchi.app/k7xq2m?ref=fb opens the target with ref=fb.
Errors
{ "error": { "code": "name_taken", "message": "…", "detail": "…", "docs": "https://links.wchi.app/developers#name_taken" } }| Code | HTTP | Meaning |
|---|---|---|
| invalid_key | 401 | The API key is missing, revoked or not recognised. |
| idempotency_key_required | 400 | Every POST needs an Idempotency-Key header (1 to 255 characters). |
| invalid_request | 400 | The request doesn't match the API. |
| invalid_filter | 400 | A filter or range in the address can't be used. |
| name_invalid | 400 | A name is 1 to 64 letters, digits and hyphens, and doesn't start or end with a hyphen. |
| target_not_allowed | 400 | The target must be an http or https address, and not another short link. |
| missing_permission | 403 | This integration isn't allowed to do that. |
| name_not_allowed | 403 | This integration makes links with generated names only. Choosing a name needs the links:choose_name permission, which an admin grants. |
| not_found | 404 | This integration has no link with that name. |
| name_taken | 409 | That name is already a link. |
| name_reserved | 409 | That name is reserved. |
| request_in_progress | 409 | A request with this Idempotency-Key is still being handled. Retry shortly. |
| idempotency_key_reused | 422 | This Idempotency-Key was already used with a different request. |
| rate_limited | 429 | Too many new links from this integration. Retry after the time given. |
| internal | 500 | Something went wrong on Links' side. |