# Receive identified visitors by webhook

**The integration most people should build first.** A webhook tells you the
moment someone is identified, instead of you asking us every few minutes
whether anything happened.

Everything below is the contract the service actually implements. Where a
number appears, it is read from the code that enforces it.

---

## Before you start

- You need a **registered endpoint**. Nothing is delivered until one exists,
  and registration is **not** on the public `/signal-api/v1` surface — it is a
  dashboard action, because it mints a secret. Go to **Exports & API →
  Webhooks → Add endpoint**, or ask the assistant ("register a webhook at
  https://…").
- You need its **signing secret** (`whsec_…`), returned at registration and
  **shown exactly once**. Store it as `SIGNAL_WEBHOOK_SECRET`; both examples
  below read it from there. Lose it and you rotate rather than recover it.
- You need the **pixel live**, or nothing will ever be identified to send. The
  [quickstart](../quickstart.md) covers install and verification.

If you are reading this page first, registration is the one step you cannot do
from code.

**The URL must be `https://` and must reach a public address.** The payload
carries people's email addresses, so it never travels in clear. A URL whose
host is `localhost`, a name without a dot, a `.local` or `.internal` name, or
any address that is loopback, private (RFC 1918), link-local, or an IPv6
equivalent is refused with the reason. The check runs at registration **and
again before every delivery**, because DNS can change: an endpoint whose name
later resolves to a private address stops receiving events, and each refused
attempt counts as a failed delivery.

**Excluded people are never sent.** Someone whose status is `excluded` —
their own, or their company's — gets no `signal.visitor_identified` event.
Marking someone excluded after they were sent does not recall that event.

**People who asked to be deleted are never sent.** If any address we hold for
a person (their own, or a work email we found for them) is on the deletion
list, no event is built for them. A delivery already queued for a retry stops,
with the reason recorded. As with exclusion, a request made after an event was
delivered does not recall that event.

**The free plan's allowance applies, as on the dashboard.** On the free plan,
a person beyond the first 150 identified that month still produces an event,
but with `"revealed": false` and `data.person.email`, `name` and `title` all
`null`. If their company is known only through people beyond the allowance,
`data.company.domain`, `domain_canonical`, `name` and `firmographics` are
`null` too. That `null` is the plan, not missing data: do not record such a
person as "no email". An upgrade does not re-send events already delivered.
Paid and trialling plans always receive `"revealed": true`. See the
[guide's allowance section](../guide.md#5-the-free-plans-monthly-allowance).

**Every person carries `sendable`.** A webhook delivers to your own system,
like a CSV export, so it carries everyone identified who is not excluded and
has not asked to be deleted, whether or not Geysera would send them to an
email platform. But each event
says which: `data.person.sendable` is `true` when Geysera's own auto-sync rules
may put this person in your email platform, and `data.person.sendable_reason`
says why or why not. It is the same rule, in the same order, as the ESP column
on the People page: only people subscribed in your email platform, or whose
business address we hold outside the EU, UK and Canada, are sendable, never
anyone unsubscribed or suppressed there. **If your receiver adds people to an
email platform, send only `sendable: true`.** It is judged when the event is
delivered (a retry is judged again), and it does not follow a later change:
someone who subscribes next week gets no new event.

| `sendable_reason` | `sendable` | Meaning |
|---|---|---|
| `subscribed` | `true` | Subscribed in your email platform |
| `business_address` | `true` | Their own address is on their company's domain, and their country is known and outside the EU, UK and Canada |
| `work_email` | `true` | We found a work email for them (country rule as above). `data.person.email` is still their own address, not the work email |
| `no_business_address` | `false` | Not subscribed, and no business address |
| `country_unknown` | `false` | A business address, but no known country yet |
| `country_excluded` | `false` | A business address only, in the EU, UK or Canada |
| `unsubscribed_or_suppressed` | `false` | Unsubscribed or suppressed in your email platform |
| `no_email` | `false` | No email address |
| `excluded` | `false` | Excluded (such a person gets no event; listed for completeness) |
| `beyond_free_allowance` | `false` | Beyond the free plan's monthly allowance (`revealed: false`). Their send-rule reason is not given, because it would describe a person the plan hides |

On Mailchimp, a push also checks the person against opt-outs anywhere in your
Mailchimp account at send time. That check is not part of `sendable`.

---

```json
{
  "id": "9766ec60-…",
  "type": "signal.visitor_identified",
  "created": 1789171234,
  "data": {
    "visitor_id": "9766ec60-…",
    "revealed": true,
    "company": {
      "domain": "acme.com",
      "domain_canonical": "acme.com",
      "name": "Acme Corp",
      "intent_score": 72,
      "classification": "lead",
      "firmographics": {}
    },
    "person": {
      "email": "dana@acme.com",
      "name": null,
      "title": null,
      "status": "lead",
      "intent_score": 64,
      "sendable": true,
      "sendable_reason": "business_address"
    },
    "resolution": { "source": "email_match", "confidence": 95 },
    "identified_at": "2026-09-11T22:14:07+00:00"
  }
}
```

**What is actually populated.** The example above is not aspirational — it is
the shape you will receive, including the nulls. Write your mapper against
this, not against the field list.

| Field | Always present? | In practice |
|---|---|---|
| `data.revealed` | **yes** | `false` only on the free plan, for a person beyond the month's allowance: their contact fields are then `null` (see above) |
| `data.person` | the object, yes | never absent — but see the fields below |
| `data.person.email` | **yes, when `revealed`** | the identity. A visitor without one is never created, so key on it — but only when `revealed` is `true`; otherwise key on `visitor_id`. |
| `data.person.name` | no — usually `null` | populated for about 2% of visitors today |
| `data.person.title` | no — usually `null` | same |
| `data.person.status` | **yes** | this person's own status, as the People list shows it: `lead` or `customer` (an `excluded` person gets no event) |
| `data.person.intent_score` | **yes** | this **person's** score, an integer 0–100: the same number the People list shows for them. Use it to rank people; `data.company.intent_score` is their company's |
| `data.person.sendable` | **yes** | `true` or `false`: may Geysera put this person in an email platform (see above) |
| `data.person.sendable_reason` | **yes** | one of the codes in the table above |
| `data.company` | the key, yes | **`null` for someone with a personal mailbox address** (Gmail, an ISP and the like): we know no company for them, so none is sent. Otherwise the object below |
| `data.company.domain` | yes, unless masked by the allowance | the company's domain |
| `data.company.name` | no | fall back to the domain |
| `data.company.intent_score` | yes | an **integer 0–100**, the same scale the dashboard and the API show, and the ACCOUNT's score rather than this person's (`data.person.intent_score`). Measured across Signal accounts: **89% score 0** (seen, but on no page you have given a weight), and of the rest the median is 23 — `>= 70` selects 8% and `>= 80` selects 3%. Pick a threshold against those shares, not against the top of the range. |
| `data.company.firmographics` | the key, yes | `null` when the company is masked by the allowance; otherwise **always `{}` today.** Firmographic enrichment is not wired; treat a non-empty object as a future addition, never as a precondition. |
| `data.resolution.source` | yes | how the person was identified: `"email_match"` is the only value currently emitted |
| `data.resolution.confidence` | yes | an **integer** 0–100, not a string. `95` for every row today, so do not build a threshold you cannot test. |

## What you get

When a visitor on your site is identified, we POST once per registered endpoint:

```http
POST /your/endpoint HTTP/1.1
Content-Type: application/json
User-Agent: Geysera-Signal-Webhooks/1
X-Signal-Event: signal.visitor_identified
X-Signal-Delivery: 9766ec60-…            ← dedup on this
X-Signal-Timestamp: 1789171234
X-Signal-Signature: t=1789171234,v1=3f9c…
```

## The delivery contract

| | |
|---|---|
| Success | any `2xx` |
| Timeout | **10 seconds** — respond first, work later |
| Redirects | **not followed.** A `3xx` is a failure. Register the final URL |
| Guarantee | **at-least-once** |
| Retries | 10 attempts over **~14.5h**: 2m, 4m, 8m, 16m, 32m, 64m, 128m, 256m, then **6h** (the backoff doubles until it hits a 6h cap, which the tenth attempt is the only one to wait) |
| Dedup key | `X-Signal-Delivery` — **stable across retries** |
| Endpoint disabled | after 15 consecutive failures |

Two consequences worth internalising:

**Respond fast, then do the work.** The timeout is 10 seconds and it is
measured on our side. If your handler enriches a CRM record before replying,
a slow CRM turns into a retry storm. Acknowledge, enqueue, process.

**You will occasionally see the same event twice.** At-least-once is a promise
that you will not silently *lose* an event; it is not a promise of exactly-once,
which nothing delivering over a network can honestly offer. `X-Signal-Delivery`
does not change between attempts, so a single unique index on your side makes
duplicates harmless.

---

## Verifying the signature

Never process an unverified webhook. The URL is guessable; the signature is not.

The value is `t=<timestamp>,v1=<hex>`, where the hex is
`HMAC-SHA256(secret, "<timestamp>.<raw body>")`.

Two rules that cause most implementation bugs:

1. **Sign the raw bytes**, not a re-serialised object. `json.loads` then
   `json.dumps` will not round-trip to the same bytes and the signature will
   never match.
2. **Compare in constant time.** `==` on a hex digest leaks timing.

### Python (FastAPI)

```python
import hashlib, hmac, os, time
from fastapi import FastAPI, HTTPException, Request

app = FastAPI()
SECRET = os.environ["SIGNAL_WEBHOOK_SECRET"]   # whsec_…
TOLERANCE_SECONDS = 5 * 60

@app.post("/geysera/webhook")
async def receive(request: Request):
    raw = await request.body()                 # RAW bytes, before parsing
    header = request.headers.get("X-Signal-Signature", "")

    parts = dict(p.split("=", 1) for p in header.split(",") if "=" in p)
    timestamp, provided = parts.get("t", ""), parts.get("v1", "")
    if not timestamp or not provided:
        raise HTTPException(400, "malformed signature header")

    # Reject stale timestamps, or a captured delivery can be replayed forever.
    if abs(time.time() - int(timestamp)) > TOLERANCE_SECONDS:
        raise HTTPException(400, "timestamp outside tolerance")

    expected = hmac.new(
        SECRET.encode(), f"{timestamp}.".encode() + raw, hashlib.sha256
    ).hexdigest()
    if not hmac.compare_digest(expected, provided):
        raise HTTPException(401, "bad signature")

    event_id = request.headers.get("X-Signal-Delivery")
    if already_processed(event_id):            # your unique index
        return {"ok": True}                    # 2xx: do not make us retry

    event = await request.json()
    # Endpoints receive EVERY event type — there is no per-endpoint filter.
    # Branch before you touch `data`, or a test ping (or an event type added
    # after you wrote this) gets processed as a visitor.
    if event.get("type") != "signal.visitor_identified":
        return {"ok": True}                    # acknowledge and ignore

    enqueue(event)                             # return fast, work later
    return {"ok": True}
```

### Node (Express)

```js
const crypto = require("crypto");
const express = require("express");
const app = express();

// express.raw, NOT express.json — you need the exact bytes we signed.
app.post("/geysera/webhook",
  express.raw({ type: "application/json" }),
  (req, res) => {
    const parts = Object.fromEntries(
      (req.get("X-Signal-Signature") || "").split(",").map(p => p.split("=", 2))
    );
    const { t, v1 } = parts;
    if (!t || !v1) return res.status(400).end();
    if (Math.abs(Date.now() / 1000 - Number(t)) > 300) return res.status(400).end();

    const expected = crypto
      .createHmac("sha256", process.env.SIGNAL_WEBHOOK_SECRET)
      .update(`${t}.`).update(req.body)
      .digest("hex");

    // Length-check BEFORE the compare. timingSafeEqual throws RangeError on
    // buffers of different sizes, and the signature is attacker-supplied — so
    // `v1=deadbeef` on a guessable URL would crash the handler with a 500
    // instead of rejecting it. Python's compare_digest is length-safe; this
    // is the one place the two examples genuinely differ.
    const a = Buffer.from(expected, "hex");
    const b = Buffer.from(v1, "hex");
    if (a.length !== b.length || !crypto.timingSafeEqual(a, b)) {
      return res.status(401).end();
    }

    const event = JSON.parse(req.body);
    res.json({ ok: true });                    // acknowledge first
    // Every event type arrives here. Branch before reading `data`.
    if (event.type !== "signal.visitor_identified") return;
    enqueue(event, req.get("X-Signal-Delivery"));
  });
```

---

## Choosing what your handler does

The temptation is to write straight into your CRM. Consider what happens when
it is down: you return non-2xx, we retry for ~14.5 hours, and then stop. Your
handler's availability becomes our delivery window.

Better shape:

```
receive → verify → dedupe → enqueue → 2xx
                                └─ your worker retries against the CRM
                                   on your own schedule, forever if needed
```

That decouples our retry budget from your downstream's uptime, which is the
whole reason the two systems should not be joined at the handler.

---

## Testing before you go live

**Send a test ping.** From **Exports & API → Webhooks**, or by asking the
assistant. It fires a `signal.test` event at your endpoint, with the same
signature scheme, so you can confirm your verification code works before real
data depends on it. Its `data` has the same shape as a
`signal.visitor_identified` event (`revealed`, `company`, `person` with
`status`, `intent_score`, `sendable` and `sendable_reason`, `resolution`,
`identified_at`), built for a made-up person at `example.com`, plus
`"test": true` and a `message`. Like
registration, this is a dashboard action and not part of the public
`/signal-api/v1` surface.

The ping reports a coarse result, not the raw connection error: `delivered`
(with your endpoint's `status_code`), `http_error` (your endpoint answered,
with a non-2xx status), `timeout` (no answer within 10 seconds), `unreachable`
(could not connect over HTTPS, which includes a certificate your endpoint's
name does not match), or `refused` (the URL is not allowed, with the reason).

It is also the first thing your handler will receive, which is exactly why it
must branch on `type`: a handler that assumes every delivery is a visitor will
record the made-up `dana@example.com` from the test ping as a real person.

**Test locally with a tunnel** (ngrok or similar). We do not follow redirects,
so register the tunnel's final HTTPS URL, not a shortener.

**Deliberately fail once.** Return a 500 on purpose and confirm you receive the
event again roughly two minutes later, with the same `X-Signal-Delivery`. If
you do not, your dedup is keyed on something unstable — the most common
integration bug in this list, and one you want to find with a test rather than
with a customer's data.

---

## When not to use webhooks

If you need a full current picture — a nightly export, a report, a backfill —
poll the REST API instead. Webhooks tell you what *changed*; they are a poor way
to learn what *is*. See [Export identified accounts](./export-and-keep-in-sync.md).
