API Reference

Complete reference for the NextLinks REST API. All endpoints use the base URL https://nextlinks.ai

Authentication

Most API endpoints require authentication. Include your API key in the Authorization header:

Authorization: Bearer YOUR_API_KEY

Getting Your API Key

  1. Navigate to your workspace settings
  2. Go to the API Keys section
  3. Generate a new API key
  4. Store it securely - it won't be shown again

Public Endpoints

The /api/click and /api/event endpoints are public and do not require authentication. They are designed for high-volume traffic.

Click Tracking

GET/api/click

Redirects users to the destination URL while tracking the click. This is called automatically when users click a NextLink.

Query Parameters

ParameterRequiredDescription
sYesLink slug
dNoDomain (for custom domains)
*NoAny other params are passed to destination

Example

# User clicks this URL
https://nextlinks.ai/c/abc123?utm_source=facebook

# System redirects to destination with click_id added
https://yoursite.com/landing?utm_source=facebook&click_id=uuid-here

UTM Parameter Pass-through

All UTM parameters and custom parameters (except reserved ones like s, d, click_id) are automatically appended to the destination URL.

Event/Conversion Tracking

GETPOST/api/event

Records a conversion event. Can be called via GET (for image pixels) or POST (for server-side tracking).

Parameters

ParameterRequiredDescription
pbkYes*Postback key from event config
click_idYes*Click ID from the original redirect
valueNo**Conversion value (for RevShare payouts)
metadataNoJSON object with additional data

* At least one of pbk or click_id is required
** Required for RevShare payout type

# GET request (simple)
curl "https://nextlinks.ai/api/event?pbk=your_key&click_id=abc123&value=49.99"

# POST request (with metadata)
curl -X POST https://nextlinks.ai/api/event \
  -H "Content-Type: application/json" \
  -d '{
    "pbk": "your_postback_key",
    "click_id": "abc123-def456",
    "value": 49.99,
    "metadata": {
      "order_id": "ORDER-123",
      "product": "Premium Plan"
    }
  }'

Response

{
  "success": true,
  "eventId": 12345,
  "clickStatus": "found"  // or "pending" if click not yet processed
}

Domains

GET/api/domains

List all custom domains for an account.

POST/api/domains

Add a new custom domain.

curl -X POST https://nextlinks.ai/api/domains \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "accountId": "YOUR_ACCOUNT_ID",
    "domain_name": "go.yourcompany.com"
  }'

Reports & Analytics

POST/api/reports

Get aggregated analytics data with flexible grouping and filtering.

Request Body

FieldTypeDescription
accountIdstringAccount UUID
dateRangeobject{ from: 'YYYY-MM-DD', to: 'YYYY-MM-DD' }
groupBystringlink, tag, device, country, browser, os
filtersobjectOptional filters
curl -X POST https://nextlinks.ai/api/reports \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "accountId": "YOUR_ACCOUNT_ID",
    "dateRange": {
      "from": "2024-01-01",
      "to": "2024-01-31"
    },
    "groupBy": "link"
  }'

Webhooks

POST/api/webhooks

Create a webhook to receive conversion events.

curl -X POST https://nextlinks.ai/api/webhooks \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "account_id": "YOUR_ACCOUNT_ID",
    "name": "My CRM Webhook",
    "target_url": "https://yourserver.com/webhook",
    "method": "POST",
    "payload_template": {
      "click_id": "{click_id}",
      "value": "{value}",
      "timestamp": "{conversion_timestamp}"
    }
  }'

Available Macros

Use these macros in your payload template:

{click_id}{slug}{conversion_timestamp}{actual_destination}{value}{postback_key}{ip_address}{user_agent}{metadata}

Tags

POST/api/tags

List or create tags for organizing links.

# List tags
curl -X POST https://nextlinks.ai/api/tags \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "accountId": "YOUR_ACCOUNT_ID",
    "page": 1
  }'

Rate Limits

API requests are subject to rate limiting to ensure service stability:

Standard API Endpoints

  • 100 requests per minute per IP
  • 1,000 requests per hour per account

Click Tracking (/api/click)

  • No rate limiting - designed for high traffic
  • Optimized for ad server verification

Event Tracking (/api/event)

  • No rate limiting - designed for conversion volume

Rate Limit Headers

Responses include these headers:

  • X-RateLimit-Remaining: Requests remaining
  • X-RateLimit-Reset: When limit resets

Error Handling

All errors follow a consistent JSON format:

{
  "error": "Error message description"
}

HTTP Status Codes

  • 200 - Success
  • 400 - Bad request (invalid parameters)
  • 401 - Unauthorized (missing or invalid API key)
  • 403 - Forbidden (no access to resource)
  • 404 - Resource not found
  • 429 - Rate limit exceeded
  • 500 - Server error