Endpoint
POST/link
APIs that can be used to work with State programmatically
This API method creates a short link for the authenticated team.
Authorization required.
url and domain_id are required; all other parameters are optional.
| Parameter | Description |
|---|---|
| url | Original long URL |
| domain_id | Domain ID. You can retrieve available domains via the Domains API |
| slug | Desired slug. If already taken, an error will be returned; if omitted, it’s generated automatically |
| title | Optional title; if omitted, it’s fetched from the long URL |
| slug_length | Desired slug length (used when auto-generating the slug) |
| folder_id | The unique ID of an existing folder to assign the short link to |
| tags | Array of unique IDs of existing tags to assign to the short link |
| utm_source | UTM source for the short link; overrides the destination URL’s UTM source if set |
| utm_medium | UTM medium for the short link; overrides the destination URL’s UTM medium if set |
| utm_campaign | UTM campaign for the short link; overrides the destination URL’s UTM campaign if set |
| utm_term | UTM term for the short link; overrides the destination URL’s UTM term if set |
| utm_content | UTM content for the short link; overrides the destination URL’s UTM content if set |
| utm_reference | Custom tag (non-standard) for referral programs or similar use cases |
| ios | The iOS destination URL for the short link; takes priority on iOS devices |
| android | The Android destination URL for the short link; takes priority on Android devices |
| password | Optional password to protect the link |
| expires_at | ISO date when the link expires |
| expires_after | Maximum number of clicks before expiration |
| expire_url | Optional redirect URL after expiration |
| redirect_code | Custom redirect code. Default is 302 |
curl https://state.sk/api/link \
-H 'x-api-key: state_xxxxxxxxxx' \
-d '{
"url": "https://google.com",
"domain_id": 1
}'
The new link
{
"id": "id-1",
"org_id": "org-1",
"user_id": "user-1",
"folder_id": null,
"domain_id": 1,
"domain": "state.sk",
"slug": "somethingrandom",
"url": "https://google.com",
"title": "Google",
"expires_at": null,
"expires_after": 0,
"expire_url": null,
"utm_source": null,
"utm_medium": null,
"utm_campaign": null,
"utm_term": null,
"utm_content": null,
"utm_reference": null,
"created_at": "2025-10-07T13:12:01.761Z",
"updated_at": "2025-10-07T13:12:01.761Z",
"ios": null,
"android": null,
"redirect_code": null,
"has_password": false,
"short_url": "https://state.sk/somethingrandom",
"clicks": 0,
"clicked_at": null,
"folder": null,
"tags": [],
"ab": [],
"geo": []
}
Detailed information about the link fields in the Link article.