Skip to content
Documentation menu

Webhooks

Create an endpoint, verify the signature and handle retries.

Overview#

A webhook sends the events of your workspace, as a JSON POST, to the address of your choice: creation, update, deletion or expiry of a short link, a QR code or a link page, alerts, visits. You no longer have to poll the API.

  1. You declare a public HTTPS address and the events you want.
  2. Hyllo sends each event, signed with the webhook’s secret.
  3. Your receiver verifies the signature and answers 2xx without waiting.

Webhooks are managed in the app (Settings, Webhooks) or through the API with the webhooks:manage scope. They require a plan that includes the API.

Create a webhook#

Create a webhook in the app or with POST /webhooks (scope webhooks:manage, reserved to an admin). The body contains url, events (at least one type) and, optionally, description and batch_visits.

curl -sS -X POST "https://api.hyllo.fr/api/public/v1/webhooks" \
  -H "Authorization: Bearer $HYLLO_API_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"url":"https://example.com/hooks/hyllo","description":"Production","events":["short_link.created","qr_code.scanned"],"batch_visits":false}'
  • The url must be a public HTTPS address: a private, local or reserved address is refused (422 webhook_url_not_public), at creation and again at each send.
  • A workspace has at most 10 webhooks (422 too_many_webhooks beyond that).

To check your receiver, send a webhook.test event (see Logs, resend and test).

Events#

The events you can subscribe to:

  • Lifecycle: short_link.created, .updated, .deleted and .expired, and likewise for qr_code.* and link_page.*.
  • Limits and alerts: visit_limit.reached (visit limit reached) and alert.triggered (analytics alert triggered).
  • Visits: qr_code.scanned, short_link.clicked, link_page.viewed and link.clicked.
  • No subscription needed: visits.batch (batched visits) and webhook.test are sent without subscribing.

GET /webhooks/events lists the types you can subscribe to. Each type’s payload (data) is described in the events of the reference.

The resources in data are those of the public API, without access. A deletion only keeps the resource reference: data.resource (type, id, name). A visit only carries occurred_at, country, device_type and referrer_domain: never an IP, a user agent, a browser or UTM parameters.

Event envelope#

The body of each request is a JSON envelope:

FieldContent
idEvent identifier (evt_…), the same as Hyllo-Event-Id.
typeEvent type.
api_versionFormat version, currently 2026-12-01.
created_atEvent date, ISO 8601.
workspaceThe workspace concerned: { id }.
dataThe payload, which depends on the type.

A full example appears in the test vector.

Headers#

HeaderValue
Content-Typeapplication/json
User-AgentHyllo-Webhooks/1.0
Hyllo-SignatureThe signature: see Verify the signature.
Hyllo-Event-IdThe envelope’s id, identical on each retry: use it to deduplicate.
Hyllo-Event-TypeThe envelope’s type.
Hyllo-Delivery-IdThe delivery identifier.

Verify the signature#

Verify the signature of every request before handling it: otherwise anyone can send fake events to your address. The Hyllo-Signature header is t=<Unix timestamp>,v1=<hex>, possibly with a second v1= (see Secret rotation).

  1. Read the Hyllo-Signature header.
  2. Extract t and the list of v1 values.
  3. Reject the request if t differs from the current time by more than 300 seconds (recommended tolerance): this blocks the replay of an intercepted request.
  4. Compute the HMAC-SHA256, in hexadecimal, of the string made of t, a dot and the raw body. The key is the whole secret, whsec_ prefix included.
  5. Compare the result with each v1 using a constant-time comparison, not ==.
  6. Accept the request if one of the v1 values matches; otherwise answer 4xx without handling it.
import { createHmac, timingSafeEqual } from 'node:crypto'

export function verifyHylloSignature(
  rawBody,
  header,
  secret,
  { toleranceSeconds = 300, now = Math.floor(Date.now() / 1000) } = {},
) {
  if (typeof header !== 'string' || typeof secret !== 'string' || secret === '') {
    return false
  }

  let timestamp = null
  const signatures = []

  for (const part of header.split(',')) {
    const separator = part.indexOf('=')
    const key = part.slice(0, separator).trim()
    const value = part.slice(separator + 1).trim()

    if (separator === -1) {
      return false
    }
    if (key === 't' && /^\d+$/.test(value)) {
      timestamp = Number(value)
    } else if (key === 'v1' && /^[0-9a-fA-F]{64}$/.test(value)) {
      signatures.push(Buffer.from(value, 'hex'))
    }
  }

  if (timestamp === null || signatures.length === 0) {
    return false
  }
  if (Math.abs(now - timestamp) > toleranceSeconds) {
    return false
  }

  const body = Buffer.isBuffer(rawBody) ? rawBody : Buffer.from(String(rawBody), 'utf8')
  const expected = createHmac('sha256', secret)
    .update(Buffer.concat([Buffer.from(`${timestamp}.`, 'utf8'), body]))
    .digest()

  let valid = false
  for (const signature of signatures) {
    if (timingSafeEqual(signature, expected)) {
      valid = true
    }
  }

  return valid
}

Test vector#

These sample values give a known signature: use them to test your code. The secret is fake, never use a real one in your tests.

  • Secret: whsec_TESTtestTESTtestTESTtestTESTtest
  • t: 1790000000
  • Raw body, on a single line: {"id":"evt_01ARZ3NDEKTSV4RRFFQ69G5FAV","type":"webhook.test","api_version":"2026-12-01","created_at":"2026-09-21T14:13:20.000000Z","workspace":{"id":"01ARZ3NDEKTSV4RRFFQ69G5FAV"},"data":{"message":"This is a test event from Hyllo."}}
  • Expected Hyllo-Signature header: t=1790000000,v1=087311d448e2a7eacab4aad98f9b611a439c32b1f635e0e7691712503dda8d3f

With this secret, this t and this body, the hexadecimal HMAC-SHA256 must equal the v1 value of the header. As t is old, set your test’s current time to t (the now parameter in the examples). Your function must then:

  • accept the vector as is;
  • reject a modified body, even by a single character;
  • reject a t outside the tolerance;
  • accept a header with two v1 values of which only the second matches;
  • reject a malformed header, without throwing an exception.

Secret rotation#

Renew the secret in the app or with POST /webhooks/{webhook}/secret: the new secret is only returned once.

During the following 24 hours, the old secret stays valid: every send carries two v1 values, the new one first. Accept the request if either one matches (the examples do), and deploy the new secret on your side before that period ends.

Delivery and retries#

Answer 2xx within 5 seconds (3 seconds to connect). Redirects are not followed and count as a failure.

Any other status, a timeout or a network error triggers a new attempt, following this schedule (the delay runs from the previous failure):

RetryDelay
#160 seconds
#2300 seconds
#3900 seconds
#43600 seconds
#57200 seconds
#614400 seconds
#728800 seconds
#828800 seconds

After the last retry, the delivery becomes failed. A skipped delivery was never attempted (webhook disabled, plan without API).

The log gives the status, the attempts, the status code received, the start of the response (cut at 1024 bytes) and error: timeout, dns, tls, connection, redirect, not_public_at_send or interrupted.

The address is resolved at each send, without a proxy: if it is no longer public, the delivery fails immediately (not_public_at_send).

Automatic disabling#

A webhook that has been failing continuously for 72 hours is disabled: is_active: false and disabled_reason: failing. Its pending deliveries are dropped (skipped) and the workspace admins are notified.

First fix your receiver, then re-enable the webhook in the app or with PATCH /webhooks/{webhook} and is_active: true.

A webhook switched off by Hyllo staff (disabled_reason: staff) no longer sends anything, test included: re-enabling it, changing its url, testing it or resending a delivery answers 403 staff_disabled.

A plan without API access does not send anything either (skipped deliveries).

Logs, resend and test#

  • Log: GET /webhooks/{webhook}/deliveries lists deliveries, most recent first, kept for 30 days. A delivery’s detail gives the body that was sent.
  • Resend: POST /webhooks/{webhook}/deliveries/{delivery}/resend sends the same event again, with the same Hyllo-Event-Id. It does not count toward the monthly cap.
  • Test: POST /webhooks/{webhook}/test sends a webhook.test synchronously (5 seconds at most) and returns the delivery as it ended. It is never retried.

Resend and test are limited: see Route-specific limits.

Visit batching#

A heavily visited site produces many visit events. With batch_visits: true, they are no longer sent one by one: they are grouped into a visits.batch event, sent at regular intervals, with at most 500 events in data.events (full envelopes).

Monthly cap#

Visit events are counted per calendar month (UTC) and per workspace. The cap depends on the plan:

PlanVisit events per month
Pro10,000
Business100,000
Enterprise1,000,000

GET /webhooks gives usage in meta.usage (period, visit_events, limit). Admins are notified as the cap approaches, then when it is reached.

Once the cap is reached, visits stop being emitted and are not caught up; lifecycle events continue. A manual resend does not count.

Best practices#

  • Verify the signature before any handling.
  • Answer 2xx quickly (within 5 seconds) and handle later, in a job queue.
  • Deduplicate by Hyllo-Event-Id: a delivery may arrive more than once (retries, resends). For *.expired, the identifier is deterministic for a resource and an expiry date: a replay of the detection keeps the same Hyllo-Event-Id.
  • Arrival order is not guaranteed: rely on created_at.
  • Ignore unknown event types and fields, and answer them with 2xx.
  • Monitor your webhooks: a continuous outage disables them (see Automatic disabling).

A minimal receiver: raw body, signature verification, fast response and deduplication.

import { createHmac, timingSafeEqual } from 'node:crypto'
import { createServer } from 'node:http'

function verifyHylloSignature(
  rawBody,
  header,
  secret,
  { toleranceSeconds = 300, now = Math.floor(Date.now() / 1000) } = {},
) {
  if (typeof header !== 'string' || typeof secret !== 'string' || secret === '') {
    return false
  }

  let timestamp = null
  const signatures = []

  for (const part of header.split(',')) {
    const separator = part.indexOf('=')
    const key = part.slice(0, separator).trim()
    const value = part.slice(separator + 1).trim()

    if (separator === -1) {
      return false
    }
    if (key === 't' && /^\d+$/.test(value)) {
      timestamp = Number(value)
    } else if (key === 'v1' && /^[0-9a-fA-F]{64}$/.test(value)) {
      signatures.push(Buffer.from(value, 'hex'))
    }
  }

  if (timestamp === null || signatures.length === 0) {
    return false
  }
  if (Math.abs(now - timestamp) > toleranceSeconds) {
    return false
  }

  const body = Buffer.isBuffer(rawBody) ? rawBody : Buffer.from(String(rawBody), 'utf8')
  const expected = createHmac('sha256', secret)
    .update(Buffer.concat([Buffer.from(`${timestamp}.`, 'utf8'), body]))
    .digest()

  let valid = false
  for (const signature of signatures) {
    if (timingSafeEqual(signature, expected)) {
      valid = true
    }
  }

  return valid
}

const secret = process.env.HYLLO_WEBHOOK_SECRET
const processed = new Set()

function handleEvent(event) {
  console.log(event.type, event.id)
}

const server = createServer((request, response) => {
  if (request.method !== 'POST' || request.url !== '/hyllo/webhooks') {
    response.writeHead(404).end()
    return
  }

  const chunks = []
  request.on('data', (chunk) => chunks.push(chunk))
  request.on('end', () => {
    const rawBody = Buffer.concat(chunks)

    if (!verifyHylloSignature(rawBody, request.headers['hyllo-signature'], secret)) {
      response.writeHead(401).end()
      return
    }

    response.writeHead(200).end()

    const eventId = request.headers['hyllo-event-id']
    if (processed.has(eventId)) {
      return
    }
    processed.add(eventId)

    setImmediate(() => {
      try {
        handleEvent(JSON.parse(rawBody.toString('utf8')))
      } catch (error) {
        console.error(error)
      }
    })
  })
})

server.listen(3000)

Read next