Send EventsPOST /collect

Send Events

Send events to Hardal with an HTTP POST to the /collect endpoint.

curl -X POST "https://analytics.yourdomain.com/collect" \
  -H "Content-Type: application/json" \
  -H "User-Agent: YOUR_CLIENT_USER_AGENT" \
  -H "x-hrd-session-id: 123e4567-e89b-12d3-a456-426614174000" \
  -H "x-hrd-consent: denied" \
  -H "X-Forwarded-For: example_string" \
  -d '{
  "tenantId": "11111111-1111-4111-8111-111111111111",
  "type": "event",
  "eventName": "quote_requested",
  "payload": {
    "sourceId": "22222222-2222-4222-8222-222222222222",
    "title": "Request a Quote",
    "hostname": "www.yourdomain.com",
    "url": "https://www.yourdomain.com/quote",
    "timestamp": 1773914400000,
    "data": {
      "plan": "enterprise",
      "seats": 250,
      "region": "EMEA"
    }
  }
}'
{
  "success": true,
  "data": {
    "accepted": 1,
    "events": [
      {
        "eventId": "44444444-4444-4444-8444-444444444444",
        "sourceId": "22222222-2222-4222-8222-222222222222"
      }
    ],
    "consentStatus": "denied"
  },
  "timestamp": "2026-11-24T12:00:00.000Z",
  "path": "/collect/",
  "requestId": "33333333-3333-4333-8333-333333333333"
}
POST
/collect
POST
Base URLstring

Target server for requests. Edit to use your own host.

Content-Typestring
Required

The media type of the request body

Options: application/json
header
User-Agentstring
Required

Send the client or application's User-Agent. Requests with a missing, blank, or bot-like value can be skipped.

header
x-hrd-session-idstring

Optional UUID shared by events in the same session.

Format: uuid
header
X-Forwarded-Forstring

Original client IP from trusted request context when consent is granted. Hardal uses the first address for location. Omit the header if consent is declined or unknown, or if the client IP is unavailable.

tenantIdstring
Required

Your Tenant ID from Setup in the Dashboard. Send it in the JSON body.

Format: uuid
anonymousSessionIdstring

Optional session UUID. You can use x-hrd-session-id instead.

Format: uuid
consentStatusstring

Consent state: granted or denied. You can use x-hrd-consent instead.

Options: granted, denied
typestring

Use event for standard and custom actions, or page_view for a page visit.

Min length: 1
eventNamestring

The action name, such as purchase, quote_requested or page_view.

Min length: 1
eventsarray

Send multiple events in this array instead of the single-event fields.

Request Preview
Response

Response will appear here after sending the request

Headers

User-Agentstring
Required

Send the client or application's User-Agent. Requests with a missing, blank, or bot-like value can be skipped.

Example:
YOUR_CLIENT_USER_AGENT
x-hrd-session-idstring

Optional UUID shared by events in the same session.

X-Forwarded-Forstring

Original client IP from trusted request context when consent is granted. Hardal uses the first address for location. Omit the header if consent is declined or unknown, or if the client IP is unavailable.

Body

application/json
tenantIdstring
Required

Your Tenant ID from Setup in the Dashboard. Send it in the JSON body.

Example:
11111111-1111-4111-8111-111111111111
anonymousSessionIdstring

Optional session UUID. You can use x-hrd-session-id instead.

Example:
33333333-3333-4333-8333-333333333333
consentStatusstring

Consent state: granted or denied. You can use x-hrd-consent instead.

Allowed values:granteddenied
typestring

Use event for standard and custom actions, or page_view for a page visit.

Example:
event
eventNamestring

The action name, such as purchase, quote_requested or page_view.

Example:
purchase
payloadobject
eventsarray

Send multiple events in this array instead of the single-event fields.

Responses

Send an event

Use your collection URL, Tenant ID, and Source ID from Setup in the Dashboard. For cURL, set USER_AGENT to the user agent of the actual sender. When forwarding a browser request, use the original browser user agent.

EVENT_TIME_MS=$(($(date +%s) * 1000))
curl --fail-with-body -X POST "https://analytics.yourdomain.com/collect" \
  -H "Content-Type: application/json" \
  -H "User-Agent: ${USER_AGENT:?Set USER_AGENT for the request}" \
  -H "x-hrd-consent: denied" \
  --data-binary @- <<JSON
  {
    "tenantId": "11111111-1111-4111-8111-111111111111",
    "type": "event",
    "eventName": "quote_requested",
    "payload": {
      "sourceId": "22222222-2222-4222-8222-222222222222",
      "timestamp": $EVENT_TIME_MS,
      "data": {
        "plan": "enterprise"
      }
    }
  }
JSON

Replace the example IDs with the values from your source. The example timestamps a new test event. For a queued or retried event, keep its original occurrence time in milliseconds.

Build the body

FieldRequiredWhat to send
tenantIdYesYour Tenant ID (UUID), in the JSON body.
typeYesUse event for standard and custom actions. For a page visit, use page_view.
eventNameYesThe action name, such as purchase, quote_requested, or page_view.
payload.sourceIdYesYour Source ID (UUID).
payload.timestampYesEvent time as a Unix timestamp in milliseconds.
payload.dataNoParameters for the event, such as plan, value, or items.

type describes the kind of event; eventName describes the action. Keep event parameters inside payload.data.

For page visits, include payload.url with its query parameters and payload.referrer when available. For purchases and other standard events, use the parameters in Standard Events. You can also send Custom Events.

To send several events together, use an events array with type, eventName, and payload in each entry. Keep tenantId at the top level.

Optional headers

  • x-hrd-session-id: a UUID shared by events in the same session.
  • x-hrd-consent: granted or denied. Send denied if consent is declined or unknown in a server integration. See Consent Signals.
  • X-Forwarded-For: the original client IP from your trusted proxy or request context when consent is granted. Hardal uses the first IP in the header.

To link events to a known user, follow Identify Visitors.

Check the result

For this single event, expect HTTP 202 and data.accepted: 1. Check the returned event ID and confirm the event in Engagement → Events. If the response contains data.skipped: true, check that the request includes the client's or application's User-Agent.

For 400 Bad Request, read the response details. In addition to the required fields and UUIDs, check event-specific parameters:

EventFields to check
scroll_depthSend a numeric payload.data.percent of 25, 50, 75, 90, or 100.
outbound_clickInclude the originating page's absolute payload.url, an absolute payload.data.linkUrl, and the matching hostname in payload.data.linkDomain.

After correcting the request, verify the event in the Dashboard.