OSPRY Docs

Developers

Receiving OSPRY webhooks

Who this is for: Developers building the endpoint that receives OSPRY webhooks · Where: Portal -> Reach -> Outbound Integrations -> Webhook (/integrations/[kind])

What this does

OSPRY sends an HTTPS POST to your endpoint when it identifies a visitor on your site. Each send carries a JSON body and signed headers. This guide covers which events you get, what the body looks like in each payload version, how to check the signature, and what OSPRY does when your endpoint fails.

To create the webhook connection itself, see Connecting an integration.

Steps

  1. In the portal, open Reach -> Outbound Integrations and choose Webhook.
  2. Enter your endpoint's https address and connect.
  3. Copy the signing secret OSPRY shows you. It starts with whsec_. OSPRY shows it only once.
  4. Choose a Payload version: v1 or v2. New receivers should use v2. See Payload versions.
  5. Store the secret on your server, for example in an OSPRY_WEBHOOK_SECRET environment variable.
  6. Verify the X-Sight-Signature header on every request. See Verify the signature.
  7. Return a 2xx status within 8 seconds.

Events

The X-Sight-Event header names the event. The body's event key carries the same value.

X-Sight-Event When OSPRY sends it X-Sight-Idempotency-Key
visitor.identified The first time OSPRY resolves a visitor. The visit ID, unprefixed: <visit_id>
visitor.enriched Enrichment of an identified person finishes. The body is rebuilt from the saved profile, so it holds the enriched data. Sent for person records only. visitor.enriched:<visit_id>
visitor.identified (automation) An automation rule's threshold is crossed. The body carries the rule's label in classification and is_repeat: true. velocity:<visit_id>:<visitor_id>

A few rules apply to all events:

  • Repeat visits never send a webhook. A known visitor coming back produces no send on its own. Only an automation rule can send for a returning visitor.
  • Most visitors produce two events. Expect visitor.identified first and visitor.enriched later, for the same visit. Update the record you already have. Do not create a second one. Match on subject.id in v2, or visitor_id in v1.
  • Automation sends go only to the connections the rule targets. They do not follow the connection's delivery scope. They are sent once, are not retried, and do not appear in the send report.

visitor.enriched status. Sending both events for the same visit is being switched on. Until it is on for your account, you receive visitor.identified only. Build your receiver to handle both now, so nothing changes for you when it turns on.

Headers

OSPRY sets these headers on every send:

Header Value
Content-Type application/json
X-Sight-Event The event name, from the table above.
X-Sight-Idempotency-Key The key for this event of this visit, from the table above. Retries reuse it.
X-Sight-Signature sha256= followed by the lowercase hex HMAC-SHA256 of the raw body, keyed with your signing secret.
X-Ospry-Contract v2 sends only. The dated contract version of the body, currently 2026-09-04. v1 sends never carry it.

You can add your own headers to a connection. OSPRY applies yours first and its own headers last, so a custom header can never replace X-Sight-Event, X-Sight-Idempotency-Key, X-Sight-Signature or X-Ospry-Contract.

Use X-Sight-Idempotency-Key to drop duplicates: if you have already processed a key, return 200 and do nothing else.

The signature covers the body only. It does not cover the headers, and it carries no timestamp. So a copy of a signed request still verifies if someone sends it again, even with a changed idempotency key. Two habits keep that harmless:

  • Apply each send as an update to one record, matched on a value inside the signed body: subject.id in v2, or visitor_id in v1. A repeated body then changes nothing.
  • Keep raw requests private. Do not log full request bodies with their signature headers, and serve your endpoint over HTTPS only.

Verify the signature

OSPRY signs the exact bytes of the body. To check a request:

  1. Read the raw body bytes before any JSON parsing. A parsed and re-serialized body will not match.
  2. Compute HMAC-SHA256 over those bytes. Use your whole signing secret as the key, including the whsec_ prefix.
  3. Add sha256= to the front of the lowercase hex digest.
  4. Compare the result with X-Sight-Signature in constant time. Reject the request if they differ or the header is missing.

Node.js

This server uses only Node.js built-in modules. Save it as receiver.js and run it with OSPRY_WEBHOOK_SECRET='whsec_...' node receiver.js:

// receiver.js: verify OSPRY webhook signatures with Node.js built-ins only.
// Run with: OSPRY_WEBHOOK_SECRET='whsec_...' node receiver.js
const crypto = require('node:crypto');
const http = require('node:http');

const SECRET = process.env.OSPRY_WEBHOOK_SECRET;

// Returns true only when the header matches an HMAC-SHA256 of the raw bytes.
function verifyOspryWebhook(rawBody, signatureHeader, secret) {
  if (typeof signatureHeader !== 'string' || !signatureHeader.startsWith('sha256=')) {
    return false;
  }
  const expected =
    'sha256=' + crypto.createHmac('sha256', secret).update(rawBody).digest('hex');
  const a = Buffer.from(expected, 'utf8');
  const b = Buffer.from(signatureHeader, 'utf8');
  // timingSafeEqual throws on unequal lengths, so check length first.
  return a.length === b.length && crypto.timingSafeEqual(a, b);
}

http
  .createServer((req, res) => {
    const chunks = [];
    req.on('data', (chunk) => chunks.push(chunk));
    req.on('end', () => {
      const rawBody = Buffer.concat(chunks); // the exact bytes OSPRY signed
      if (!verifyOspryWebhook(rawBody, req.headers['x-sight-signature'], SECRET)) {
        res.writeHead(401).end();
        return;
      }
      const event = req.headers['x-sight-event'];
      const idempotencyKey = req.headers['x-sight-idempotency-key'];
      const body = JSON.parse(rawBody.toString('utf8'));
      console.log('verified', event, idempotencyKey, body.tier);
      // Skip if you already processed idempotencyKey, then update your record.
      res.writeHead(200).end();
    });
  })
  .listen(3000);

If you use Express, mount express.raw({ type: 'application/json' }) on the webhook route so req.body is a Buffer, then pass it to verifyOspryWebhook.

Python

This server uses only the Python 3.10+ standard library. Save it as receiver.py and run it with OSPRY_WEBHOOK_SECRET='whsec_...' python3 receiver.py:

# receiver.py: verify OSPRY webhook signatures with the Python standard library.
# Run with: OSPRY_WEBHOOK_SECRET='whsec_...' python3 receiver.py
import hashlib
import hmac
import json
import os
from http.server import BaseHTTPRequestHandler, HTTPServer

SECRET = os.environ["OSPRY_WEBHOOK_SECRET"]

def verify_ospry_webhook(raw_body: bytes, signature_header: str | None, secret: str) -> bool:
    """Return True only when the header matches an HMAC-SHA256 of the raw bytes."""
    if not signature_header or not signature_header.startswith("sha256="):
        return False
    digest = hmac.new(secret.encode("utf-8"), raw_body, hashlib.sha256).hexdigest()
    expected = ("sha256=" + digest).encode("utf-8")
    return hmac.compare_digest(expected, signature_header.encode("utf-8"))

class OspryWebhookHandler(BaseHTTPRequestHandler):
    def do_POST(self):
        length = int(self.headers.get("Content-Length", "0"))
        raw_body = self.rfile.read(length)  # the exact bytes OSPRY signed
        if not verify_ospry_webhook(raw_body, self.headers.get("X-Sight-Signature"), SECRET):
            self.send_response(401)
            self.end_headers()
            return
        event = self.headers.get("X-Sight-Event")
        idempotency_key = self.headers.get("X-Sight-Idempotency-Key")
        body = json.loads(raw_body)
        print("verified", event, idempotency_key, body["tier"], flush=True)
        # Skip if you already processed idempotency_key, then update your record.
        self.send_response(200)
        self.end_headers()

HTTPServer(("", 3000), OspryWebhookHandler).serve_forever()

In Flask, read the raw bytes with request.get_data(). In Django, use request.body.

Both servers accept a correctly signed body and return 401 when one byte of the body changes, the header is missing, or the body was signed with another secret.

Payload versions

Each connection sends one payload version. You pick it with the Payload version control in the connection's settings.

  • v1 is a flat body. It is frozen: its keys, order and types never change. Existing connections stay on v1 until you change them.
  • v2 is an envelope around a shared contact object. Every absent field comes with a reason, and you can opt into more data. Choosing Include all available fields or any extra tier moves the connection to v2.

A change of version applies to the next send. A retry always resends the version it was first sent with.

Automation sends whose profile could not be loaded are sent as v1, even on a v2 connection.

v1 body

The v1 body is a single JSON object. Keys appear in this order. A key marked "omitted when empty" is left out when it has no value.

# Key Omitted when empty Meaning
1 event No visitor.identified or visitor.enriched.
2 tier No person or company.
3 visitor_id Yes The visitor's ID.
4 full_name Yes Full name.
5 first_name Yes First name.
6 last_name Yes Last name.
7 title Yes Job title.
8 business_email Yes Work email address.
9 linkedin_url Yes LinkedIn profile URL.
10 company_name Yes Company name.
11 company_domain Yes Company domain.
12 industry Yes Industry.
13 employee_count Yes Employee-count band, such as 201-500.
14 est_revenue Yes Revenue band, such as $50M-$100M.
15 city Yes City.
16 state Yes State or region.
17 captured_url Yes The page the visitor was on.
18 referrer Yes The referring URL.
19 seen_at Yes When the visit happened, RFC 3339 in UTC.
20 is_repeat No Always present. true on automation sends.
21 served_from Yes No longer set. Kept because v1 never changes.
22 classification Yes The automation rule's label, on automation sends.

Here is a v1 body for an automation send:

{"event":"visitor.identified","tier":"person","visitor_id":"9f2c1e4a-7b30-4a51-9d8e-2f6b1c0d5e77","full_name":"Dana Whitfield","first_name":"Dana","last_name":"Whitfield","title":"VP Operations","business_email":"dana.whitfield@northwindlogistics.com","linkedin_url":"https://www.linkedin.com/in/dana-whitfield","company_name":"Northwind Logistics","company_domain":"northwindlogistics.com","industry":"Transportation and Logistics","employee_count":"201-500","est_revenue":"$50M-$100M","city":"Columbus","state":"OH","captured_url":"https://northwindlogistics.com/pricing","referrer":"https://www.google.com/","seen_at":"2026-09-04T18:59:02Z","is_repeat":true,"classification":"high_intent"}

v2 body

The v2 body is defined by WebhookEventV2 in the field contract, which you can fetch from https://app.ospry.ai/api/v1/schema. These are its top-level keys:

Key Always present Meaning
event Yes visitor.identified or visitor.enriched.
contract_version Yes The dated contract, currently 2026-09-04. Same value as X-Ospry-Contract.
id Yes The visit ID. For visitor.identified this equals X-Sight-Idempotency-Key.
emitted_at Yes When OSPRY rendered the body, RFC 3339 in UTC.
tier Yes person or company.
is_repeat Yes true on automation sends.
served_from No Omitted when empty.
classification No The automation rule's label. Omitted when empty.
subject Yes The contact object (Contact in the schema).
visit Yes visitor_id, captured_url, referrer, seen_at, domain_id. A missing value is null, never a missing key.
field_policy Yes Counts of what this send included and withheld, and which tiers are on.

subject holds identity, company, location, handles, traits, custom_fields, missing, provenance and links. Every field OSPRY could send appears exactly once: as a value, or in missing with a reason. For what each field means, see the Contact field reference.

missing uses five reasons:

Reason Meaning
no_source No data source OSPRY uses produces this field.
not_enriched A source exists, but this record has not been enriched with it yet.
unmapped Your inbound field mapping drops this field.
withheld_tier The field belongs to a tier this connection has not turned on.
withheld_compliance The value was held back: a phone on a do-not-call list or with an unknown do-not-call status, or a record removed at the person's request.

Schema note. The published schema currently lists only visitor.identified for event. visitor.enriched bodies have the same shape with event set to visitor.enriched. If you validate bodies against the schema, allow both values.

Here is a shortened v2 body from a connection with contact handles on and sensitive traits off. The missing list is cut to three entries, while field_policy keeps the counts of the full list:

{
  "event": "visitor.identified",
  "contract_version": "2026-09-04",
  "id": "4d2c9b17-6e51-4d0a-9b8b-1f3a2c7d8e90",
  "emitted_at": "2026-09-04T18:59:03Z",
  "tier": "person",
  "is_repeat": false,
  "subject": {
    "object": "contact",
    "id": "9f2c1e4a-7b30-4a51-9d8e-2f6b1c0d5e77",
    "subject_type": "person_profile",
    "contract_version": "2026-09-04",
    "identity": {
      "full_name": "Dana Whitfield",
      "first_name": "Dana",
      "last_name": "Whitfield",
      "title": "VP Operations",
      "linkedin_url": "https://www.linkedin.com/in/dana-whitfield"
    },
    "company": {
      "name": "Northwind Logistics",
      "domain": "northwindlogistics.com",
      "industry": "Transportation and Logistics",
      "employee_count": "201-500",
      "est_revenue": "$50M-$100M"
    },
    "location": { "city": "Columbus", "state": "OH", "postal_code": "43017" },
    "handles": {
      "business_email": "dana.whitfield@northwindlogistics.com",
      "emails": [{ "value": "dana.whitfield@gmail.com", "kind": "personal", "verified": null }],
      "phones": [
        { "value": "+1 614 555 0144", "kind": "mobile", "dnc": false, "dnc_known": true, "callable": true }
      ]
    },
    "traits": [],
    "custom_fields": [
      {
        "key": "lifecycle_stage",
        "label": "Lifecycle stage",
        "type": "select",
        "value": "Marketing qualified A",
        "source": "inbound_mapping",
        "enriched_at": null
      }
    ],
    "missing": {
      "person.seniority": "not_enriched",
      "person.trait.age_range": "withheld_tier",
      "person.trait.income_range": "withheld_tier"
    },
    "provenance": {},
    "links": {}
  },
  "visit": {
    "visitor_id": "9f2c1e4a-7b30-4a51-9d8e-2f6b1c0d5e77",
    "captured_url": "https://northwindlogistics.com/pricing",
    "referrer": "https://www.google.com/",
    "seen_at": "2026-09-04T18:59:02Z",
    "domain_id": "8c1d0f22-1b44-4c6e-9a02-5d7e3b1a0c11"
  },
  "field_policy": {
    "permitted_tiers": [1, 2, 3],
    "enabled_tiers": [1, 2],
    "withheld_tiers": [],
    "included": 17,
    "missing": 17,
    "missing_reason": { "not_enriched": 6, "withheld_tier": 11 }
  }
}

v2 tiers

v2 fields come in three tiers. You turn tiers on per connection, in the connection's settings.

Tier Settings label Default What it adds
1 Identity, firmographics and custom fields Always on What the profile page shows, plus your own custom fields in custom_fields.
2 Contact handles (emails and phones) Off handles.emails and handles.phones.
3 Sensitive traits (household, demographic, financial) Off Household, demographic and financial traits in traits, such as age band, homeowner status and income range.
  • Custom fields are always sent in v2. The exception is a custom field you have classed as personal contact data or sensitive data. It follows tier 2 or tier 3. A field flagged for compliance is never sent.
  • Phones need tier 2 and a clean do-not-call status. OSPRY sends a phone only when its do-not-call status is known and the number is not on a do-not-call list. Every phone sent has callable: true. A held-back phone shows in missing as withheld_compliance.
  • Off tiers are listed, not hidden. Fields from a tier you have not turned on show in missing as withheld_tier, so you can see what turning it on would add.
  • Include all available fields turns on tiers 2 and 3 together. You can also turn on either tier alone.

Retries and failures

OSPRY waits up to 8 seconds for each attempt.

Your response What OSPRY does
Any 2xx Marks the send delivered.
429, any 5xx, a timeout or a network error Retries later.
Any other 4xx Marks the send failed. No retry.

Retry rules:

  • Up to 8 attempts in total, the first send plus up to 7 retries. After the 8th failed attempt, OSPRY stops and the send shows as Dead in the connection's send report.
  • Backoff with full jitter. Before retry number n, OSPRY waits a random time between 0 and 2 seconds x 2^(n-1), capped at 5 minutes. The longest possible waits are 2, 4, 8, 16, 32, 64 and 128 seconds, so all retries finish within a few minutes.
  • Retries resend the stored bytes. OSPRY saves the body at the first attempt and resends exactly that body, with the same idempotency key and X-Ospry-Contract. The signature also matches, unless you rotate the secret between attempts (see below). Changing the payload version or tiers mid-retry does not change the body.
  • Circuit breaker per host. After 5 failures in a row to the same host, OSPRY pauses sends to that host for at least 30 seconds, then tries one request. Paused sends are rescheduled 30 to 60 seconds out and do not use up their 8 attempts. The failure count resets after 2 minutes with no new failure.
  • Automation sends are not retried. They get one attempt.

Versioning

  • Adding a field inside v2 changes only the dated contract_version and X-Ospry-Contract. Ignore keys you do not know, and your receiver keeps working.
  • Removing, renaming or retyping a field needs a new payload version. The old version keeps working for 90 days alongside the new one.
  • v1 never changes.

See Versioning for the full policy.

Not yet available

These are planned but do not exist today:

  • contact.upserted, delivery.failed and webhook.test events.
  • Creating, changing or deleting webhook connections through the API. Use the portal.

See Not yet available for the full list.

Tips & FAQs

  • Respond fast, work later. Return 2xx as soon as the signature checks out, then do slow work in the background. A response slower than 8 seconds counts as a failure.
  • Never parse before verifying. Frameworks that parse JSON for you change the bytes. Read the raw body first.
  • Cap the body size. The examples read the whole body. In production, set a size limit in your server or framework so an oversized request is refused before it is buffered.
  • Rotating the secret has no overlap. Rotate secret replaces the secret at once. Every send from then on is signed with the new secret, including retries of older sends. Update your server right after you rotate.
  • Two events, one record. visitor.identified and visitor.enriched for one visit carry the same visit ID, in the body's id (v2) and in the idempotency key. Treat the second event as an update.
  • Return 200 for duplicates. If you have seen an idempotency key before, return 200. Returning an error makes OSPRY retry.
  • A 4xx stops retries. If your endpoint rejects a valid send with 400, OSPRY will not try again. Use 5xx or 429 only for problems that a retry can fix.