Reference Doc #10

API reference

The gateway's tracking endpoint, the ana.js tracker, responses, rate limits and error codes

The gateway’s tracking API and the ana.js tracker. Sending orders to Watch has its own reference: order webhook API.

Base URLs

WhatURL
Gateway (tracking)https://edge.anacoic.com
The apphttps://app.anacoic.com
Custom domainhttps://your-domain.com (if set up)

Tracking API

POST /track

Primary endpoint for sending events.

curl -X POST https://edge.anacoic.com/track \
  -H "Content-Type: application/json" \
  -H "X-Gateway-ID: your_gateway_id" \
  -d '{
    "event_name": "Purchase",
    "event_id": "unique-event-id",
    "timestamp": 1704067200,
    "user": {
      "email": "[email protected]",
      "phone": "+1234567890",
      "external_id": "user_123"
    },
    "custom_data": {
      "value": 99.99,
      "currency": "USD",
      "transaction_id": "order_123"
    }
  }'

Headers

HeaderRequiredDescription
Content-TypeYesMust be application/json
X-Gateway-IDYes*Your gateway ID (*or use ?gid= query param)

Request Body

FieldTypeRequiredDescription
event_namestringYesEvent name (e.g., “Purchase”, “AddToCart”)
event_idstringRecommendedUnique ID for deduplication
timestampnumberNoUnix timestamp (seconds). Defaults to now.
userobjectNoUser identifiers (see below)
custom_dataobjectNoEvent-specific data

User Object

FieldTypeDescription
emailstringEmail address (auto-hashed)
phonestringPhone in E.164 format (auto-hashed)
external_idstringYour internal user ID (auto-hashed)
fbpstringMeta browser ID, the _fbp cookie (auto-captured)
fbcstringMeta click ID, the _fbc cookie (auto-captured)
client_ip_addressstringAuto-extracted if not provided
client_user_agentstringAuto-extracted if not provided

Meta scores Event Match Quality itself and shows it in Events Manager. Sending more of these fields usually helps Meta match events to people, but we don’t estimate the score: check it in Events Manager.

Custom Data

Common fields for e-commerce:

FieldTypeDescription
valuenumberMonetary value
currencystringISO 4217 currency code
transaction_idstringUnique order/transaction ID
content_namestringProduct/content name
content_typestring”product”, “article”, etc.
content_idsarrayArray of product IDs
num_itemsnumberNumber of items

Response

Delivered (200, or 207 when only some destinations accepted it):

{
  "success": true,
  "partiallySuccessful": false,
  "requestId": "uuid",
  "dispatched_to": ["meta", "tiktok"],
  "results": [
    { "success": true, "provider": "meta", "status": 200, "latencyMs": 112 },
    { "success": true, "provider": "tiktok", "status": 200, "latencyMs": 98 }
  ]
}

If every destination fails, the status is 500 and success is false; each entry in results carries the destination’s error. Signed receipts for AI agents are part of the agent tools, which are coming soon.

Free plan allowance used up (200, not forwarded):

{
  "success": true,
  "forwarded": false,
  "code": "SIGNAL_LIMIT_REACHED",
  "message": "Signal received but not forwarded: this plan's 10,000 signals for this billing cycle are used up. Forwarding resumes when the next cycle starts, or right away after an upgrade."
}

Billing blocked (403):

{
  "error": "Subscription not active.",
  "code": "BILLING_LIMIT"
}

Rate limited (429):

{
  "error": "Rate limit exceeded for gateway",
  "code": "GATEWAY_RATE_LIMIT",
  "retryAfter": 60
}

Gateway not found (404):

{
  "error": "Gateway not found"
}

The ana.js tracker

Global Object

When the tracker loads, it exposes window.anacoic:

interface AnacoicSDK {
  // Track an event
  track: (event: TrackEvent) => void;

  // Track a page view
  page: (name?: string, properties?: object) => void;

  // Identify a user
  identify: (userId: string, traits?: object) => void;

  // Configuration
  config: {
    gateway_id: string;
    emq_mode: string;
  };
}

track()

anacoic.track({
  event_name: 'Purchase',
  event_id: 'unique-id',  // For deduplication
  user: {
    email: '[email protected]',
    phone: '+1234567890'
  },
  custom_data: {
    value: 99.99,
    currency: 'USD'
  }
});

page()

// Auto-named
anacoic.page();

// Custom name
anacoic.page('Product Detail', {
  product_id: 'sku_123'
});

identify()

anacoic.identify('user_123', {
  email: '[email protected]',
  plan: 'pro'
});

Rate Limits

Each gateway’s limit depends on the plan; every plan also limits each visitor IP to 30 requests per minute.

PlanPer gateway
Free300 requests per minute
Pro5,000 requests per minute
Agency15,000 requests per minute

Past the limit, /track answers 429 (see above) until the next minute.


Error Codes

CodeMeaningResolution
200Success—
400Bad RequestCheck JSON syntax
403ForbiddenCheck allowed origins; with code: "BILLING_LIMIT", the subscription isn’t active, was canceled, or its payment failed without a payment method on file
404Gateway Not FoundVerify gateway ID
429Rate LimitedWait and retry
207Some destinations failedCheck results for each destination’s error
500Every destination failedCheck results and your destination settings
502No destinations configuredAdd a destination to the gateway

Data Retention

Data TypeRetentionNotes
Delivery logsThe latest 100 entries per gateway, kept for up to 30 daysNewer entries replace older ones
Analytics30 daysAggregated data
Health stats60 daysSuccess/error counts

SDK Installation

NPM (Coming Soon)

npm install @anacoic/sdk

CDN (Current)

<script src="https://edge.anacoic.com/v1/ana.js"
        data-gateway="YOUR_GATEWAY_ID"
        data-emq="optimize"></script>

Data Attributes

AttributeDescription
data-gatewayYour gateway ID (required)
data-emqSet to “optimize” to send the page URL with each event (event_source_url), which Meta uses for matching
data-auto-pageSet to “false” to turn off the automatic PageView
data-enrichSet to “true” to add a signed-in customer’s email and ID to each event, when the store’s page exposes them (Shopify, WooCommerce, WordPress)

Need help? Contact support