Documentation
Product Analytics API

Product Analytics API

The Altertable Product Analytics API provides direct HTTP access to track events and identify users. For most use cases, we recommend using the JavaScript or React SDKs, which provide a simpler interface and handle session management automatically.

Base URL

All API requests should be made to:

https://api.altertable.ai

Authentication

All API requests require authentication using an API key. Include your API key in the Authorization header:

Authorization: Bearer YOUR_API_KEY

See the Authentication guide for details on obtaining and managing API keys.

Track Events

Endpoint

POST /track

Request Format

{
"event": "Button Clicked",
"properties": {
"button_name": "Sign Up",
"location": "header"
},
"distinct_id": "u_01jza857w4f23s1hf2s61befmw",
"device_id": "device-0197d9df-3c3b-734e-96dd-dfda52b0167c",
"timestamp": "2025-01-15T10:30:00Z"
}

Request Parameters

ParameterTypeRequiredDescription
eventstringYesThe event name
propertiesobjectNoCustom event properties (key-value pairs)
distinct_idstringYesThe distinct ID (user ID or visitor ID)
device_idstringNoThe device ID (persists across sessions)
timestampstring (ISO 8601)NoEvent timestamp (defaults to current time)

Example Request

curl -X POST https://api.altertable.ai/track \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"event": "Purchase Completed",
"properties": {
"product_id": "p_01jza8fr5efvgbxxdd1bwkd0m5",
"amount": 99.99,
"currency": "USD"
},
"distinct_id": "u_01jza857w4f23s1hf2s61befmw"
}'

Response

Success (200 OK):

{
"success": true
}

Error (4xx/5xx):

{
"error": {
"message": "Invalid API key",
"code": "AUTHENTICATION_ERROR"
}
}

Identify Users

Endpoint

POST /identify

Request Format

{
"distinct_id": "u_01jza857w4f23s1hf2s61befmw",
"anonymous_id": "visitor-0197d9df-3c3b-734e-96dd-dfda52b0167c",
"device_id": "device-0197d9df-3c3b-734e-96dd-dfda52b0167c",
"traits": {
"email": "[email protected]",
"name": "John Doe",
"plan": "premium",
"signup_date": "2025-01-01"
}
}

Request Parameters

ParameterTypeRequiredDescription
distinct_idstringYesThe user's unique identifier
anonymous_idstringNoThe previous visitor ID (for linking anonymous events)
device_idstringNoThe device ID (persists across sessions)
traitsobjectNoUser properties (key-value pairs)

Example Request

curl -X POST https://api.altertable.ai/identify \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"distinct_id": "u_01jza857w4f23s1hf2s61befmw",
"traits": {
"email": "[email protected]",
"name": "John Doe",
"company": "Acme Corp",
"plan": "premium"
}
}'

Response

Success (200 OK):

{
"success": true
}

Error (4xx/5xx):

{
"error": {
"message": "Invalid distinct_id format",
"code": "VALIDATION_ERROR"
}
}

Alias Users

Endpoint

POST /alias

Request Format

{
"distinct_id": "u_01jza857w4f23s1hf2s61befmw",
"new_user_id": "new_user_id-019aca6a-1e42-71af-81a0-1e14bbe2ccbd",
"device_id": "device-0197d9df-3c3b-734e-96dd-dfda52b0167c"
}

Request Parameters

ParameterTypeRequiredDescription
distinct_idstringYesThe current user identifier
new_user_idstringYesThe new ID to link to the current identity
device_idstringNoThe device ID

Example Request

curl -X POST https://api.altertable.ai/alias \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"distinct_id": "u_01jza857w4f23s1hf2s61befmw",
"new_user_id": "new_user_id-019aca6a-1e42-71af-81a0-1e14bbe2ccbd"
}'

Response

Success (200 OK):

{
"success": true
}

Error (4xx/5xx):

{
"error": {
"message": "Invalid new_user_id format",
"code": "VALIDATION_ERROR"
}
}

Error Handling

Error Codes

CodeStatusDescription
AUTHENTICATION_ERROR401Invalid or missing API key
VALIDATION_ERROR400Invalid request format or parameters
RATE_LIMIT_ERROR429Too many requests
SERVER_ERROR500Internal server error

Rate Limiting

API requests are rate-limited to prevent abuse. If you exceed the rate limit, you'll receive a 429 Too Many Requests response:

{
"error": {
"message": "Rate limit exceeded",
"code": "RATE_LIMIT_ERROR",
"retry_after": 60
}
}

The retry_after field indicates the number of seconds to wait before retrying.

Retry Logic

For production applications, implement exponential backoff retry logic:

  1. Retry on 429 (rate limit) and 5xx (server errors)
  2. Use exponential backoff: wait 1s, then 2s, then 4s, etc.
  3. Respect the retry_after header when provided
  4. Limit retries to avoid infinite loops

Best Practices

  • Use SDKs when possible: The SDKs handle retries, queuing, and session management automatically
  • Identify users for better tracking: Use the /identify endpoint to set user context, then include distinct_id in subsequent track requests to associate events with users
  • Batch events: When sending multiple events, consider using the SDK's built-in batching
  • Use consistent event names: Use clear, consistent naming conventions for events
  • Validate data: Ensure event properties and user traits are valid JSON
  • Monitor errors: Track API errors and implement appropriate retry logic

Next Steps

Crafted with <3 by former Algolia × Front × Sorare builders© 2025 AltertableTermsPrivacySecurityCookies