Skip to content
Get started

Actions: what happens after a decision

Use with an AI tool
refund: if @refund is true, min_p 0.8webhook to a local receiver, CURVA_ALLOW_PRIVATE_HOOKSCallerCurvaLocal receiverI was charged twice, refund me nowrefund yes, p 0.9997Kimi K2.5 on Bedrock, 0.37 sactionPOST, 1.4 ms p50HMAC-SHA256, t=, v1=True as sent, False +1 byte503try 2503try 35030.50 s1.00 ssame idempotency key each timedlv_1957d88b63e1f4fbfailedattempts 3, 1,508 ms, HTTP 503Replaysame body, same key, fresh t200dlv_1957d88b63e1f4fbdeliveredattempts 4, signature valid, last_error cleared

Click a step to see it happen.

  1. 1 Trigger checked

    Before any model call, Curva checks each trigger: its answers must exist, its address must be public https or on your allow list, and a webhook needs the project's signing secret. A mistake gets an error sentence and no model is paid for.

    In the example: Trigger refund: if @refund is true, min_p 0.8, webhook to a local receiver we listed in CURVA_ALLOW_PRIVATE_HOOKS.

  2. 2 Trigger fires

    Once the decision is answered, every condition in if must hold, and the lowest confidence among those answers must reach min_p. The action gets an id, the audit log records it, and it comes back in actions with the reason.

    In the example: I was charged twice, refund me now: refund yes, p 0.9997. Kimi K2.5 on Bedrock answered in 0.37 s, and the action came back with the decision.

  3. 3 Delivery

    The send runs beside the decision, so a slow receiver never holds it up. Each destination is its own delivery, and at most 256 are in flight on a server. Chat URLs get a readable message, but real chat channels have not been tested, only local receivers.

    In the example: The POST reached the local receiver as the caller got its answer. The guide measures 1.4 ms p50 from decision to POST on one machine.

  4. 4 Signature

    A webhook POST carries the action id as its idempotency key and an HMAC of the time, the key and the raw body. Each attempt is signed with a fresh time, and the SDKs refuse one more than 300 seconds off. Check it on the raw body, before parsing.

    In the example: verify_webhook returned True on the body as sent, and False once we added one byte.

  5. 5 Retries

    A delivery is tried up to 3 times when the receiver is down, times out, or answers 408, 429 or 5xx. Any other 4xx is not retried, because the receiver has said no.

    In the example: Our receiver answered 503 three times, 0.50 s and then 1.00 s apart, with the same idempotency key each time.

  6. 6 Delivery log

    After its last try, each delivery is logged per project with its status, attempts, latency and last error. The log shows only the scheme and host, because the path of a chat URL is its token. It keeps the newest 10,000 per project, for up to 30 days.

    In the example: dlv_1957d88b63e1f4fb: failed, attempts 3, 1,508 ms, the receiver answered HTTP 503.

  7. 7 Replay

    A replay sends the same body with the same idempotency key, signed with a fresh time, so your receiver can skip one it has handled. It updates the same log entry. The address is kept encrypted, so this needs CURVA_MASTER_KEY.

    In the example: With the receiver answering 200, the replay of that delivery succeeded: status delivered, attempts 4, signature valid, last_error cleared.

A trigger names the answers to act on and where to send them. Add triggers to any decision:

import curva
d = curva.decide("I was charged twice, refund me now", {"refund": "Asks for a refund?"},
triggers={"refund": {"if": {"@refund": True}, "slack": "https://hooks.slack.com/services/T000/B000/XXXX"}})
print(d.actions) # [{"name": "refund", "id": "act_...", "because": {"refund": True, "p": 0.97}}]
import { decide } from "curva-ai";
const d = await decide("I was charged twice, refund me now", { refund: "Asks for a refund?" }, {
triggers: { refund: { if: { "@refund": true }, slack: "https://hooks.slack.com/services/T000/B000/XXXX" } },
});
console.log(d.actions);

The Slack channel gets one readable line:

Curva action refund: refund yes, 97% sure. Decision dec_..., project default.

The decision comes back as soon as it is answered. The message is sent beside it, so a slow receiver never holds up a decision.

Each trigger takes any of these, one URL each, all sent when it fires:

Field The URL What is posted
webhook your own https endpoint the action as JSON, signed (see Your own webhook)
slack a Slack incoming webhook, https://hooks.slack.com/services/... {"text": ...}
teams a Teams Workflows or incoming-webhook URL an Adaptive Card with the same line
discord a Discord channel webhook, https://discord.com/api/webhooks/... {"content": ...}, with mentions off
telegram https://api.telegram.org/bot<token>/sendMessage?chat_id=<chat id> {"chat_id": ..., "text": ...}

For email, SMS, a CRM or a sheet, send the webhook to n8n, Zapier or Make and let the workflow take it from there. Any tool that accepts an HTTP POST works the same way (any HTTP tool).

"triggers": {
"end_call": {"if": {"@verdict": "block", "@pressure": true}, "min_p": 0.9,
"webhook": "https://app.example/hooks/curva", "slack": "https://hooks.slack.com/services/...",
"timeout_ms": 3000}
}
  • if: the answers that must all hold, as "@key": answer. A list means any of them, and a score takes {"gte": 2}.
  • min_p: the least calibrated confidence for the answers in if (default 0).
  • timeout_ms: how long to wait for each destination on each attempt (default 5000, at most 30000).
  • repeat: on /v1/listen and /v1/watch, fire every time it holds, not once per event.
  • on_fallback: also fire on a fallback answer (when the model missed the deadline).

The same triggers work on POST /v1/decide, live calls (voice) and live video (watch). In an ask file, write each destination as a line under the rule: - slack: https://hooks.slack.com/services/..., and likewise - webhook:, - teams:, - discord: and - telegram:. A decision sent with an ask file fires the file’s alerts.

curva map writes its answers to a file and fires nothing; run each line through /v1/decide with triggers when the rows should act.

Make the project’s signing secret once, on the server’s database (it is shown once). This command and signing both need CURVA_MASTER_KEY:

curva keys webhook-secret default

Each POST carries x-curva-idempotency-key, the action’s id, which stays the same on every retry and replay, and x-curva-signature: t=<unix seconds>,v1=<hex>, where v1 is the HMAC-SHA256 of <t>.<idempotency key>.<raw body> under the secret. Every attempt and replay is signed again with a fresh t. Check the signature on the raw body, before parsing it; the SDKs refuse a t more than 300 seconds from now (pass a different tolerance as the last argument), so a captured request cannot be sent again later:

from curva import verify_webhook
@app.post("/hooks/curva")
def hook():
headers = request.headers
if not verify_webhook(request.get_data(), headers.get("x-curva-signature"), SECRET, headers.get("x-curva-idempotency-key")):
return "", 401
return handle(request.get_json())
import { verifyWebhook } from "curva-ai";
const body = await request.text();
const ok = await verifyWebhook(body, request.headers.get("x-curva-signature"), SECRET, request.headers.get("x-curva-idempotency-key"));
if (!ok) throw new Error("not from Curva");

Keep the idempotency keys you have handled for longer than the tolerance and skip a repeat: a retry or replay is the same action.

The body is the action with where it came from:

{"type": "action", "name": "end_call", "id": "act_5f1c...", "because": {"verdict": "block", "pressure": true, "p": 0.94},
"decision": "dec_...", "project": "default", "at": 1792519527805}

Live calls add call, live video adds stream, and a speculative alert on video is followed by a confirmed or retracted event under the id <action id>.confirmed.

curva webhook test https://app.example/hooks/curva --project default

sends a sample action, signed like a real one, and prints what came back:

delivered to webhook (https://app.example): HTTP 200 in 143 ms, 1 attempt

Slack, Teams, Discord and Telegram URLs are recognised by their address and get their own message.

A delivery is tried up to 3 times, 0.5 s and then 1 s apart, when the receiver is down, times out, or answers 408, 429 or 5xx. Any other 4xx is not retried: the receiver has said no.

Every delivery is logged per project, with its status (delivered or failed), attempts, latency and last error:

curva webhook log --project default --failed
curva webhook replay dlv_9c2e41d07b3a5f86

Over HTTP: GET /v1/deliveries?project=default&status=failed and POST /v1/deliveries/<id>/replay. A replay sends the same body with the same idempotency key, signed again with a fresh t.

At most 256 deliveries are in flight on a server at once, and one project gets at most half of them; set CURVA_DELIVERIES_IN_FLIGHT to change the server’s number. A delivery past the cap is not sent: it is logged as failed with too many deliveries in flight and 0 attempts, so you can replay it.

The log keeps the newest 10,000 deliveries per project, for up to 30 days. It shows only the scheme and host of each URL, because the path of a Slack, Discord or Telegram URL is its token. The full URL is kept encrypted with CURVA_MASTER_KEY; without that key, deliveries are still logged but cannot be replayed.

From the decision to the signed POST reaching a receiver on the same machine (2026-10-27, release build, the decision’s at time to the receiver’s clock, so up to 1 ms is rounding):

Where the decision came from n p50 p99
POST /v1/decide 100 1.4 ms 11.3 ms
/v1/listen, a live call 33 1.9 ms 3.8 ms
/v1/watch, a live camera 34 2.0 ms 3.6 ms

On /v1/decide, the POST reached the receiver 0.3 ms (p50) after the caller had the decision. A receiver on the internet adds its own network time. curva webhook log --failed listed a delivery that failed after its 3 tries, and curva webhook replay sent it again with the same idempotency key once the receiver was back.

Curva posts only to public https addresses. Private, loopback and link-local addresses, plain http and redirects to any of them are refused, so a trigger cannot reach inside your network. For a receiver on your own network, list it by host and port when you start the server:

CURVA_ALLOW_PRIVATE_HOOKS=hooks.internal:8080,10.0.0.5:443 curva serve

Those hosts may use plain http, and redirects from them are not followed.