HeadlessAnalytics Documentation
HeadlessAnalytics is the API-first operating intelligence layer for agentic companies. It tracks what happens across digital products, physical identifiers, enterprise systems, AI agents, workflows, campaigns, decisions, proofs, and outcomes, then makes that intelligence available to agents and operators through API, SDK, CLI, MCP, webhooks, OpenAPI, exports, and optional dashboards.
API
Ingest events, generate trackables, query metrics, enforce actions, and export proof trails over HTTP.
CLI
Use `ha` from CI, scripts, agent shells, local operators, and enterprise automation runners.
MCP
Give agents tools for tracking, querying, recommending, enforcing, and exporting intelligence.
SDKs
Use TypeScript, JavaScript, Python, Go, Ruby, OpenAI tools, LangChain, LlamaIndex, and AutoGPT hooks.
Operating Intelligence Model
A normal analytics platform asks what happened. HeadlessAnalytics asks what happened, what it changed in the operating graph, what an agent should know next, whether a recommendation is consequential, and what proof should be generated.
Workspace
The tenancy boundary for keys, events, entities, dashboards, connectors, decisions, proof trails, and exports.
Business
A graph node representing a company, brand, client, location, product line, or operating unit. Every workspace has a default business.
Event
The atomic fact: something happened, caused by an actor, against an object, in a source/context, with properties and outcomes.
Trackable
A generated or external identifier for QR codes, barcodes, RFID tags, sensors, robots, agents, MCP servers, and CLI workflows.
Operating Graph
Events become entities, relationships, attribution touchpoints, agent runs, workflow runs, decisions, receipts, proofs, and outcomes.
Full Hypervisor
The governance layer for consequential actions: DecisionObject, AuthorityGrant, ContextContract, attestation, receipt, and proof.
Quickstart
Use the API directly, or configure the SDK, CLI, and MCP server around the same API key. The dashboard is useful for setup and operations, but it is not required for daily execution.
curl -X POST https://api.headlessanalytics.com/api/ingest \
-H "Authorization: Bearer ha_live_..." \
-H "Content-Type: application/json" \
-d '{
"event": "qr.bottle_scanned",
"actor": { "type": "customer", "id": "anon_123" },
"object": { "type": "product", "id": "olive-oil-500ml" },
"source": { "channel": "qr", "campaign": "spring-launch" },
"properties": { "sku": "olive-oil-500ml", "lot": "L2026-04" }
}'End-to-End Flow
A DTC brand ships 10,000 bags of single-origin coffee, each with a QR code. Their growth agent provisions the tracking plan, generates identifiers, and begins operating. No dashboard. No manual setup. The agent seeds, tracks, queries, decides, enforces, and exports — entirely headlessly.
ha tracking-plan-create '{"name":"Roast & Origin","vertical":"dtc_commerce_ops"}'
ha create-trackable qr_code "Ethiopia Single-Origin Bag" https://roastandorigin.com/ethiopia
ha use ethiopia-bag-001 qr_scan '{"sku":"ETH-250G","lot":"L2026-04","campaign":"spring-launch"}'
ha track order.created '{"revenue":22,"source":"bag_qr","campaign":"spring-launch"}'
ha agent-context recommend_next_actions '{"businessId":"default","limit":250}'
ha graphql 'query Ops { businessHealth { healthScore revenue nextActions } attribution { bySource byCampaign } }'
ha decision-create campaign.scale '{"status":"approved","risk":"medium"}'
ha enforce '{"action":"campaign.scale","amount":500,"currency":"USD"}' '{"decisionObjectId":"..."}'
ha proof-export '{"title":"Campaign scale proof","receiptIds":["..."]}'What To Track
Track every event that changes state, creates context, influences revenue, modifies risk, or helps an agent decide what should happen next.
QR Codes, Barcodes, RFID, Sensors, And Robotics
Trackables let enterprises generate and observe identifiers that exist outside your website. A QR code on a bottle, an RFID tag in a warehouse, a barcode on packaging, a sensor ping, a robot action, and an MCP tool call can all become first-class events in the same operating graph.
ha create-trackable qr_code "Single-Origin Coffee Bag" https://roastandorigin.com/ethiopia
ha use ethiopia-bag-001 qr_scan '{"sku":"ETH-250G","lot":"L2026-04"}'
ha metric-query '{"eventName":"qr.bag_scanned","limit":500}'MCP For Agentic Work
The MCP server gives agents governed tools for tracking, querying metrics, reading business health, getting agent context, querying GraphQL, checking usage, recommending actions, creating decisions, enforcing actions, and exporting proof trails.
{
"mcpServers": {
"headlessanalytics": {
"command": "npx",
"args": ["-y", "@headlessanalytics/mcp"],
"env": {
"HA_API_KEY": "ha_live_...",
"HA_API_URL": "https://api.headlessanalytics.com"
}
}
}
}CLI
The CLI is built for operators, CI jobs, local scripts, and agent shells. It can generate trackables, query intelligence, process alerts, pull connectors, enforce actions, and export packets.
ha health default
ha usage
ha agent-context recommend_next_actions '{"limit":250}'
ha graphql 'query Ops { businessHealth { healthScore revenue nextActions } }'
ha funnel-query '[{"name":"Scan","event":"qr.bottle_scanned"},{"name":"Order","event":"order.created"}]'
ha decision-create campaign.scale '{"status":"approved","risk":"medium"}'
ha enforce '{"action":"campaign.scale","amount":500}' '{"decisionObjectId":"..."}'
ha destination-export bigquery '{"limit":500,"config":{"projectId":"analytics-prod","datasetId":"ha","tableId":"events"}}'SDKs And Agent Frameworks
First-party clients are available for TypeScript/JavaScript, Python, Go, and Ruby. The TypeScript SDK also exposes OpenAI tool schemas and dependency-free LangChain, LlamaIndex, and AutoGPT hooks.
const ha = new HeadlessAnalytics({ writeKey: process.env.HA_API_KEY! });
await ha.track("order.created", { properties: { revenue: 149 } });
const health = await ha.getBusinessHealth("default");
const usage = await ha.getApiUsage();
const tools = ha.openAITools();
const callbacks = [ha.langChainCallbackHandler({ agentId: "growth-agent" })];Enterprise Connectors
Connector ingestion normalizes external records into events, entities, attribution, sync records, and health state. Supported providers include Salesforce, HubSpot, Shopify, Stripe, Amazon, Walmart, QuickBooks, Xero, NetSuite, Google Ads, Meta Ads, GA4, Resend, YouTube, Twitch, Discord, TikTok, Roblox, Fortnite, ServiceNow, Jira, Asana, Linear, Procore, ServiceTitan, Fieldwire, QR.io, RFID, sensors, robotics, and generic records.
Full Hypervisor Governance
Analytics can recommend actions, but consequential execution should route through governance. The enforcement flow validates API access, DecisionObject state, authority grants, context contracts, trust tier, compliance mapping, and attestation evidence before returning `allow`, `deny`, `escrow`, or `needs_human_approval`.
DecisionObject
AuthorityGrant
ContextContract
EnforcementReceipt
Exports And Destinations
Export bounded operating graphs, proof trails, or event batches to GraphNative, SovereignProof, Snowflake, BigQuery, Redshift, S3, GCS, or custom HTTPS endpoints. Every external push records a receipt with destination, status, request ID, response status, external ID, error, and payload hash.
Acceptance Stories
Marco, DTC brand operator
Every bottle carries a QR code. Every scan feeds attribution. Every order traces back to a campaign. His agents optimize spend, flag anomalies, and route scale decisions through governance — all without Marco logging into a dashboard.
Loic, creator game studio
Asset launches across Roblox and Fortnite. YouTube performance. Merch drops. Streaming spikes. His copilot reads the operating graph, recommends when to promote, and exports proof trails when partner royalties are due.
Ryan, electrical contractor
Leads become takeoffs. Takeoffs become scheduled jobs. Jobs track crews, inventory, and field photos. When a job runs over, his hypervisor flags it before the invoice goes out — and routes the replan through governed approval.
Endpoint Map
| POST | /api/ingest | Canonical event ingestion. |
| POST | /api/trackables | Create QR, barcode, RFID, sensor, robot, agent, MCP, or CLI identifiers. |
| POST | /api/track | Record a generated trackable usage event. |
| POST | /api/connectors/ingest | Normalize records from enterprise systems into the event graph. |
| POST | /api/metrics/query | Query metric definitions and recent event counts. |
| POST | /api/graphql | Query the flexible GraphQL-compatible headless data surface. |
| POST | /api/intelligence/agent-context | Return agent-readable changes, anomalies, proof gaps, and next actions. |
| POST | /api/funnels/query | Calculate conversion and workflow progression. |
| POST | /api/attribution/query | Read attribution touchpoints by source, channel, campaign, and entity. |
| GET | /api/businesses/{id}/health | Fetch operating health and recommendations. |
| GET | /api/usage | Fetch API usage metering for billing, quotas, agents, and connectors. |
| GET | /api/health | Check production environment readiness without exposing secrets. |
| POST | /api/governance/enforce | Ask the Full Hypervisor for allow, deny, escrow, or approval. |
| POST | /api/exports/destinations | Export records to warehouses, data lakes, or custom HTTPS destinations. |
The machine-readable OpenAPI document is available at GET /api/openapi.