API reference
A REST API for creating and managing short links and reading their analytics.
Authentication
Every request needs an API key in the Authorization header. Keys are created at /dashboard/api-keys, shown once, and stored only as a SHA-256 hash — there is no way to recover a lost key.
curl https://sportnex.pro/api/v1/links \
-H "Authorization: Bearer lf_your_key_here"Keep keys server-side
Scopes
- readList and retrieve links; read analytics. Granted by default.
- writeCreate, update and delete links. Grant it only where you need it.
Rate limits
Limits are applied per key. Exceeding one returns 429 with a Retry-After header giving the seconds until the window resets. Back off rather than retrying immediately — a tight retry loop will simply keep the window saturated.
Endpoints
Base URL: https://sportnex.pro/api/v1
- GET
/linksreadList your links, newest first.
- page
- integer — Page number. Default 1.
- per_page
- integer — 1–100. Default 25.
- status
- string — active | disabled | archived | expired
- POST
/linkswriteCreate a short link.
- destinationUrl
- string — Required. Public http(s) URL.
- slug
- string — Optional. Generated when omitted.
- password
- string — Optional. Gates the redirect.
- expiresAt
- string — Optional ISO 8601 instant.
- maxClicks
- integer — Optional click budget.
- GET
/links/{id}readRetrieve one link.
- PATCH
/links/{id}writePartial update. Only the fields you send are changed.
- destination_url
- string — New destination.
- status
- string — active | disabled | archived
- password
- string — Send "" to remove protection.
- DELETE
/links/{id}writeSoft delete. Recorded clicks are retained.
- GET
/analyticsreadTime series and dimension breakdowns.
- days
- integer — 1–365. Default 30.
- link_id
- uuid — Scope to a single link.
Errors
Every failure returns the same envelope, so a client can handle them uniformly:
{
"error": {
"code": "invalid_key",
"message": "That API key is not valid."
}
}- 400
- The request body was not valid JSON.
- 401
- Missing, invalid, expired or revoked key.
- 403
- The key lacks the required scope, or the account is inactive.
- 404
- No such resource, or it does not belong to this key.
- 409
- The requested slug is taken.
- 422
- Validation failed. The response names the offending fields.
- 429
- Rate limited. See Retry-After.
- 503
- The API is disabled on this deployment.
A complete example
# Create a link
curl -X POST https://sportnex.pro/api/v1/links \
-H "Authorization: Bearer lf_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"destinationUrl": "https://example.com/spring-campaign",
"slug": "spring",
"title": "Spring campaign",
"utmSource": "newsletter",
"utmMedium": "email"
}'
# Read its analytics
curl "https://sportnex.pro/api/v1/analytics?link_id=<id>&days=30" \
-H "Authorization: Bearer lf_your_key_here"Questions about the API on LinkForge? Contact your administrator.