Developers

Webhooks.

Hear from a session when it's ready, when a turn ends, when it needs you, and when it opens a pull request.

Events

A session started through the API tells what it does to the webhook_url it was started with, and to the endpoint set beside the key that started it. Each is a signed POST of JSON.

EventWhen
workspace.readyIts setup ended and its prompt was sent
turn.completedA turn is over (data.turn.last_message is what it said)
needs_inputIt asked a question, or for secrets
pr.openedA pull request of its showed up
errorIts setup failed, or it did later

Check it came from Outrunner

Each delivery carries Outrunner-Signature: t=<unix seconds>,v1=<hex>, an HMAC-SHA256 of <t>.<body> with the signing secret on the settings page. Check it, and turn away one more than five minutes old.

Node.js
import { createHmac, timingSafeEqual } from "node:crypto";

function fromOutrunner(secret, body, header) {
  const { t, v1 } = Object.fromEntries(header.split(",").map((p) => p.split("=")));
  if (Math.abs(Date.now() / 1000 - Number(t)) > 300) return false;
  const mac = createHmac("sha256", secret).update(`${t}.${body}`).digest("hex");
  return v1?.length === mac.length && timingSafeEqual(Buffer.from(v1), Buffer.from(mac));
}

A delivery counts once it's answered 2xx within 10 seconds. Otherwise it's tried again for about nine hours.

Something unclear? Let us know ↗