Webhook Triggers
A trigger fires from outside Harmony and spawns an agent run (Decision 0017). The webhook trigger is the one that's live: an external system POSTs to your trigger's URL, Harmony verifies the signature, and — if it checks out — starts a fresh agent run and hands you back the ids to watch it.
This is the inbound direction. Harmony is the receiver. (Outbound delivery — Harmony POSTing our events to your URL — is a separate, planned feature; see the note at the bottom.)
The endpoint
POST /api/v1/webhooks/{triggerId}
The triggerId is the trigger you created in your workspace. The route is public — there's no API key — so the signature is the authentication.
On a valid signature, Harmony starts a run and returns 202 immediately. The agent loop runs in the background:
{
"ok": true,
"run": { "id": "run_…" },
"thread": { "id": "thr_…" },
"stream": "harmony://ws/_/runs/run_…"
}
Each fire gets its own thread — no carry-over between calls. The stream field is the SSE URL for watching that run unfold; subscribe to it to see events as they happen.
Signing requests
Every request must carry an X-Harmony-Signature header. The value is an HMAC-SHA256 of the raw request body — nothing else, no timestamp prefix — keyed with the trigger's signing secret. Two formats are accepted:
- bare lowercase hex:
3f2a… - GitHub style:
sha256=3f2a…
The signing secret is per-trigger. It's minted once when you create the trigger (prefixed whsec_), shown to you exactly once, and stored from then on as a workspace Credential linked via the trigger's authBindingId. Lost it? Recreate the trigger.
Hardening
The receiver is deliberately strict:
| Condition | Result |
|---|---|
Signature isn't exactly 64 hex chars (^[0-9a-f]{64}$) | 401, rejected before any decode |
| Signature doesn't match | 401, increments the trigger's failureCount |
| Missing signature | 401 |
Body exceeds 256 KB (Content-Length or actual length) | 413 |
| Trigger is disabled | 423 |
| No such webhook trigger | 404 |
The comparison is constant-time (timingSafeEqual) over fixed 32-byte buffers. Shape validation happens before the decode so malformed input can't become a timing oracle. A successful fire resets failureCount to 0 and stamps lastFiredAt.
Verifying on your side
If you ever receive a signed request from Harmony (or want to mirror our scheme), verify like this:
import { createHmac, timingSafeEqual } from "node:crypto";
function verify(secret: string, rawBody: string, header: string | null): boolean {
if (!header) return false;
const provided = header.startsWith("sha256=") ? header.slice(7) : header;
if (!/^[0-9a-f]{64}$/i.test(provided)) return false;
const expected = createHmac("sha256", secret).update(rawBody).digest(); // 32 bytes
const providedBuf = Buffer.from(provided, "hex"); // 32 bytes
try {
return timingSafeEqual(expected, providedBuf);
} catch {
return false;
}
}
Note the HMAC is over rawBody only — sign and verify against the exact bytes you send, before any JSON re-serialization.
Sending a request
Compute the signature over the exact body you're sending, then post it:
TRIGGER_ID="trg_…"
SECRET="whsec_…"
BODY='{"event":"deploy.finished","repo":"acme/api","sha":"a1b2c3"}'
SIG=$(printf '%s' "$BODY" | openssl dgst -sha256 -hmac "$SECRET" | sed 's/^.* //')
curl -X POST "https://platform.groupany.ai/api/v1/webhooks/$TRIGGER_ID" \
-H "Content-Type: application/json" \
-H "X-Harmony-Signature: sha256=$SIG" \
-d "$BODY"
printf '%s' matters — it sends the body without a trailing newline, so the bytes you sign are the bytes Harmony hashes.
Shaping the agent's input
By default the raw request body becomes the agent's input verbatim. To shape it into something more useful, set a prompt_template on the trigger's config. Placeholders are substituted from the inbound request:
| Placeholder | Resolves to |
|---|---|
{{body}} | The raw request body, as received |
{{body.json}} | The parsed JSON, re-stringified |
{{body.<path>}} | A dot-path into the parsed JSON, e.g. {{body.repo}} or {{body.commit.author}} |
{{header.X-Foo}} | A request header by name (case-insensitive) |
An empty or whitespace-only template falls back to the raw body. Unknown placeholders, missing JSON paths, and absent headers resolve to an empty string.
Example template:
A deploy just finished for {{body.repo}} at {{body.sha}}.
Check the changelog and post a summary to #releases.
Other trigger kinds
The TriggerKind enum reserves four kinds. Only webhook is wired today:
| Kind | Status |
|---|---|
webhook | Live |
cron | Enum value reserved, not yet wired |
email_received | Enum value reserved, not yet wired |
repo_event | Enum value reserved, not yet wired |
Planned: outbound webhook delivery — Harmony POSTing session and workspace lifecycle events to a URL you register — is not yet built. This page covers inbound triggers only.