---
source: https://iinventedlight.com/library/notes/github-webhook-signatures.md
title: "GitHub webhook deliveries are checked with an HMAC SHA-256 signature"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "CC-BY-4.0 (GitHub Docs); PSF-2.0 (Python docs); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: GitHub Docs, Validating webhook deliveries, CC-BY-4.0 (https://raw.githubusercontent.com/github/docs/main/LICENSE). Copyright GitHub, Inc.; Python docs, hmac — Keyed-Hashing for Message Authentication, PSF-2.0 (https://docs.python.org/3/license.html)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-16
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-16
as_of: 2026-11-16
confidence: medium
untested: "Not reproduced (2026-11-16). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-web: webhook signature verification"
tags: [webhooks, hmac, github, signatures]
client: Librarian
sources:
  - id: S1
    title: "Validating webhook deliveries"
    publisher: GitHub Docs
    url: https://docs.github.com/en/webhooks/using-webhooks/validating-webhook-deliveries
    accessed: 2026-11-16
    license: "CC-BY-4.0"
  - id: S2
    title: "hmac — Keyed-Hashing for Message Authentication"
    publisher: Python docs
    url: https://docs.python.org/3/library/hmac.html
    accessed: 2026-11-16
    license: "PSF-2.0"
---
# GitHub webhook deliveries are checked with an HMAC SHA-256 signature
**Answer:** You can use a webhook secret to verify that a webhook delivery is from GitHub. Create a secret token for a webhook. Store the token securely on your server. Validate incoming webhook payloads against the token.

## The header

Each delivery has a signature header. The hash signature always starts with `sha256=`. GitHub uses an HMAC hex digest to compute the hash. The hash signature is generated using your webhook's secret token and the payload contents.

## Checking the digest

Calculate a hash using your secret token. Then compare the hash that GitHub sent with the expected hash that you calculated. The `hmac` module implements the HMAC algorithm as described by RFC 2104. The key is a bytes or bytearray object giving the secret key. When comparing a hexdigest to an externally supplied digest, use the `compare_digest` function instead of the `==` operator. The example calls compare_digest on expected_signature and signature_header.

## See also

- [github-actions-workflow-basics](https://iinventedlight.com/library/notes/github-actions-workflow-basics/)
- [python-json](https://iinventedlight.com/library/notes/python-json/)
- [github-actions-concurrency](https://iinventedlight.com/library/notes/github-actions-concurrency/)
- [github-actions-setup-python](https://iinventedlight.com/library/notes/github-actions-setup-python/)

## Claims

- id: C1
  claim: The signature header is X-Hub-Signature-256.
  source: S1
  evidence: "value of the `X-Hub-Signature-256` header."

- id: C2
  claim: The hash signature always starts with sha256=.
  source: S1
  evidence: "The hash signature always starts with `sha256=`."

- id: C3
  claim: GitHub uses an HMAC hex digest to compute the hash.
  source: S1
  evidence: "uses an HMAC hex digest to compute the hash."

- id: C4
  claim: Python recommends compare_digest instead of ==.
  source: S2
  evidence: "compare_digest` function instead of the ``==`` operator"

## Sources

- [S1] Validating webhook deliveries. GitHub Docs. https://docs.github.com/en/webhooks/using-webhooks/validating-webhook-deliveries . License: CC-BY-4.0. Accessed 2026-11-16.

- [S2] hmac — Keyed-Hashing for Message Authentication. Python docs. https://docs.python.org/3/library/hmac.html . License: PSF-2.0. Accessed 2026-11-16.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: GitHub Docs, Validating webhook deliveries, CC-BY-4.0 (https://raw.githubusercontent.com/github/docs/main/LICENSE). Copyright GitHub, Inc.; Python docs, hmac — Keyed-Hashing for Message Authentication, PSF-2.0 (https://docs.python.org/3/license.html). Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
