Getting StartedUse the Analytics API

Use the Analytics API

Read your first report and reuse Hardal analytics in scripts and integrations.

Use the Analytics API to retrieve existing Hardal reports for your own dashboards, scheduled reporting scripts, or analysis workflows. Access is read-only and limited to the tenants approved for the credential.

To collect new data, use Send Events or Send Agent Events. An Analytics API key is not a collection credential.

1. Create an API key

Follow Get an API Key. Select only the tenants your integration needs and save the key in a server-side secret or environment variable.

Do not put the key in browser JavaScript, mobile code, URLs, or public repositories.

2. Find your tenant and source

Set HARDAL_API_KEY to your saved key and run this in your terminal.

curl --fail-with-body "https://api.hardal.ai/v1/workspace/access" \
  --header "Authorization: Bearer ${HARDAL_API_KEY:?Set HARDAL_API_KEY}"

To use the browser instead, open Workspace Access and choose Try it. Enter your key in Bearer Token. Clear both optional pagination fields before sending your first request. If you need another page, use numbers such as limit=50&offset=0.

A successful call returns HTTP 200 and success: true. Find the tenant by name under its organization. Set HARDAL_TENANT_ID to that tenant's id for the next request. If the list is empty, ask the key owner to check access to the active tenant.

The response contains:

FieldUse
data.tenants[].idThe tenantId used in a report request
data.tenants[].organizationThe organization owning that tenant
data.tenants[].sourcesSource IDs and names available in the tenant
meta.hasNextWhether more tenants follow; increase offset by limit to request the next page

Omit sourceId to include all sources in a tenant. sourceId identifies a collection source; a marketing source filter such as google is a different field.

3. Read Overview

Open Overview. Set:

ParameterExample
tenantIdA tenant UUID from Workspace Access
timeframelast7days
timezoneEurope/Istanbul
intervalday

Send the request. A successful response has success: true; data contains the report, including scoreCards and timeSeries. A valid empty report does not mean authentication failed.

The Reports API base URL is https://api.hardal.ai. Use the same key and tenant UUID as in step 2.

curl --fail-with-body --get "https://api.hardal.ai/v1/reports/overview" \
  --header "Authorization: Bearer ${HARDAL_API_KEY}" \
  --data-urlencode "tenantId=${HARDAL_TENANT_ID}" \
  --data-urlencode "timeframe=last7days" \
  --data-urlencode "timezone=Europe/Istanbul" \
  --data-urlencode "interval=day"

For a completed week, use timeframe=custom and explicit inclusive startDate and endDate values in YYYY-MM-DD format. Presets can include the current, incomplete day.

Start another report

Start a GET request with only its required inputs. For example, use the tenant from step 2 to retrieve page metrics:

curl --fail-with-body --get "https://api.hardal.ai/v1/reports/pages/metrics" \
  --header "Authorization: Bearer ${HARDAL_API_KEY:?Set HARDAL_API_KEY}" \
  --data-urlencode "tenantId=${HARDAL_TENANT_ID:?Set HARDAL_TENANT_ID}" \
  --data-urlencode "timeframe=today"

A successful response includes success: true and a data object. Add optional filters one at a time. When a generated example contains example_string, omit optional parameters until you have a real filter value.

OperationAdditional input for a first request
AI filter optionsSet dimension=agentType to list available agent types.
Saved funnelList funnels and use a returned funnel ID in the path. If the list is empty, save a funnel in the Dashboard first.
Page time seriesSend POST with the tenant in the query and JSON {"pagePaths":["/pricing"]} in the body. Replace the path with a page you track.

4. Use the result

A weekly reporting script can request a fixed date range, read data.scoreCards, and write those values to your own report or spreadsheet. Run that script in your own scheduler; retrieving a report does not create a scheduled job in Hardal.

Choose another endpoint when the question changes:

GoalStart with
Compare channels and campaignsAcquisition
Analyze salesCommerce Overview
Analyze event totalsEvent Overview
Review AI agent activityAI Visibility

These are report endpoints, not an unrestricted raw-data export. Check each operation's response, pagination, and supported filters before building an integration.

Commerce Overview can return data.consentBreakdown. The consented and deniedOrUnknown groups show order counts and revenue in the reporting currency. An unavailable revenue value appears as null.

Use daily to read the breakdown by date. When daily is empty, use the totals for the selected period. See the OpenAPI specification for a response example.

Match the Dashboard

Use the same tenant, source, dates, timezone, and supported report configuration. For Acquisition, also match conversion events, attribution model, lookback window, and traffic scope. Do not assume every report uses the same filters or default timeframe.

Handle responses

StatusNext step
400Read the validation details and correct the request parameters
401Check the Bearer token. For session-cookie-not-accepted, send the request from a client without the Dashboard session cookie. Replace expired or revoked credentials
403Check the selected tenant and source against the credential's approved access
429Respect Retry-After before retrying

Keep the response requestId when asking support to investigate a failed request. Never include the API key in the support message.