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#

LevelApplies toSet up under
Repositoryone repositoryRepository → Settings → Webhooks
Ownerall repositories of an account or organizationaccount or organization settings
Systemthe whole instanceadmin 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#

EventWhen
pushpush to a branch
branch.created, branch.deletedbranch created or deleted
tag.created, tag.deletedtag created or deleted
repository.created, repository.deletedrepository created or deleted
issue.created, issue.updated, issue.closedissue created, changed, closed
issue.commentcomment on an issue
pull_request.created, .updated, .closed, .mergedpull request created, changed, closed, merged
pull_request.comment, pull_request.reviewcomment or review on a pull request
release.publishedrelease published
workflow_run.started, workflow_run.completedworkflow run started or completed
user.created, organization.createdsystem webhooks only: account or organization created

Request#

Every delivery is a POST with Content-Type: application/json and these headers:

HeaderContent
X-Codeny-Eventname of the event
X-Codeny-Deliveryunique ID of the delivery
X-Codeny-Signature-256sha256=<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.

Last updated