Webhooks
Notify other services about events – with signature, retries and delivery history.
A webhook sends an HTTP POST with JSON to a URL of your choice when selected events happen – for example to a chat, a deploy service or your own script.
Levels#
| Level | Applies to | Set up under |
|---|---|---|
| Repository | one repository | Repository → Settings → Webhooks |
| Owner | all repositories of an account or organization | account or organization settings |
| System | the whole instance | admin area (administrators only) |
A webhook has a target URL, an optional secret, the events you want and optionally a branch filter (e.g. main or release/*).
Events#
| Event | When |
|---|---|
push | push to a branch |
branch.created, branch.deleted | branch created or deleted |
tag.created, tag.deleted | tag created or deleted |
repository.created, repository.deleted | repository created or deleted |
issue.created, issue.updated, issue.closed | issue created, changed, closed |
issue.comment | comment on an issue |
pull_request.created, .updated, .closed, .merged | pull request created, changed, closed, merged |
pull_request.comment, pull_request.review | comment or review on a pull request |
release.published | release published |
workflow_run.started, workflow_run.completed | workflow run started or completed |
user.created, organization.created | system webhooks only: account or organization created |
Request#
Every delivery is a POST with Content-Type: application/json and these headers:
| Header | Content |
|---|---|
X-Codeny-Event | name of the event |
X-Codeny-Delivery | unique ID of the delivery |
X-Codeny-Signature-256 | sha256=<HMAC> over the raw body, only with a secret |
Verifying the signature#
import hmac, hashlib
def valid(secret: bytes, body: bytes, header: str) -> bool:
expected = "sha256=" + hmac.new(secret, body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, header)
# header = request.headers["X-Codeny-Signature-256"]Always compare against the unmodified body and in constant time.
Delivery and retries#
Codeny waits at most 10 seconds for a response. Any status other than 2xx counts as failure and is retried after 1 min, 5 min, 30 min, 2 h and 6 h – 6 attempts in total. The delivery history shows every attempt with its status and lets you redeliver.
For security reasons Codeny does not deliver to addresses in local or private networks (loopback, 10.x, 192.168.x etc.) and does not follow redirects. Secrets are stored encrypted.
Was this page helpful?