Events and Webhooks¶
Gradient records each state change as a typed event. Event names use dotted notation, such as build.completed, task.star, or proto.client.nar_push.
Two delivery classes exist:
- Durable events land in pending deliveries alongside the change that triggered them. Gradient then delivers them to webhooks and task actions and retries on failure.
- Firehose-only events carry high-rate telemetry. The debug stream is the only place where they appear.
GET /api/v1/events/catalog lists all event names together with their durable flag.
Envelope¶
All three payloads use one JSON structure: websocket messages, webhook bodies, and task action bodies.
{
"event": "build.completed",
"at": "2026-09-26T12:00:00.123Z",
"content": { "build_id": "...", "derivation_build": "...", "evaluation_id": "...", "status": 3, "status_name": "completed", "task": "...", "project": "..." }
}
Event Families¶
| Family | Durable | Examples |
|---|---|---|
build.<status> |
yes (entry points) | build.queued, build.started, build.completed, build.failed, build.substituted |
evaluation.<phase> |
yes | evaluation.queued, evaluation.building, evaluation.failed, evaluation.aborted |
fork_pull_request_approval.<phase> |
yes | fork_pull_request_approval.needs_maintainer_approval, fork_pull_request_approval.evaluation_started_after_approval, fork_pull_request_approval.approval_without_changed_file_matching_trigger_path |
exec_job.<status> |
yes | exec_job.queued, exec_job.started, exec_job.phase, exec_job.completed, exec_job.failed, exec_job.aborted |
project.*, task.*, cache.* |
yes | project.create, task.star, task.action.update, cache.nar.upload, cache.member.create |
gc.* |
yes | gc.swept, gc.deep_finished |
worker.demand |
yes, team webhooks only | waiting evaluations that need a system, feature, network, secrets or eval worker missing from the connected workers. Delivered once per team granting its workers to the project |
| account activity | yes, instance webhooks only | login.success, api_key.create, session.revoke |
build.status_changed, build.progress, evaluation.progress, evaluation.activity |
no | each build job transition, build transfer progress, fetch and eval progress |
graph.* |
no | graph.recorded, graph.demoted, graph.collected |
worker.* |
no | worker.connected, worker.job_dispatched, worker.queue_depth |
vm.state |
no | a worker's VM became warm, running or stopped, with the exec job it ran |
proto.client.*, proto.server.* |
no | message type, worker, job id and size, never the payload |
cache.changed, cache.nar.fetched, cache.narinfo.served, cache.nar.signed |
no | cache traffic. cache.nar.signed marks a fresh upload as signed into a cache |
Every build.* event with a per-evaluation build_id also includes derivation_build. That field identifies the shared build, and worker.job_dispatched names this same build as its build_id.
The build.*, evaluation.* and exec_job.* events include status_name, a snake_case status name, in addition to the numeric status. Example values include completed, failed_permanent and running.
Events build.*, evaluation.*, and exec_job.* include allows_project_credentials_and_privileged_actions. The value is false for evaluations of pull requests from forks that maintainers have not approved. Such evaluations receive neither project secrets nor SSH keys. That event doesn't trigger open_pr or start_evaluation task actions.
Webhooks¶
Manage webhooks under Webhooks in the project settings, on the cache page or in the team settings. Superusers manage instance webhooks under Job Board -> System Health -> Instance Webhooks. Task actions receive the same envelope for single tasks.
| Scope | API | Who may manage | Receives |
|---|---|---|---|
| Project | /api/v1/projects/{project}/webhooks |
manageWebhooks |
events of the project, its tasks and evaluations |
| Cache | /api/v1/caches/{cache}/webhooks |
manageCacheWebhooks |
events of the cache |
| Team | /api/v1/teams/{team}/webhooks |
team Admin | team events (worker.demand, team.worker.*, team.webhook.*), never events of granting projects |
| Instance | /api/v1/admin/webhooks |
superuser | every durable event |
eventsis a list of globs (build.*,task.star). With an empty list, the webhook receives everything in scope.- The API exposes the signing secret exactly once, on create and on
rotate-secret. - Gradient retries a failed delivery (transport error or non-2xx) up to 6 times in total. Backoff starts at 30 s and caps at 8 min. After the last attempt, Gradient dead-letters the delivery.
- Gradient can store
build.<status>andexec_job.<status>events only if consumers already exist for the evaluation task at the time of event recording. These consumers are active task actions and status reports for commits to the Git host. Active webhooks for a project or an instance also count. A webhook or task action created later can get no such events for builds and exec jobs that were reported before that webhook or task action existed. POST .../{id}/testdispatches awebhook.pingimmediately and gives back the recorded delivery.
Request Headers
Content-Type: application/json
X-Gradient-Event: build.completed
X-Gradient-Delivery: <uuid> # stable across retries, for deduplication
X-Gradient-Signature: sha256=<hex HMAC-SHA256(secret, raw body)>
Signature Verification (Python)
import hashlib
import hmac
def verify(secret: str, body: bytes, header: str) -> bool:
expected = "sha256=" + hmac.new(secret.encode(), body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, header)
Firehose¶
Warning
Use the firehose for debugging only. Each server process can send the stream on a best-effort basis and drop events during lag. Other systems receive events through webhooks.
GET /api/v1/metrics/events (superuser) upgrades to a websocket. An API key needs readSuperuser and no project or cache pin. Every event, durable or not, flows through it as one JSON envelope per frame. The ?events= parameter accepts comma-separated globs.
websocat -H "Authorization: Bearer $TOKEN" "wss://gradient.example.com/api/v1/metrics/events?events=build.*,proto.client.*"
A lagging subscriber will receive {"event":"stream.lagged","content":{"skipped":N}} and continue from the newest event.