API Reference

Complete API reference for Anacoic endpoints

API Reference

Complete reference for Anacoic’s REST API and SDK methods.

Base URLs

EnvironmentURL
Edge (Tracking)https://edge.anacoic.com
Web Apphttps://anacoic.com
Custom Domainhttps://your-domain.com (if configured)

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

FieldTypeEMQ ImpactDescription
emailstring+2.5 ptsEmail address (auto-hashed)
phonestring+2.0 ptsPhone in E.164 format (auto-hashed)
external_idstring+1.0 ptYour internal user ID (auto-hashed)
fbpstring+1.5 ptsFacebook Browser ID (auto-captured)
fbcstring+1.5 ptsFacebook Click ID (auto-captured)
client_ip_addressstring+0.5 ptsAuto-extracted if not provided
client_user_agentstring+0.3 ptsAuto-extracted if not provided

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

Success (200):

{
  "status": "confirmed",
  "receipt": {
    "data": {
      "id": "uuid",
      "ts": 1704067200000,
      "owner": "user_id"
    },
    "signature": "hmac_sha256_hex"
  },
  "tx_id": "uuid"
}

Rate Limited (429):

{
  "error": "Rate limit exceeded. Maximum 100 requests per minute.",
  "retry_after": 45
}

Gateway Not Found (404):

{
  "error": "Gateway Not Configured"
}

Agent Gateway API (MCP)

GET /v1/mcp/sse

Server-Sent Events endpoint for MCP connections.

curl -N https://edge.anacoic.com/v1/mcp/sse?gid=your_gateway_id

POST /v1/mcp/sse

JSON-RPC endpoint for MCP commands.

curl -X POST https://edge.anacoic.com/v1/mcp/sse?gid=your_gateway_id \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "resources/list"
  }'

Methods

MethodDescription
initializeInitialize MCP connection
resources/listList available resources
resources/readRead a specific resource
tools/listList available tools
tools/callExecute a tool

Resources

URIDescription
pricing://currentPricing tiers as JSON
docs://primaryDocumentation URL
system://hintAnti-hallucination instructions

Tools

ToolParametersDescription
book_demoname, email, company?, message?Submit demo request

Tracker.js SDK

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;
    mcp_enabled: boolean;
    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'
});

Server Actions (Dashboard)

These endpoints are used by the Anacoic dashboard.

Authentication

All dashboard actions require Supabase authentication via cookies.

Gateways

ActionDescription
getGatewaysForOrg(orgId)List organization’s gateways
addGateway(data)Create new gateway
getGatewayAnalytics(gatewayId)Get 30-day analytics

Agent Manifest

ActionDescription
getAgentManifest(gatewayId)Get MCP configuration
saveAgentManifest(gatewayId, data)Update MCP configuration

Rate Limits

EndpointLimitWindow
POST /track100 requests60 seconds per gateway
GET /v1/mcp/sse10 connectionsPer IP
Dashboard API1000 requests60 seconds per user

Error Codes

CodeMeaningResolution
200Success
400Bad RequestCheck JSON syntax
403ForbiddenCheck allowed origins
404Gateway Not FoundVerify gateway ID
429Rate LimitedWait and retry
502All Providers FailedCheck integrations config

Data Retention

Data TypeRetentionNotes
Event Logs100 entries / 24 hoursPer gateway
Analytics30 daysAggregated data
Health Stats60 daysSuccess/error counts
Billing Events1 year after cancellationFor invoicing

SDK Installation

NPM (Coming Soon)

npm install @anacoic/sdk

CDN (Current)

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

Data Attributes

AttributeDescription
data-gatewayYour gateway ID (required)
data-emqSet to “optimize” to enable EMQ features
data-mcpSet to “true” to enable AI Agent features
data-auto-pageSet to “false” to disable auto PageView

Need help? Contact support