> ## Documentation Index
> Fetch the complete documentation index at: https://docs.geekflare.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Webhooks

> Get notified when a crawl or a map job changes state, instead of polling.

Pass `webhookUrl` when you start a crawl (`POST /crawl`) or an asynchronous map (`POST /map/async`). Geekflare then sends an HTTPS `POST` to that URL when the job changes state.

The response that creates the job contains a `webhookSecret`. **It is shown once.** Store it: you need it to check that a request really comes from Geekflare.

## Requirements for your endpoint

* The URL must use `https` and must not contain a username or password.
* It must point to a public address. Private, loopback and link-local addresses (for example `10.x.x.x`, `127.0.0.1`, `169.254.169.254`) and names that only resolve inside a network (`localhost`, `*.internal`, `*.local`) are rejected when you create the job, and again every time a delivery is attempted, after DNS resolution.
* Redirects are not followed. Answer on the URL you registered.
* Answer with a `2xx` status within 10 seconds. Anything else counts as a failed attempt. The response body is ignored.

## Request

```http theme={null}
POST /your/webhook HTTP/1.1
Content-Type: application/json
User-Agent: Geekflare-Webhooks/1.0
X-Geekflare-Event: crawl.completed
X-Geekflare-Delivery: 6f1c1d1e-5b0c-4b52-9b0b-0e4f6f4f0a11
X-Geekflare-Signature: t=1767225600,v1=3f1c...e9
```

| Header | Meaning |
| - | - |
| `X-Geekflare-Event` | Event type, for example `crawl.completed`. |
| `X-Geekflare-Delivery` | Unique id of this delivery. It is also the `id` in the body. Use it to ignore duplicates. |
| `X-Geekflare-Signature` | Timestamp and signature. See [Verify the signature](#verify-the-signature). |

The body is always:

```json theme={null}
{
  "id": "6f1c1d1e-5b0c-4b52-9b0b-0e4f6f4f0a11",
  "type": "crawl.completed",
  "createdAt": "2026-01-01T12:00:00.000Z",
  "data": {}
}
```

## Events

### Crawl

| Event | Sent when | Default |
| - | - | - |
| `crawl.started` | Discovery has finished and pages are being scraped. | yes |
| `crawl.page` | One page has finished (scraped or failed). One call per page, so a 5,000 page crawl means 5,000 calls. | no, add it to `webhookEvents` |
| `crawl.on_hold` | Credits ran out (or billing is unavailable). Pages scraped so far stay available. Sent once per hold. | yes |
| `crawl.resumed` | Credits are available again and the crawl continues. | yes |
| `crawl.completed` | Every page has finished and its credits are recorded. | yes |
| `crawl.failed` | The crawl failed, for example nothing could be scraped, or it stayed on hold for 24 hours. | yes |
| `crawl.cancelled` | You cancelled the crawl. | yes |

Choose events with `webhookEvents` when you create the crawl. If you leave it out you get the defaults.

`crawl.started`, `crawl.on_hold`, `crawl.resumed`, `crawl.completed`, `crawl.failed` and `crawl.cancelled` carry the state of the job:

```json theme={null}
{
  "crawlId": "0b0f5f3e-...",
  "url": "https://example.com/",
  "status": "completed",
  "totalPages": 120,
  "completedPages": 118,
  "failedPages": 2,
  "discoveryComplete": true,
  "discoveryPartial": false,
  "credits": { "consumed": 29.5 },
  "holdReason": null,
  "holdExpiresAt": null,
  "expiresAt": "2026-01-08T12:00:00.000Z",
  "error": null
}
```

* `expiresAt` is when the pages and the ZIP of the crawl are deleted. It is `null` until the crawl has finished.
* `crawl.on_hold` has `holdReason` (`credits` or `billing`), `holdExpiresAt` (when the crawl fails if credits have not been added) and `reason`.
* During planned maintenance a running crawl can be paused without a webhook: `GET /crawl/{id}` then shows `status: "on_hold"` with `holdReason: "maintenance"` and no `holdExpiresAt`, and the crawl continues by itself afterwards.
* `crawl.failed` after an unresolved hold has `reason: "hold_expired"`.

`crawl.page`:

```json theme={null}
{
  "crawlId": "0b0f5f3e-...",
  "url": "https://example.com/pricing",
  "depth": 1,
  "status": "completed",
  "httpStatusCode": 200,
  "contentUrl": "https://...r2.cloudflarestorage.com/...?X-Amz-Signature=...",
  "linkExpiresAt": "2026-01-02T12:00:00.000Z",
  "durationMs": 840,
  "proxyUsed": false,
  "credits": 0.25,
  "error": null
}
```

`contentUrl` is a temporary signed link. It works until `linkExpiresAt` and never later than `expiresAt`. When it has expired, call `GET /crawl/{id}`: every response contains fresh links.

### Map

| Event | Sent when |
| - | - |
| `map.completed` | The map job finished. |
| `map.failed` | The map job failed. |

```json theme={null}
{
  "mapId": "5a0c7a52-...",
  "url": "https://example.com/",
  "status": "completed",
  "count": 412,
  "failedCount": 3,
  "partial": false,
  "estimatedCredits": 103,
  "credits": 1,
  "error": null
}
```

## Verify the signature

Every request is signed with your `webhookSecret`. Check the signature before you trust the body.

`X-Geekflare-Signature` looks like `t=1767225600,v1=<hex>`:

* `t` is the Unix time in seconds when the request was signed.
* `v1` is the hexadecimal HMAC-SHA256 of the string `"<t>.<raw request body>"`, using the `webhookSecret` (the whole value, including the `whsec_` prefix) as the key.

Use the **raw** body, exactly as received, not a re-serialized copy. Compare in constant time and reject requests whose timestamp is more than 5 minutes old. Every retry is signed again with a new timestamp.

```javascript Node.js theme={null}
import { createHmac, timingSafeEqual } from "node:crypto";

export function verifyGeekflareWebhook(
  rawBody,
  signatureHeader,
  secret,
  toleranceSeconds = 300,
) {
  const parts = Object.fromEntries(
    signatureHeader.split(",").map((part) => part.split("=")),
  );
  const timestamp = Number(parts.t);

  if (
    !timestamp ||
    Math.abs(Date.now() / 1000 - timestamp) > toleranceSeconds
  ) {
    return false;
  }

  const expected = createHmac("sha256", secret)
    .update(`${timestamp}.${rawBody}`)
    .digest("hex");
  const received = parts.v1 ?? "";

  return (
    expected.length === received.length &&
    timingSafeEqual(Buffer.from(expected), Buffer.from(received))
  );
}

// Express: use express.raw({ type: 'application/json' }) so req.body is the raw body.
app.post("/webhook", express.raw({ type: "application/json" }), (req, res) => {
  const ok = verifyGeekflareWebhook(
    req.body.toString("utf8"),
    req.header("X-Geekflare-Signature") ?? "",
    process.env.GEEKFLARE_WEBHOOK_SECRET,
  );

  if (!ok) return res.sendStatus(400);

  const event = JSON.parse(req.body.toString("utf8"));
  // ... handle event.type, ignore event.id if you have seen it before
  res.sendStatus(200);
});
```

```python Python theme={null}
import hashlib
import hmac
import time


def verify_geekflare_webhook(raw_body: bytes, signature_header: str, secret: str, tolerance_seconds: int = 300) -> bool:
    parts = dict(part.split("=", 1) for part in signature_header.split(","))
    timestamp = int(parts.get("t", "0"))

    if not timestamp or abs(time.time() - timestamp) > tolerance_seconds:
        return False

    signed = f"{timestamp}.".encode() + raw_body
    expected = hmac.new(secret.encode(), signed, hashlib.sha256).hexdigest()

    return hmac.compare_digest(expected, parts.get("v1", ""))
```

## Retries

A delivery is retried until your endpoint answers `2xx`, up to 5 attempts in total:

| Attempt | Sent |
| - | - |
| 1 | right away |
| 2 | 10 seconds after attempt 1 failed |
| 3 | 1 minute after attempt 2 failed |
| 4 | 5 minutes after attempt 3 failed |
| 5 | 30 minutes after attempt 4 failed |

After the fifth failed attempt the delivery is marked `failed` and is not sent again. In total that is about 36 minutes. A link inside a payload is always valid for longer than that.

Redirects and `3xx` answers, timeouts, connection errors and non-`2xx` statuses all count as failed attempts. A URL that resolves to a non-public address fails immediately and is not retried.

## Order and duplicates

* Deliveries are queued in the order events happen, but retries mean they can arrive out of order. A `crawl.page` that is being retried can arrive after `crawl.completed`. Use `createdAt` in the body to order events and the crawl status from `GET /crawl/{id}` as the source of truth.
* A delivery can arrive more than once. Use `id` (also `X-Geekflare-Delivery`) to ignore repeats.

## See what was delivered

If an event did not reach you, look at what Geekflare tried:

* `GET /crawl/{id}` contains `webhook.deliveries`: the 10 most recent deliveries with `status` (`pending`, `delivered`, `failed`), `attempts`, `lastHttpStatus`, `lastError` and `nextAttemptAt`.
* `GET /crawl/{id}/webhooks` lists every delivery, with `limit` and `offset`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.