REST API

Pro

Overview

The tapurl.io REST API lets you create and manage short links, smart rules and view click statistics programmatically. Available on Pro plan and higher.

Base URL: https://tapurl.io/api/v1

Authentication

All API requests require an API key passed in the Authorization header:

Authorization: Bearer tap_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Generate your API key in Dashboard → My Account → API Access.

Keep your API key secret. Anyone with the key has full API access to your account.

Smart rules

Add geo, device or A/B test rules to any link. Each rule contains one or more variants with a target URL and weight.

MethodEndpointDescription
POST/links/{id}/rulesAdd a smart rule
GET/links/{id}/rulesList rules for a link
DELETE/links/{id}/rules/{rule_id}Delete a rule

Geo rule — redirect RU traffic

POST /api/v1/links/{id}/rules { "type": "geo", "condition_value": "RU", "priority": 1, "variants": [ { "url": "https://offer-ru.com", "weight": 100 } ] }

Device rule — mobile traffic

POST /api/v1/links/{id}/rules { "type": "device", "condition_value": "mobile", "priority": 2, "variants": [ { "url": "https://m.example.com", "weight": 100 } ] }

A/B test — 70/30 split

For A/B testing, add multiple variants to one rule. Leave condition_value empty for ab_test type.

POST /api/v1/links/{id}/rules { "type": "ab_test", "priority": 10, "variants": [ { "url": "https://offer-a.com", "weight": 70 }, { "url": "https://offer-b.com", "weight": 30 } ] }
typecondition_valueDescription
geoISO country code (RU, US, DE…)Match by visitor country
devicemobile / desktop / tabletMatch by device type
ab_test— (leave empty)Random split by weight

Statistics

Get click statistics for any link including total clicks, unique clicks, breakdown by country and device.

GET /api/v1/links/{id}/stats Authorization: Bearer tap_live_...
{ "link_id": "uuid", "total_clicks": 1542, "unique_clicks": 891, "by_country": [ { "country": "RU", "clicks": 720 }, { "country": "US", "clicks": 310 } ], "by_device": [ { "device": "mobile", "clicks": 980 }, { "device": "desktop", "clicks": 562 } ] }

Error responses

All errors return JSON with an error code and human-readable message:

{ "error": "plan_required", "message": "API access requires Pro plan or higher", "upgrade_url": "https://tapurl.io/pricing" }
HTTPerrorDescription
401unauthorizedMissing or invalid API key
401invalid_api_keyAPI key not found or revoked
403plan_requiredFeature not available on current plan
404link_not_foundLink doesn't exist or belongs to another account
404project_not_foundProject doesn't exist or belongs to another account
422invalid_typeRule type must be geo, device or ab_test
422invalid_dateexpires_at must be YYYY-MM-DD format