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 "x-hrd-session-id: 123e4567-e89b-12d3-a456-426614174000" \
  -H "x-hrd-consent: granted" \
  -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": "123e4567-e89b-12d3-a456-426614174000",
        "sourceId": "your-source-id"
      }
    ],
    "consentStatus": "granted"
  },
  "timestamp": "2024-12-25T10:00:00Z",
  "path": "/collect",
  "requestId": "example_string"
}
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
x-hrd-session-idstring

Optional UUID shared by events in the same session.

Format: uuid
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

x-hrd-session-idstring

Optional UUID shared by events in the same session.

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 first-party URL, Tenant ID, and Source ID from Setup in the Dashboard.

curl -X POST "https://analytics.yourdomain.com/collect" \
  -H "Content-Type: application/json" \
  -d '{
    "tenantId": "11111111-1111-4111-8111-111111111111",
    "type": "event",
    "eventName": "quote_requested",
    "payload": {
      "sourceId": "22222222-2222-4222-8222-222222222222",
      "timestamp": 1792659600000,
      "data": {
        "plan": "enterprise"
      }
    }
  }'

Replace the example IDs and timestamp with your own values. Send the event time in milliseconds, for example Date.now() in JavaScript.

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. See Consent Signals before sending user identity.

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

Check the result

202 Accepted means Hardal accepted the request for processing. Check the Events report to confirm your event appears.

For 400 Bad Request, check the required fields, UUIDs, and JSON format. The response includes error details.