API Reference
Complete reference for Anacoic’s REST API and SDK methods.
Base URLs
| Environment | URL |
|---|
| Edge (Tracking) | https://edge.anacoic.com |
| Web App | https://anacoic.com |
| Custom Domain | https://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"
}
}'
| Header | Required | Description |
|---|
Content-Type | Yes | Must be application/json |
X-Gateway-ID | Yes* | Your gateway ID (*or use ?gid= query param) |
Request Body
| Field | Type | Required | Description |
|---|
event_name | string | Yes | Event name (e.g., “Purchase”, “AddToCart”) |
event_id | string | Recommended | Unique ID for deduplication |
timestamp | number | No | Unix timestamp (seconds). Defaults to now. |
user | object | No | User identifiers (see below) |
custom_data | object | No | Event-specific data |
User Object
| Field | Type | EMQ Impact | Description |
|---|
email | string | +2.5 pts | Email address (auto-hashed) |
phone | string | +2.0 pts | Phone in E.164 format (auto-hashed) |
external_id | string | +1.0 pt | Your internal user ID (auto-hashed) |
fbp | string | +1.5 pts | Facebook Browser ID (auto-captured) |
fbc | string | +1.5 pts | Facebook Click ID (auto-captured) |
client_ip_address | string | +0.5 pts | Auto-extracted if not provided |
client_user_agent | string | +0.3 pts | Auto-extracted if not provided |
Custom Data
Common fields for e-commerce:
| Field | Type | Description |
|---|
value | number | Monetary value |
currency | string | ISO 4217 currency code |
transaction_id | string | Unique order/transaction ID |
content_name | string | Product/content name |
content_type | string | ”product”, “article”, etc. |
content_ids | array | Array of product IDs |
num_items | number | Number 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
| Method | Description |
|---|
initialize | Initialize MCP connection |
resources/list | List available resources |
resources/read | Read a specific resource |
tools/list | List available tools |
tools/call | Execute a tool |
Resources
| URI | Description |
|---|
pricing://current | Pricing tiers as JSON |
docs://primary | Documentation URL |
system://hint | Anti-hallucination instructions |
| Tool | Parameters | Description |
|---|
book_demo | name, 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
| Action | Description |
|---|
getGatewaysForOrg(orgId) | List organization’s gateways |
addGateway(data) | Create new gateway |
getGatewayAnalytics(gatewayId) | Get 30-day analytics |
Agent Manifest
| Action | Description |
|---|
getAgentManifest(gatewayId) | Get MCP configuration |
saveAgentManifest(gatewayId, data) | Update MCP configuration |
Rate Limits
| Endpoint | Limit | Window |
|---|
POST /track | 100 requests | 60 seconds per gateway |
GET /v1/mcp/sse | 10 connections | Per IP |
| Dashboard API | 1000 requests | 60 seconds per user |
Error Codes
| Code | Meaning | Resolution |
|---|
| 200 | Success | — |
| 400 | Bad Request | Check JSON syntax |
| 403 | Forbidden | Check allowed origins |
| 404 | Gateway Not Found | Verify gateway ID |
| 429 | Rate Limited | Wait and retry |
| 502 | All Providers Failed | Check integrations config |
Data Retention
| Data Type | Retention | Notes |
|---|
| Event Logs | 100 entries / 24 hours | Per gateway |
| Analytics | 30 days | Aggregated data |
| Health Stats | 60 days | Success/error counts |
| Billing Events | 1 year after cancellation | For 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
| Attribute | Description |
|---|
data-gateway | Your gateway ID (required) |
data-emq | Set to “optimize” to enable EMQ features |
data-mcp | Set to “true” to enable AI Agent features |
data-auto-page | Set to “false” to disable auto PageView |
Need help? Contact support