LiyaEngine Docs
Guides

Webhooks and approvals in your own app

Get told when a workflow needs a person, show the request in your own product, and send the decision back. Event format, signature check, retries, and the four-eyes rule.

Dashboard

A workflow that reaches an approval step pauses until a person decides. You can let your people decide in the LiyaEngine dashboard, or in your own product. This guide covers the second: LiyaEngine sends your application a signed webhook when a request is waiting, your application shows it, and your application sends the decision back.

workflow reaches an approval step
   │
   ├── LiyaEngine ──(signed POST: workflow.approval_requested)──▶ your application
   │                                                                │ shows it to the right person
   ◀── POST /v1/workflows/approvals/{id}/decision ─────────────────┘
   │
   ├── the run resumes, and LiyaEngine sends workflow.approval_decided

1. Add an endpoint

In the dashboard, go to Administration → Webhooks and choose Add endpoint. Give it a name, a public https:// address, and the events you want. The signing secret (whsec_…) is shown once, when the endpoint is created. Store it with your other secrets. If you lose it, rotate it from the endpoint's page and the old one stops working at once.

You can also manage endpoints through the dashboard API, with a dashboard login of an admin or owner:

POST   /dashboard/webhooks                    { "name": "Case tool", "url": "https://app.example.com/hooks/liya", "event_types": ["workflow.approval_requested", "workflow.approval_decided"] }
GET    /dashboard/webhooks
PATCH  /dashboard/webhooks/{id}               { "is_active": false }
DELETE /dashboard/webhooks/{id}
POST   /dashboard/webhooks/{id}/rotate-secret
POST   /dashboard/webhooks/{id}/test          sends a signed test event now
GET    /dashboard/webhooks/{id}/deliveries    recent deliveries and their attempts

A workspace can have up to 10 endpoints. The address must be reachable from the internet; addresses on private networks are refused.

2. Events

Every event has the same envelope:

{
  "id": "evt_8f2c1a9b04d3e7f5a1b2c3d4",
  "type": "workflow.approval_requested",
  "created_at": "2026-11-08T19:41:07.512Z",
  "tenant_id": "your-workspace",
  "data": { }
}

workflow.approval_requested

A run paused at an approval step and is waiting for a person.

{
  "approval_id": "cmw8r1tny001rzz22aydlwuzs",
  "workflow_id": "cmw7c2cug004ia4n6hss095dp",
  "workflow_key": "dispute-resolution",
  "workflow_name": "Dispute resolution",
  "run_id": "cmw8r1tg9001pzz22xk2m1e0a",
  "title": "Approve a provisional credit of $1249 for dispute DSP-1042?",
  "summary": "…",
  "context": { "trigger": { "dispute_id": "DSP-1042" } },
  "assignee_role": "supervisor",
  "expires_at": "2026-11-09T19:41:07.000Z",
  "decision_endpoint": "/v1/workflows/approvals/cmw8r1tny001rzz22aydlwuzs/decision"
}

context is what the approval step chose to show the reviewer: the request as it arrived, and step results only if the workflow author turned that on. If it would make the event larger than 64 KB, it is left out and context_truncated: true is sent instead; fetch the full approval with GET /v1/workflows/approvals/{approval_id}.

workflow.approval_decided

An approval was approved, rejected or timed out, and the run resumed. It is also sent when the decision was made in the dashboard, so your application can close the request it showed.

{
  "approval_id": "cmw8r1tny001rzz22aydlwuzs",
  "workflow_id": "cmw7c2cug004ia4n6hss095dp",
  "run_id": "cmw8r1tg9001pzz22xk2m1e0a",
  "decision": "approved",
  "status": "approved",
  "decided_by": "[email protected] (via API key cmw7bxw6k0005a4n6ixaff1nt)",
  "decided_by_type": "api",
  "note": "Within policy"
}

status is approved, rejected or expired (a time limit ran out and the step's automatic outcome was applied).

3. Check the signature

Each request carries:

HeaderValue
X-Liya-Signaturesha256= followed by the hex HMAC-SHA256 of {timestamp}.{raw body}, keyed with your endpoint's secret
X-Liya-TimestampWhen it was sent, in milliseconds since 1970
X-Liya-EventThe event type
X-Liya-Event-IdThe event's id. The same for every endpoint that receives this event, and for every retry
X-Liya-DeliveryThis delivery's id

Recompute the signature from the raw request body (before it is parsed), compare in constant time, and reject anything older than five minutes.

// Node.js (Express): use express.raw({ type: "application/json" }) on this route
import { createHmac, timingSafeEqual } from "node:crypto";

export function verify(secret: string, headers: Record<string, string | undefined>, rawBody: string): boolean {
  const timestamp = headers["x-liya-timestamp"];
  const signature = headers["x-liya-signature"];
  if (!timestamp || !signature) return false;
  if (Math.abs(Date.now() - Number(timestamp)) > 5 * 60 * 1000) return false;
  const expected = "sha256=" + createHmac("sha256", secret).update(`${timestamp}.${rawBody}`).digest("hex");
  const a = Buffer.from(expected), b = Buffer.from(signature);
  return a.length === b.length && timingSafeEqual(a, b);
}
# Python
import hmac, hashlib, time

def verify(secret: str, headers: dict, raw_body: bytes) -> bool:
    ts, sig = headers.get("X-Liya-Timestamp"), headers.get("X-Liya-Signature")
    if not ts or not sig or abs(time.time() * 1000 - int(ts)) > 5 * 60 * 1000:
        return False
    expected = "sha256=" + hmac.new(secret.encode(), f"{ts}.".encode() + raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, sig)

Answer with any 2xx status once you have stored the event. Do the slow work afterwards: a receiver that takes more than 10 seconds to answer counts as a failure.

4. Delivery, retries and duplicates

  • Retries. A delivery that fails (a non-2xx answer, a timeout, or no connection) is tried again after 30 seconds, 2 minutes, 10 minutes, 1 hour and 6 hours. After the sixth attempt it is marked failed and stays in the endpoint's delivery list.
  • At least once. An event can arrive more than once, for example when LiyaEngine restarts while a request is in flight. Deduplicate on X-Liya-Event-Id.
  • Order. Events for different approvals can arrive in any order. For one approval, approval_requested is sent before it can be decided.
  • A receiver that is down is not hammered: after two failures in a row, LiyaEngine leaves that endpoint alone until its next sweep (every 30 seconds), and other endpoints are not held up.
  • Check it. Send test event on the endpoint's page sends a signed webhook.test event and shows what your receiver answered.

5. Send the decision back

curl -X POST https://api.liyaengine.ai/v1/workflows/approvals/{approval_id}/decision \
  -H "Authorization: Bearer $LIYA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "decision": "approve", "note": "Within policy", "decided_by": "[email protected]" }'

The response carries the resumed run's status, which is awaiting_approval again if the workflow has a further approval step.

Who may decide is your application's call

An API key stands for your whole application, so LiyaEngine cannot tell which of your people is deciding, or whether they are allowed to. Two rules follow:

  1. Send decided_by. A decision without it is refused with 400 DECIDED_BY_REQUIRED. It is recorded on the approval, in the audit log and in the run's output, next to the API key.
  2. Check authority in your own system first. The approval step's who can decide setting (a minimum role, or named people) applies to people using the LiyaEngine dashboard. For API decisions, your application decides who may approve, using its own roles. The assignee_role in the event tells you what the workflow author intended.

Four eyes: someone other than the requester

An approval step can require a different person from whoever started the run. Turn on A different person must approve on the step. To use it with API-started runs, send requested_by when you start the run, naming the person it is for:

curl -X POST https://api.liyaengine.ai/v1/workflows/dispute-resolution/run \
  -H "Authorization: Bearer $LIYA_API_KEY" -H "Content-Type: application/json" \
  -d '{ "input": { "dispute_id": "DSP-1042", "…": "…" }, "requested_by": "[email protected]" }'

A decision whose decided_by (or, in the dashboard, whose user) is the same person is refused with 403 SAME_PERSON; the comparison ignores case. Notes:

  • If the run was started without requested_by (a webhook or schedule trigger, say), nobody is known to be the requester, so the rule cannot apply and any approver may decide.
  • Runs started from the editor's Test run never enforce it, because they exist to try the flow out.
  • GET /v1/workflows/approvals/{id} returns require_different_person and requested_by, so your interface can say why a person is not offered the decision.

On this page