# Get decisions by webhook

Send signed events to your own systems when requests are created, decided, expire or are cancelled.

Channels. About 5 minutes. HTML: https://promptcompute.ai/docs/webhooks

## Before you start

- An owner or admin role
- An https endpoint you control

## Steps

1. **Add an endpoint** Under Webhooks, enter your URL and pick events. The signing secret is shown once; store it as a secret.

2. **Verify the signature** Each delivery has a `promptcompute-signature` header: `t=<unix>,v1=<HMAC-SHA256 of t.body>`. The SDKs check it and reject old timestamps. Each delivery also carries the Standard Webhooks headers `webhook-id`, `webhook-timestamp` and `webhook-signature`, signed with the same secret, so a Standard Webhooks library can check it too (give it the secret with `-` changed to `+` and `_` to `/`).

```ts
import { constructEvent } from "@promptcompute/sdk/webhooks";

const event = await constructEvent(rawBody, req.headers["promptcompute-signature"], process.env.PC_WEBHOOK_SECRET!);
if (event.type === "approval.decided") {
  // event.data.final_args is what may run
}
```

3. **Send a test event** Press Send test event. The delivery log shows the status code your endpoint returned.

4. **Handle retries** Failed deliveries retry with backoff for 24 hours. Make your handler idempotent on the event id. Replay any delivery from the log.

## Use cases

### Resume a workflow

- Situation: A Temporal or Inngest workflow waits for a decision.
- What to do: Point a webhook at a handler that signals the workflow on approval.decided.
- Result: The workflow resumes the moment someone decides.

### Mirror into your ticket system

- Situation: Your team tracks risky changes in tickets.
- What to do: Create or update a ticket on approval.created and approval.decided.
- Result: Every request has a ticket with the decision and who made it.

## What you will see

Your endpoint receives signed events, and the delivery log shows each attempt.

- The delivery log shows 200 for the test event
- Signature checks pass in your handler
- Replays arrive with the same event id

approval.decided payload:

```json
{
  "id": "evt_01j...",
  "type": "approval.decided",
  "created": 1793349840,
  "data": { "id": "apr_01j...", "status": "approved", "final_args": { "amount": 80 } }
}
```

## If something goes wrong

- **Signature check fails.** Verify the raw body, not parsed JSON, and use the secret for this endpoint. Rotating keeps the old secret valid for a while.
- **The URL is refused.** Endpoints must be https and public. Private and local addresses are blocked.
- **Duplicate events.** Retries resend the same event id. Skip ids you already handled.

## Related

- [Send requests from code](https://promptcompute.ai/docs/send-requests.md)
- [Export and verify the signed ledger](https://promptcompute.ai/docs/signed-ledger.md)
- [Decide requests](https://promptcompute.ai/docs/decide-requests.md)
