API Reference
Complete reference for the LinkTrace Client API — link creation, install attribution, link metadata, and event tracking.
Base URL
https://api.linktrace.in
Your API Key
your-api-key(issued once you sign up)
Endpoints in this reference
Links & Attribution
Event Tracking
Authentication
Every request is authenticated with your secret API key. Here's how to send it and what each plan can call.
API Keys
Every request must include your API key in the x-api-key HTTP header. You can find your key in the LinkTrace dashboard under Settings → API Key.
x-api-key: your-api-keyKeep your API key secret. Never expose it in client-side JavaScript, mobile app binaries, or public repositories. Rotate it immediately from the dashboard if you suspect compromise.
Plan requirements
| Endpoint | Free Plan | Scale Plan |
|---|---|---|
POST /api/v1/referral-links | ✓ Available | ✓ Available |
POST /api/v1/attributions | ✓ Available | ✓ Available |
GET /api/v1/referral-links/metadata | ✓ Available | ✓ Available |
POST /api/v1/events | ✗ Scale only | ✓ Available |
Link Creation & Attribution
Generate traceable links, attribute new installs to the referrer that drove them, and resolve link metadata.
Generate Dynamic Links
POSTGenerate a unique traceable link for a referrer or campaign. Share this link anywhere — in-app share sheets, social posts, email campaigns, or QR codes. Anyone who clicks this link and installs your app within the attribution window will be attributed to this referrer.
Headers
| Header | Value | Required |
|---|---|---|
| Content-Type | application/json | Yes |
| x-api-key | your-api-key | Yes |
Example Payload
{
"referrerIdentifier": "user_id_223",
"source": "home_tab",
"campaign": "in_app_referral",
"environment": "production",
"customPayload": {
"date": "15 Aug, 2025",
"cta": "share app pop up in home"
}
}Track App Installs
POSTCall this endpoint from your app after a new user completes signup. Pass their unique identifier (userId) — LinkTrace matches the install to a prior link click and returns the full referral data. A given userId is only attributed once — repeat calls return the existing attribution.
- First-touch attribution — LinkTrace attributes an install to the first dynamic link the user clicked.
- Attribution window — 24 hours from the link click. If a user installs within that window, the install is attributed.
- Deterministic matching — Attribution is based on the device clicking the link, not probabilistic fingerprinting.
- Custom payload passthrough — Any
customPayloadfields you set on the link are returned in the attribution response.
Headers
| Header | Value | Required |
|---|---|---|
| Content-Type | application/json | Yes |
| x-api-key | your-api-key | Yes |
Example Payload
{
"userId": "user_275"
}Integrate this endpoint with an AI coding assistant
Skip the manual wiring. This prompt gives your AI coding tool full context for the Attribution API above, so it can drop the install-tracking call into your signup flow, tailored to your stack. Sign in to copy it pre-filled with your API key.
/api/v1/referral-links/metadata
x-api-keyResolve metadata for a referral link by full URL, path, or bare short code.
Query parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| link | string | required | Accepts a full URL (https://app.linktrace.in/r/497b3422), a path (/r/497b3422), or a bare short code (497b3422). |
Example request
curl "https://api.linktrace.in/api/v1/referral-links/metadata?link=https://app.linktrace.in/r/497b3422" \
-H "x-api-key: your-api-key"Response fields — 200 OK
| Field | Type | Description |
|---|---|---|
| shortCode | string | The resolved short code. |
| referrerIdentifier | string | The referrer as set when the link was created. |
| source / medium / campaign | string | null | UTM-style fields. |
| environment | string | production or stage. |
| customPayload | object | null | Custom metadata attached to the link. |
| active | boolean | Whether the link is currently active. |
| createdAt | string (ISO 8601) | Timestamp when the link was created. |
Privacy by design. The API returns an identical 404 Link not found error whether the link does not exist or belongs to a different account — to prevent link enumeration.
Event Tracking
Send post-install conversion events to measure what your referred users do after they sign up.
Scale plan required. Event ingestion is available on the Scale plan only. Calls from non-Scale accounts return 403 PLAN_UPGRADE_REQUIRED.
/api/v1/events
Scale x-api-keyIngest a named event against a referral link's short code — purchases, sign-ups, level completions, anything meaningful — and attribute it back to the link that drove the install. Writes are fire-and-forget: the endpoint responds immediately and the database write happens asynchronously.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
| linkShortCode | string | required | The 4–32 character alphanumeric short code of the referral link (e.g. 497b3422). |
| eventName | string | required | A snake_case event name. Must start with a letter and contain only lowercase letters, digits, and underscores — max 128 characters. Names are normalised to lowercase automatically. Reserved names (rejected): click, install, impression, open. |
| entityId | string | optional | A unique identifier for the entity this event represents (e.g. an order ID, user ID, session ID). When provided, LinkTrace deduplicates events: if the same (linkShortCode, eventName, entityId) tuple has already been recorded, the second call returns 200 { deduplicated: true } instead of writing a new row. Max 255 characters. |
Basic — no dedup
{
"linkShortCode": "497b3422",
"eventName": "web_link_click"
}With entityId — deduplication enabled
{
"linkShortCode": "497b3422",
"eventName": "purchase",
"entityId": "order_9876"
}Responses
Event queued for async write. Normal success path.
{ "success": true, "queued": true }
Same (shortCode, eventName, entityId) already recorded.
{ "success": true, "deduplicated": true }
Monthly limit of 5,000 events reached.
{ "code": "QUOTA_EXCEEDED", "resetsOn": "2026-07-01T00:00:00.000Z" }
Account is not on the Scale plan.
{ "code": "PLAN_UPGRADE_REQUIRED" }
Quota applies to production events only. The 5,000 monthly limit tracks only events sent for the production environment. The counter resets on the 1st of each calendar month (UTC).
Code example
curl -X POST https://api.linktrace.in/api/v1/events \
-H "x-api-key: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"linkShortCode": "497b3422",
"eventName": "purchase",
"entityId": "order_9876"
}'Errors
Standard HTTP status codes with a consistent error envelope across every endpoint.
Error Response Format
All errors follow a consistent JSON envelope.
{
"success": false,
"message": "Human-readable description of what went wrong",
"code": "MACHINE_READABLE_CODE",
"resetsOn": "2026-07-01T00:00:00.000Z"
}code is present on some errors; resetsOn is present on 429 QUOTA_EXCEEDED.
| HTTP Status | Code | When it occurs |
|---|---|---|
| 400 | — | Validation error — missing or invalid request fields. |
| 401 | — | Missing or invalid x-api-key header. Your key is available in Settings → API Key. |
| 403 | PLAN_UPGRADE_REQUIRED | The requested endpoint requires the Scale plan. |
| 404 | LINK_NOT_FOUND | The short code does not exist or belongs to another account. |
| 429 | QUOTA_EXCEEDED | Monthly event quota (5,000) has been exhausted. resetsOn indicates when the counter resets. |
Platform Examples
Copy-paste integration snippets for the most common mobile and web stacks.
Platform Integration Examples
val client = OkHttpClient()
val mediaType = "application/json".toMediaType()
val body = "{
\"userId\": \"user_275\"
}".toRequestBody(mediaType)
val request = Request.Builder()
.url("https://api.linktrace.in/api/v1/attributions")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("x-api-key", "your-api-key")
.build()
val response = client.newCall(request).execute()Need Help?
Running into an issue with your integration? Send us an email — we respond within 24 hours on weekdays.
contact@linktrace.in