# Webhook Signature Verifier (`stellar_ballet_0bu/webhook-sig-verifier`) Actor

Verify HMAC-SHA256/SHA1/SHA512, Stripe-Signature, GitHub X-Hub-Signature-256, Apify webhook, and Bearer-token webhook payloads against a shared secret. Constant-time compare, per-check pass/fail, structured reason codes for n8n/Make/Sheets alerts.

- **URL**: https://apify.com/stellar\_ballet\_0bu/webhook-sig-verifier.md
- **Developed by:** [Nikita S](https://apify.com/stellar_ballet_0bu) (community)
- **Categories:** Developer tools, Other
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-usage

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## Webhook Signature Verifier

Verify HMAC-SHA256 / SHA1 / SHA512, Stripe-Signature (`t=...,v1=...`), GitHub `X-Hub-Signature-256`, Apify webhook resource HMAC, and Bearer-token webhook payloads against a shared secret. Constant-time compare, per-check pass/fail with structured reason codes — built for `n8n → Slack` style alerts and Apify-as-a-step workflows.

### Why a separate Actor?

There is no Store Actor that handles more than one signing scheme. `devnomad/webhook-validator` and `stalniad/webhook-validator` are HTTPS endpoints, not Apify Actors. Most teams have to write a per-provider n8n Function node or Make Module. This Actor unifies the common signing schemes behind one input shape, with one output row per check.

### Quick start

```json
{
  "mode": "hmac_sha256",
  "secret": "whsec_...",
  "signature": "sha256=abc...",
  "payloadText": "{\"event\":\"push\",\"id\":\"evt_1\"}"
}
````

Output: one row per source/payload with `ok: true|false|null`, `reason`, `mode`, `matched`, and `recomputed` (the expected signature, hex-encoded) for debugging.

### Inputs

| Field | Type | Notes |
|------|------|-------|
| `mode` | string | `hmac_sha256` (default) / `hmac_sha1` / `hmac_sha512` / `stripe` / `apify_webhook` / `bearer` |
| `secret` | string | Shared signing secret (Stripe `whsec_...`, GitHub webhook secret, etc.) |
| `signature` | string | Raw header value (`sha256=...`, `t=...,v1=...`, or `Bearer ...`) |
| `token` | string | Expected Bearer token (when `mode=bearer`) |
| `timestamp` | string | Optional override for Stripe `t=` (skips skew check) |
| `toleranceSeconds` | int | Stripe mode clock-skew tolerance (default 300) |
| `payloadText` | string | Raw webhook body to verify (one check per top-level config) |
| `contentType` | string | MIME of `payloadText` (default `application/json`) |
| `payloadUrls` | string\[] | Public URLs whose response body is verified (one check per URL) |
| `rawBody` | string | Extra inline body for an extra check (no fetch) |
| `checks` | object\[] | Array of `{mode, secret, signature, token, rawBody}` for batch verification |

### Output

Each row:

```json
{
  "source": "https://example.com/hook",
  "format": "json",
  "mode": "hmac_sha256",
  "ok": true,
  "reason": "matched",
  "recomputed": "f0e1...",
  "matched": true,
  "check": { "mode": "hmac_sha256", "headerName": null, "hasTimestamp": false, "toleranceSeconds": 300 }
}
```

A `SUMMARY` record is also written with `totalChecks`, `passed`, `failed`, `errors`, and per-mode counts.

### Supported modes

- **hmac\_sha256** / **hmac\_sha1** / **hmac\_sha512** — accepts both hex and base64 encodings; the `sha256=` / `sha1=` / `sha512=` prefix is stripped automatically. Constant-time compare via `crypto.timingSafeEqual`.
- **stripe** — parses `t=...,v1=...` header, recomputes HMAC-SHA256 over `${t}.${rawBody}`, optional timestamp skew check.
- **apify\_webhook** — Apify webhooks sign only the `resource` object (stringified). The Actor extracts it from a parsed JSON body and verifies the HMAC.
- **bearer** — constant-time compare of provided `Bearer ...` token against expected.

### Pairs with

- [`webhook-payload-debugger`](../webhook-payload-debugger) — inspect the payload after signature verifies.
- [`jws-verifier`](../jws-verifier) — verify JWT/JWS-style tokens (Auth0/Clerk/Cognito).
- [`security-headers-validator`](../security-headers-validator) — quick webops audit on a public URL.

### Pricing / cost expectations

Default 256 MB / 512 MB. Pure Node `crypto` + `fetch`; per check is sub-millisecond of CPU. **Pay-per-event** scheduled to activate after public launch: 1 charge per `signature_check` event (one webhook = one charge).

### FAQ

**Does it support JWT / JWS?** No — see the [`jws-verifier`](../jws-verifier) Actor for that. This Actor targets raw HMAC, Stripe, GitHub, Apify, and Bearer.

**Does it fetch URLs?** Yes, via `payloadUrls[]`. Public URLs only, no auth, no proxy.

**Is the compare timing-safe?** Yes — uses `crypto.timingSafeEqual` on the recomputed and provided signatures.

**Does it log secrets?** No — `secret`/`token` are read once into memory and never echoed in SUMMARY or dataset rows.

### License

MIT.

# Actor input Schema

## `mode` (type: `string`):

Used when 'checks' is empty.

## `secret` (type: `string`):

Webhook signing secret. Treated as sensitive.

## `signature` (type: `string`):

Raw header value (e.g. 'sha256=abc...' for HMAC, 't=...,v1=...' for Stripe, 'Bearer ...' for token).

## `token` (type: `string`):

Used when mode is 'bearer'.

## `timestamp` (type: `string`):

If set, used as the signed timestamp for Stripe mode (skips skew check).

## `toleranceSeconds` (type: `integer`):

Maximum allowed clock skew for Stripe-style signatures.

## `payloadText` (type: `string`):

Raw webhook body to verify against.

## `contentType` (type: `string`):

MIME of payloadText (used by the parser to choose JSON/form/XML).

## `payloadUrls` (type: `array`):

Fetch public URLs and verify each payload against the top-level check.

## `rawBody` (type: `string`):

If set, runs an additional check against this body without any fetch.

## `checks` (type: `array`):

Array of {mode, secret, signature, token, rawBody} objects; each runs against payloadText/payloadUrls or its own rawBody.

## Actor input object example

```json
{
  "mode": "hmac_sha256",
  "secret": "",
  "signature": "",
  "token": "",
  "timestamp": "",
  "toleranceSeconds": 300,
  "payloadText": "",
  "contentType": "application/json",
  "payloadUrls": [],
  "rawBody": "",
  "checks": []
}
```

# Actor output Schema

## `checkRows` (type: `string`):

Default dataset items with mode, valid, observed, expected, reason, plus original payloadText and signature when present.

## `summary` (type: `string`):

Run summary with ok, valid, mode, observed, expected, reason.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("stellar_ballet_0bu/webhook-sig-verifier").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("stellar_ballet_0bu/webhook-sig-verifier").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call stellar_ballet_0bu/webhook-sig-verifier --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=stellar_ballet_0bu/webhook-sig-verifier",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Webhook Signature Verifier",
        "description": "Verify HMAC-SHA256/SHA1/SHA512, Stripe-Signature, GitHub X-Hub-Signature-256, Apify webhook, and Bearer-token webhook payloads against a shared secret. Constant-time compare, per-check pass/fail, structured reason codes for n8n/Make/Sheets alerts.",
        "version": "0.1",
        "x-build-id": "wbHLKWNzoE26bQS7W"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/stellar_ballet_0bu~webhook-sig-verifier/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-stellar_ballet_0bu-webhook-sig-verifier",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/stellar_ballet_0bu~webhook-sig-verifier/runs": {
            "post": {
                "operationId": "runs-sync-stellar_ballet_0bu-webhook-sig-verifier",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/stellar_ballet_0bu~webhook-sig-verifier/run-sync": {
            "post": {
                "operationId": "run-sync-stellar_ballet_0bu-webhook-sig-verifier",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "mode": {
                        "title": "Verification mode (single-check fallback)",
                        "type": "string",
                        "description": "Used when 'checks' is empty.",
                        "default": "hmac_sha256"
                    },
                    "secret": {
                        "title": "Shared secret",
                        "type": "string",
                        "description": "Webhook signing secret. Treated as sensitive.",
                        "default": ""
                    },
                    "signature": {
                        "title": "Provided signature / header value",
                        "type": "string",
                        "description": "Raw header value (e.g. 'sha256=abc...' for HMAC, 't=...,v1=...' for Stripe, 'Bearer ...' for token).",
                        "default": ""
                    },
                    "token": {
                        "title": "Expected Bearer token",
                        "type": "string",
                        "description": "Used when mode is 'bearer'.",
                        "default": ""
                    },
                    "timestamp": {
                        "title": "Optional override timestamp (epoch seconds)",
                        "type": "string",
                        "description": "If set, used as the signed timestamp for Stripe mode (skips skew check).",
                        "default": ""
                    },
                    "toleranceSeconds": {
                        "title": "Tolerance (seconds, Stripe mode)",
                        "minimum": 0,
                        "maximum": 86400,
                        "type": "integer",
                        "description": "Maximum allowed clock skew for Stripe-style signatures.",
                        "default": 300
                    },
                    "payloadText": {
                        "title": "Payload text (single-check fallback)",
                        "type": "string",
                        "description": "Raw webhook body to verify against.",
                        "default": ""
                    },
                    "contentType": {
                        "title": "Content type",
                        "type": "string",
                        "description": "MIME of payloadText (used by the parser to choose JSON/form/XML).",
                        "default": "application/json"
                    },
                    "payloadUrls": {
                        "title": "Public payload URLs",
                        "type": "array",
                        "description": "Fetch public URLs and verify each payload against the top-level check.",
                        "default": [],
                        "items": {
                            "type": "string"
                        }
                    },
                    "rawBody": {
                        "title": "Raw body for single inline check (no fetch)",
                        "type": "string",
                        "description": "If set, runs an additional check against this body without any fetch.",
                        "default": ""
                    },
                    "checks": {
                        "title": "Multiple checks (advanced)",
                        "type": "array",
                        "description": "Array of {mode, secret, signature, token, rawBody} objects; each runs against payloadText/payloadUrls or its own rawBody.",
                        "default": []
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
