Skip to content
Denne side findes på dansk. Læs på dansk
HeyMySocial

Send events from your server

Report leads, status changes, sales and refunds from your own server: the event body, the API call with a key, the signed webhook, duplicates and corrections.

A browser can report a visit and a lead. Everything that happens afterwards (the first call, a qualification, a quote, a sale, a refund) is known to your server or your CRM, and comes in through one of two doors that take the same event:

Door Authentication Use it for
POST https://heymysocial.com/api/v1/events An API key with the scope events:write A CRM, a shop or a script that reports for the whole workspace
POST https://heymysocial.com/hooks/hms_pk_… A signature made with one tracking site's signing secret A form or calculator that belongs to one website

The workspace is decided by the key or by the site. A workspace id in the body is never read.

The event

Field Needed What it is
event_id Yes Your id for this event: up to 96 printable characters without spaces. Sending it again is safe
type Yes One of the event types
occurred_at Yes When it happened, as a date and time (ISO 8601). Kept as sent. Not more than a day in the future
external_id No Your id for the lead (lead_created), the sale (sale_won) or the refund (sale_refunded). The same id is the same record. Up to 191 characters
lead_external_id, lead_id For most types Your id of the lead the event is about, or ours. Every type except lead_created and the visit types needs one of them. Your id is looked up among leads from the same source first, then among all leads when exactly one has it
source No Through the API: api (the default), crm or website. Through the webhook it is always webhook: leave the field out
consent_state No granted, denied, unknown (the default) or not_applicable. See consent modes
campaign_ref No The campaign's opaque reference code, when you know it. Leave it out when you do not
ad_ref, creative_ref No Your own references to an ad and a creative, up to 191 characters each
session_id No The script's session key, only when the visitor consented
corrects_event_id No Makes this event a correction of an earlier event_id
test No true stores the event and creates nothing
schema_version No 1
properties By type See below. At most 16 KB as JSON

Properties by type

Type Properties
lead_created contact with name, email, phone, company (at least a name, an email address or a phone number); form with the form's answers (up to 40); hms_ref or tracking_link to tie it to a tracked link; contact_consent and contact_consent_source
sale_won, sale_refunded amount in major units or amount_minor; currency as three letters (the workspace's currency when left out). A sale also takes revenue_basis: booked (the default), invoiced or collected, and verification_source: manual, crm or invoice. Only a sale on the booked basis counts as revenue in results. A refund names its sale with sale_external_id or sale_id
lead_disqualified, sale_lost reason
opportunity_created, quote_sent name, estimated_value or estimated_value_minor, currency
appointment_booked title, starts_at

Contact details and form answers reach the contact and the lead. They are not stored in the event log.

Send with an API key

Create a key under API keys with the scope events:write and send it as a bearer token:

curl -X POST https://heymysocial.com/api/v1/events \
  -H "Authorization: Bearer $HMS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "event_id": "form-2026-0412",
    "type": "lead_created",
    "occurred_at": "2026-04-12T09:30:00+02:00",
    "external_id": "lead-8841",
    "consent_state": "not_applicable",
    "properties": {
      "contact": { "name": "Test Person", "email": "test.person@example.com", "phone": "+45 55 55 01 00" },
      "form": { "message": "Please call me about the spring offer." }
    }
  }'

A new event is answered with 202, one seen before with 200:

{
  "status": "accepted",
  "event_id": "01jc3vb2m8q4x6y7z9w0t1r2s3",
  "lead_id": "01jc3vb2n5p8r0s2t4v6w8x0y2"
}

Later events name the lead by your own id. Up to 100 events fit in one request:

curl -X POST https://heymysocial.com/api/v1/events \
  -H "Authorization: Bearer $HMS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "events": [
      {
        "event_id": "lead-8841-qualified",
        "type": "lead_qualified",
        "occurred_at": "2026-04-14T10:05:00+02:00",
        "lead_external_id": "lead-8841"
      },
      {
        "event_id": "invoice-20417",
        "type": "sale_won",
        "occurred_at": "2026-04-28T14:00:00+02:00",
        "external_id": "invoice-20417",
        "lead_external_id": "lead-8841",
        "properties": { "amount": 18500, "currency": "DKK", "revenue_basis": "invoiced", "verification_source": "invoice" }
      }
    ]
  }'

A batch is always answered with 200 and one result per event, in the order sent:

{
  "accepted": 2,
  "duplicates": 0,
  "rejected": 0,
  "results": [
    { "status": "accepted", "event_id": "01jc3vb5k2m4p6r8t0v2x4z6b8", "lead_id": "01jc3vb2n5p8r0s2t4v6w8x0y2" },
    { "status": "accepted", "event_id": "01jc3vb5k9n1q3s5v7w9y1a3c5", "lead_id": "01jc3vb2n5p8r0s2t4v6w8x0y2", "sale_id": "01jc3vb5m4p6r8t0v2x4z6b8d0" }
  ]
}
Status Code When
401 unauthenticated The key is missing or not valid
403 access_denied The key lacks events:write
422 validation_failed A single event is not valid (details names the fields), or events is not a list of 1 to 100
429 rate_limited More than 600 requests a minute from one address, or 120 a minute for the key

The operation is ingest-events in the API reference.

Send with a signed webhook

The address is on the site's page: Funnels, Websites and forms, Install and test. The signing secret is shown there once, when the site is created or the secret is rotated. Sign the exact bytes you send:

  1. Take the current Unix time in seconds as the timestamp.
  2. Compute HMAC-SHA256 over the timestamp, a dot and the raw request body, with the signing secret as the key, and write it as hexadecimal.
  3. Send X-HMS-Signature: t=<timestamp>,v1=<signature>.
BODY='{"event_id":"form-2026-0412","type":"lead_created","occurred_at":"2026-04-12T09:30:00+02:00","external_id":"lead-8841","consent_state":"not_applicable","properties":{"contact":{"name":"Test Person","email":"test.person@example.com"}}}'
TS=$(date +%s)
SIG=$(printf '%s.%s' "$TS" "$BODY" | openssl dgst -sha256 -hmac "$HMS_SIGNING_SECRET" | sed 's/^.* //')

curl -X POST "https://heymysocial.com/hooks/hms_pk_…" \
  -H "Content-Type: application/json" \
  -H "X-HMS-Signature: t=$TS,v1=$SIG" \
  --data "$BODY"
<?php

$body = json_encode([
    'event_id' => 'form-2026-0412',
    'type' => 'lead_created',
    'occurred_at' => '2026-04-12T09:30:00+02:00',
    'external_id' => 'lead-8841',
    'consent_state' => 'not_applicable',
    'properties' => ['contact' => ['name' => 'Test Person', 'email' => 'test.person@example.com']],
]);
$timestamp = time();
$signature = hash_hmac('sha256', $timestamp.'.'.$body, getenv('HMS_SIGNING_SECRET'));

$request = curl_init('https://heymysocial.com/hooks/hms_pk_…');
curl_setopt_array($request, [
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => $body,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => ['Content-Type: application/json', "X-HMS-Signature: t={$timestamp},v1={$signature}"],
]);
echo curl_exec($request);
const crypto = require('node:crypto');

const body = JSON.stringify({
  event_id: 'form-2026-0412',
  type: 'lead_created',
  occurred_at: '2026-04-12T09:30:00+02:00',
  external_id: 'lead-8841',
  consent_state: 'not_applicable',
  properties: { contact: { name: 'Test Person', email: 'test.person@example.com' } },
});
const timestamp = Math.floor(Date.now() / 1000);
const signature = crypto
  .createHmac('sha256', process.env.HMS_SIGNING_SECRET)
  .update(`${timestamp}.${body}`)
  .digest('hex');

fetch('https://heymysocial.com/hooks/hms_pk_…', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json', 'X-HMS-Signature': `t=${timestamp},v1=${signature}` },
  body,
}).then((response) => response.json()).then(console.log);

The body is one event, or {"events": [...]} with 1 to 100 events, and at most 256 KB. The answer lists what became of each:

{
  "received": 1,
  "results": [
    { "status": "accepted", "event_id": "01jc3vb2m8q4x6y7z9w0t1r2s3", "lead_id": "01jc3vb2n5p8r0s2t4v6w8x0y2" }
  ]
}
Status Code When
200 At least one event was accepted or recognized as a duplicate
401 unauthenticated The signature does not match, or the timestamp is more than 5 minutes from the server's clock
404 not_found The key is unknown, or the site is paused
409 duplicate This exact request, with the same timestamp and signature, was received before. Sign a retry afresh
413 validation_failed The body is too large
422 validation_failed The body is not readable, or every event in it was rejected

A request whose signature is valid is written down before it is processed. Its body is kept for 14 days with personal details removed. A request refused for its signature, its timestamp or as a repeat is recorded without its body. Both show under Latest webhook deliveries on the site's page. The tracking webhook page has the full detail.

Duplicates and retries

An event is the same event when it has the same source and event_id, or the same source, type and external_id. A repeat is answered with the status duplicate and the ids of the first result, and changes nothing. So a retry after a timeout is always safe, as long as it carries the same event_id.

The source is part of the identity. The same event_id sent through the webhook and through the API is two events.

Corrections

Events are never edited. To change one, send a new event with corrects_event_id set to the event_id of the original:

{
  "event_id": "invoice-20417-corrected",
  "type": "sale_won",
  "occurred_at": "2026-04-29T09:00:00+02:00",
  "corrects_event_id": "invoice-20417",
  "lead_external_id": "lead-8841",
  "properties": { "amount": 17500 }
}

A corrected sale_won changes the amount of the sale. A corrected status event moves the lead to that status and records it as a correction with a reason. A refund is its own event:

{
  "event_id": "credit-note-311",
  "type": "sale_refunded",
  "occurred_at": "2026-05-06T11:20:00+02:00",
  "external_id": "credit-note-311",
  "lead_external_id": "lead-8841",
  "properties": { "amount": 2500, "sale_external_id": "invoice-20417" }
}

When a refund names no sale, or one that is not known, and the lead has exactly one sale, that sale is used.

Status reports only move forward

A reported status may skip steps forward, never backward. A lead_contacted that arrives after the lead was qualified changes no status; it still fills in the time of first contact when that was missing or later. See lead statuses.

Warnings

An accepted event can carry a warning. The event is stored, and for the first three the matter is listed under Items to review on the Funnels screen:

Warning Meaning
unmatched_lead The lead it names is not known yet. The event is applied when that lead arrives
unmatched_sale The sale a refund or a correction names is not known
not_applied The event could not be applied to the lead as it stands
won_without_sale A lead was stated as won without a sale. It is kept as an opportunity until the sale arrives

A campaign_ref that matches no campaign does not stop the lead: it is created and the reference is listed for review.

Limits

WhatLimitCounted per
REST API120 requests a minuteAPI key
Event ingestion and webhooks600 requests a minuteTracking site and sender address
Assistant connector90 requests a minuteSigned-in person
Public forms10 requests a minuteVisitor address

Accepted events count toward the plan's tracked events for the month, and going over the allowance never blocks an event. Test events are not counted.