Skip to main content
The Datalyr API hands you one workspace’s analytics, attribution, revenue, and workspace data as JSON. Most endpoints read, and a read changes nothing. A small, scoped set of endpoints changes conversion rules and trackable links, or drafts a container script.
Every /v1 endpoint needs an Agent key, with one exception: POST /signup needs no credential at all. See Authentication. Each endpoint that changes something needs a named key carrying that endpoint’s scope. See Agent access.

Read endpoints

Each endpoint has its own page in this section, with the full parameter list and the response schema. None in the last column means the endpoint takes no required parameter. POST /metrics is a read that takes a body, because 50 metric ids do not belong in a query string.

Endpoints that change something

These need a named key carrying the scope in the last column. The original per-workspace Agent key resolves to datalyr:read alone, so it reads every route above and changes none of these. Four rules govern every one of them. A container script is arbitrary JavaScript on every page of your site. That is why POST /scripts/proposals only drafts one: no scope publishes a script, and no endpoint approves one. An owner or admin approves it in the dashboard.

Signup takes no credential

POST /signup is the only route here that needs no key. It sends one verification email and returns {"status": "verification_sent"} for a new address and an existing one alike. Nothing is created until the recipient opens the link. See Agent-driven setup.

Date parameters

Most reporting endpoints take a date range. /realtime, /event-names, /users/{userId}, /workspace, and /usage take none. /retention, /ltv, and /funnel accept a range and fall back to a default when you omit it, so read each endpoint’s own page for its rule. The table below covers the endpoints that require both dates. A missing or unparseable date returns 400 with {"error":"start_date and end_date required (ISO 8601)"}. /commerce-metrics is stricter. Both instants must land on an exact UTC hour. end_date is exclusive, cannot be in the future, and cannot sit more than 366 days after start_date. /ads accepts a second, provider-local form: date_from and date_through as YYYY-MM-DD. A request that sends both forms returns 400.

Response format

Every response is application/json and carries Access-Control-Allow-Origin: *. Every error carries a single error string. /ads, /commerce-metrics, and the cost-import routes add a machine-readable code or reason. See Errors and limits.

Other routes on api.datalyr.com

These four routes sit outside /v1, and each takes a different credential. Two POST routes exist at /v1/shopify/economics/cost-imports/validate and /v1/shopify/economics/cost-imports/apply. We run both of them, so an Agent key on its own returns 403.

Verify your access

  1. Copy your Agent key from Settings → API.
  2. Run the request below in a terminal.
The response names your workspace:

When it doesn’t work

Next