Endpoint
PUT/link/:link_id/ab
APIs that can be used to work with State programmatically
This API method allows the authenticated team to update, add, or remove A/B links associated with an existing short link.
Authorization required.
| Parameter | Description |
|---|---|
| link_id | Required |
| Parameter | Description |
|---|---|
| items | Array of URLs with assigned percentages |
Each array element must include a valid URL and a percentage.
The total percentage must be less than or equal to 100%.
Example:
{
"items": [
{ "id": 1, "url": "https://bing.com", "percent": 25 },
{ "url": "https://duckduckgo.com", "percent": 25 }
]
}
Links with IDs are updated, links without IDs are added, and any existing A/B link not included in the payload will be deleted.
curl -X 'PUT' https://state.sk/api/link/link42/ab \
-H 'x-api-key: state_xxxxxxxxxx' \
-d '{
"items": [
{ "id": 1, "url": "https://bing.com", "percent": 25 },
{ "url": "https://duckduckgo.com", "percent": 25 }
]
}'
The updated link
{
"id": "link42",
"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,
"domain": null,
"redirect_code": null,
"has_password": false,
"short_url": "https://state.sk/somethingrandom",
"clicks": 3,
"clicked_at": "2025-10-15T13:12:01.761Z",
"folder": null,
"tags": [],
"ab": [
{ "id": 1, "url": "https://bing.com", "percent": 25 },
{ "url": "https://duckduckgo.com", "percent": 25 }
],
"geo": []
}
Detailed information about the link fields in the Link article.