Synced from Hive. This page is pulled from hivecommons/hive@v5 during the docs build. Edit the canonical source in the Hive repository.

Task workflow notifications

A task workflow can tell another system when a run or a step finishes: hive sends a signed JSON POST to a URL you choose. Notifications are off by default and optional; nothing is sent unless every one of these holds:

  1. the hive switch workflow.tasks.notify.enabled is on (env HIVE_WORKFLOW_TASKS_NOTIFY_ENABLED);
  2. the workflow’s spec names a target in spec.notify.url;
  3. the workflow has a signing secret (created by an owner, below).

Configure

In hive.yaml:

workflow:
  tasks:
    enabled: true
    notify:
      enabled: true
      # Optional. Hosts that may be reached although they resolve to private
      # addresses (an in-cluster receiver, for example).
      allowed_private_hosts: [ci-hooks.ci.svc.cluster.local]

Both knobs are also on Settings → Workflows → Task workflows (owner only).

In the workflow:

spec:
  notify:
    url: https://ci.example.com/hooks/hive
    events: [run, step]   # run, step or both; empty means both

The URL is part of the workflow spec, so everyone who can open the dashboard can read it, in the workflow and in each run. Do not put a token in it: the signature authenticates hive.

Then create the signing secret (owner only). It is returned once; store it with the receiver. Creating it again replaces it, and deleting it stops notifications for the workflow.

curl -s -X POST https://hive.example/api/task-workflows/regression/notify/secret \
  -H "Authorization: Bearer $HIVE_TOKEN"

GET /api/task-workflows/{name}/notify shows whether the hive switch is on, whether a secret exists (when it was made and by whom, never the secret), the target host, and why the target would be refused. DELETE /api/task-workflows/{name}/notify/secret removes the secret. Each create and delete is audited.

What is sent

One request per event. Headers:

HeaderValue
Content-Typeapplication/json
X-Hive-Eventrun.finished or step.finished
X-Hive-DeliveryA unique id for this event; retries of it keep the same id
X-Hive-Signature-256sha256= and the hex HMAC-SHA256 of the raw body under the workflow’s secret

The body carries state only: ids, statuses, attempt numbers, fixed failure codes and times. It never carries params, prompts, step results, agent output, logs or credentials.

{
  "schema_version": 1,
  "event": "step.finished",
  "delivery_id": "d-6f1c2a9b0e47d3a58c21f0b4",
  "sent_at": "2026-11-30T02:14:09Z",
  "workflow": "regression",
  "revision": 3,
  "run_id": "r-20261130-0200-7f3a",
  "run_status": "running",
  "trigger": "schedule",
  "created_at": "2026-11-30T02:00:00Z",
  "started_at": "2026-11-30T02:00:02Z",
  "step": { "id": "deploy", "status": "failed", "attempt": 3, "reason": "timeout", "finished_at": "2026-11-30T02:14:08Z" }
}

A run.finished body has run_status succeeded, failed or cancelled, finished_at, and steps[] with every step in the same shape as step above. reason is one of reported-failed, timeout, no-report, preempted, agent-unavailable, delivery-failed, prompt-too-long, render-failed, run-timeout or cancelled. To read a step’s result, call the run status API, for example with a run-trigger token: GET /api/task-workflows/hooks/{name}/runs/{run}.

Verify the signature

Compute HMAC-SHA256 of the raw request body (the bytes as received, before any JSON parsing) with the secret as the key, hex-encode it, prefix sha256=, and compare it with X-Hive-Signature-256 in constant time. Reject the request if they differ. Then use delivery_id to ignore a repeat, and sent_at to reject an old request replayed later; both are inside the signed body.

Python:

import hashlib, hmac
 
def verify(secret: str, body: bytes, header: str) -> bool:
    want = "sha256=" + hmac.new(secret.encode(), body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(want, header or "")

Go:

func verify(secret string, body []byte, header string) bool {
	mac := hmac.New(sha256.New, []byte(secret))
	mac.Write(body)
	want := "sha256=" + hex.EncodeToString(mac.Sum(nil))
	return hmac.Equal([]byte(want), []byte(header))
}

Node.js:

const crypto = require("crypto");
 
function verify(secret, rawBody, header) {
  const want = "sha256=" + crypto.createHmac("sha256", secret).update(rawBody).digest("hex");
  const a = Buffer.from(want), b = Buffer.from(header || "");
  return a.length === b.length && crypto.timingSafeEqual(a, b);
}

The scheme is the same as GitHub’s X-Hub-Signature-256, so receivers that already verify GitHub webhooks can reuse their code with the hive secret.

Delivery

  • Sent from the hive process, off the runner. Hive resolves and checks the target itself and connects to the checked address; when hive’s upstream proxy applies to the host, the connection is chained through it to that address (CONNECT ip:port), so the proxy never resolves the name again.
  • Each try times out after 10 seconds. A connection failure, a timeout, 408, 429 or a 5xx is retried (a refused address is not), up to 4 tries in all, waiting 5 seconds and doubling (at most a minute). Any other 4xx is not retried. Answer 2xx to acknowledge.
  • Redirects are not followed: a 3xx counts as a failure.
  • The outcome of every delivery (delivered, failed, skipped, dropped, with the number of tries and a short reason) is recorded on the run, in notifications[] of the run detail. A failed delivery never changes the run’s result.

Which targets are allowed

The URL’s form (scheme, credentials, metadata names) is checked when the workflow is saved. The address is checked before every try, and again for every address the name resolves to when hive connects, so a name that changes its answer cannot get past the check:

  • https only. Plain http is accepted only for a loopback host (localhost, 127.0.0.1, ::1), for local testing.
  • No user name or password in the URL; the signature authenticates hive instead.
  • No private, internal or otherwise non-public address (RFC 1918, loopback, CGNAT, unique local, localhost and the like), unless the host is listed in workflow.tasks.notify.allowed_private_hosts. A loopback test receiver therefore needs both the http loopback URL and its host in that list.
  • Never a link-local address (which holds 169.254.169.254) or a cloud metadata name or address (metadata.google.internal, fd00:ec2::254, 100.100.100.200), even when listed.

Hive logs a notification with the workflow, run, event, delivery id, target host, outcome and reason. It never logs the URL’s path or query (they can hold a receiver’s token), the body’s signature, or the secret.