Approvals and notifications
When a rule asks for approval, Sefra holds the request and notifies your team. Nothing reaches your system until the required people have decided.
Start from a clean sandbox, in its directory:
./sandbox destroy
./sandbox up
Three ways to decide
Section titled “Three ways to decide”| Where | Best for | Evidence recorded |
|---|---|---|
Approval page, at /approvals on the operator listener |
Everyday decisions by people | oidc: a fresh sign-in at your identity provider |
| Console, under Approvals | People who already work in the console | oidc |
CLI, sefra approvals approve |
Operators and scripts run by a person | token: a valid access token |
A rule can demand the stronger level with "min_evidence": "oidc". Sefra then refuses a CLI decision, and the person must use the approval page.
What Sefra guarantees
Section titled “What Sefra guarantees”- The person approves what they saw. The decision is bound to a hash of the exact request. If the request differs, the approval does not apply.
- Requesters can be excluded. With
distinct_from_requesteron a rule, neither the agent nor the user it acts for can approve. Set it on every rule unless you have a reason not to. - Policy runs again. Before acting, Sefra re-evaluates with fresh facts. If the budget has since run out, the approved order is still refused.
- Approvals expire. The default is 24 hours, after which the execution ends with
APPROVAL_EXPIRED.
The agent’s rationale is shown to the approver, labelled as unverified. Treat it as a claim and not as evidence.
Receive notifications
Section titled “Receive notifications”Sefra posts two kinds of webhook, configured in webhooks:
| Type | Sent when |
|---|---|
approval.requested |
A person needs to decide |
operator.alert |
An execution needs an operator, or a workflow could not start |
Point them at a small service that forwards to your chat or paging tool. A delivery that fails is retried for one hour, and each attempt is in the audit trail. Each retry has the same id, so drop repeats by that field. After that hour Sefra stops trying, and an approval can then wait unnoticed until it expires, so monitor your receiver and check the console’s overview.
In the sandbox, webhooks land in the sample ERP’s inbox. Create one to look at:
AGENT=$(./sandbox token agent)
curl -sS -o /dev/null -X POST http://127.0.0.1:18180/v1/executions \
-H "Authorization: Bearer $AGENT" -H "Content-Type: application/json" \
-H "Idempotency-Key: webhook-example-0001" \
-d '{"intent": "procurement.create_purchase_order",
"input": {"vendor_id": "v_1001", "sku": "WHITEBOARD", "quantity": 25,
"unit_price_minor": 100000, "currency": "EUR", "department": "it-ops"}}'
sleep 2
./sandbox erp state | jq '.webhooks[-1].body | {type, id, required: .data.required}'
Verify the signature
Section titled “Verify the signature”Always verify a webhook before acting on it. Each carries two headers:
| Header | Value |
|---|---|
X-Sefra-Timestamp |
Unix seconds when it was sent |
X-Sefra-Signature |
v1= and the hex HMAC-SHA256 of <timestamp>.<raw body>, keyed with your signing secret |
Refuse a timestamp more than five minutes from now, and compare signatures in constant time. Compute the HMAC over the raw bytes you received, before parsing the JSON. In Python:
import hashlib, hmac, time
def verify(secret: bytes, timestamp: str, signature: str, raw_body: bytes) -> bool:
if abs(time.time() - int(timestamp)) > 300:
return False
signed = timestamp.encode() + b"." + raw_body
expected = "v1=" + hmac.new(secret, signed, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, signature)
Summary lines can contain values from the request, such as an amount or a vendor name. Fields your bundle marks as sensitive are redacted, so mark them, and keep the receiver inside your trust boundary.