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 "tenant-id: your-tenant-id" \
-H "x-virgo-session-id: 123e4567-e89b-12d3-a456-426614174000" \
-H "x-virgo-consent: granted" \
-d '{
"type": "event",
"eventName": "purchase",
"payload": {
"sourceId": "your-source-id",
"title": "Order Confirmed",
"hostname": "www.yourdomain.com",
"url": "https://www.yourdomain.com/order/confirmation",
"timestamp": 1773914400000,
"data": {
"transaction_id": "ORD-20260615-7891",
"value": 214.98,
"currency": "USD",
"items": [
{
"item_id": "SNK-URBAN-10",
"item_name": "UrbanGlide Sneakers",
"price": 134.99,
"quantity": 1
}
]
}
}
}'
import requests
import json
url = "https://analytics.yourdomain.com/collect"
headers = {
"Content-Type": "application/json",
"tenant-id": "your-tenant-id",
"x-virgo-session-id": "123e4567-e89b-12d3-a456-426614174000",
"x-virgo-consent": "granted"
}
data = {
"type": "event",
"eventName": "purchase",
"payload": {
"sourceId": "your-source-id",
"title": "Order Confirmed",
"hostname": "www.yourdomain.com",
"url": "https://www.yourdomain.com/order/confirmation",
"timestamp": 1773914400000,
"data": {
"transaction_id": "ORD-20260615-7891",
"value": 214.98,
"currency": "USD",
"items": [
{
"item_id": "SNK-URBAN-10",
"item_name": "UrbanGlide Sneakers",
"price": 134.99,
"quantity": 1
}
]
}
}
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
const response = await fetch("https://analytics.yourdomain.com/collect", {
method: "POST",
headers: {
"Content-Type": "application/json",
"tenant-id": "your-tenant-id",
"x-virgo-session-id": "123e4567-e89b-12d3-a456-426614174000",
"x-virgo-consent": "granted"
},
body: JSON.stringify({
"type": "event",
"eventName": "purchase",
"payload": {
"sourceId": "your-source-id",
"title": "Order Confirmed",
"hostname": "www.yourdomain.com",
"url": "https://www.yourdomain.com/order/confirmation",
"timestamp": 1773914400000,
"data": {
"transaction_id": "ORD-20260615-7891",
"value": 214.98,
"currency": "USD",
"items": [
{
"item_id": "SNK-URBAN-10",
"item_name": "UrbanGlide Sneakers",
"price": 134.99,
"quantity": 1
}
]
}
}
})
});
const data = await response.json();
console.log(data);
package main
import (
"fmt"
"net/http"
"bytes"
"encoding/json"
)
func main() {
data := []byte(`{
"type": "event",
"eventName": "purchase",
"payload": {
"sourceId": "your-source-id",
"title": "Order Confirmed",
"hostname": "www.yourdomain.com",
"url": "https://www.yourdomain.com/order/confirmation",
"timestamp": 1773914400000,
"data": {
"transaction_id": "ORD-20260615-7891",
"value": 214.98,
"currency": "USD",
"items": [
{
"item_id": "SNK-URBAN-10",
"item_name": "UrbanGlide Sneakers",
"price": 134.99,
"quantity": 1
}
]
}
}
}`)
req, err := http.NewRequest("POST", "https://analytics.yourdomain.com/collect", bytes.NewBuffer(data))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("tenant-id", "your-tenant-id")
req.Header.Set("x-virgo-session-id", "123e4567-e89b-12d3-a456-426614174000")
req.Header.Set("x-virgo-consent", "granted")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println("Response Status:", resp.Status)
}
require 'net/http'
require 'json'
uri = URI('https://analytics.yourdomain.com/collect')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Content-Type'] = 'application/json'
request['tenant-id'] = 'your-tenant-id'
request['x-virgo-session-id'] = '123e4567-e89b-12d3-a456-426614174000'
request['x-virgo-consent'] = 'granted'
request.body = '{
"type": "event",
"eventName": "purchase",
"payload": {
"sourceId": "your-source-id",
"title": "Order Confirmed",
"hostname": "www.yourdomain.com",
"url": "https://www.yourdomain.com/order/confirmation",
"timestamp": 1773914400000,
"data": {
"transaction_id": "ORD-20260615-7891",
"value": 214.98,
"currency": "USD",
"items": [
{
"item_id": "SNK-URBAN-10",
"item_name": "UrbanGlide Sneakers",
"price": 134.99,
"quantity": 1
}
]
}
}
}'
response = http.request(request)
puts response.body
{
"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"
}
{
"error": "Bad Request",
"message": "The request contains invalid parameters or malformed data",
"code": 400,
"details": [
{
"field": "email",
"message": "Invalid email format"
}
]
}
/collect
Target server for requests. Edit to use your own host.
The media type of the request body
Your Tenant ID from Setup in the Dashboard.
Stable UUID for the current app or server session. If omitted, Hardal creates a session ID.
Explicit consent state for this request. granted allows identity processing and denied clears the first-party identity cache. If this header is omitted, Hardal reuses a valid identity cache for the same Tenant ID and Source ID; otherwise it removes userId and visitorId before processing.
Request Preview
Response
Response will appear here after sending the request
Headers
Stable UUID for the current app or server session. If omitted, Hardal creates a session ID.
Explicit consent state for this request. granted allows identity processing and denied clears the first-party identity cache. If this header is omitted, Hardal reuses a valid identity cache for the same Tenant ID and Source ID; otherwise it removes userId and visitorId before processing.
granteddeniedBody
Raw application/json data
Responses
Send events straight to Hardal over HTTP. The reference and live playground below are generated from the API spec, so you can fill in your own values and send a test event to your first-party URL.