Webhooks
Reference

Webhooks

Subscribe to call lifecycle events. HMAC-signed deliveries with retries and an audit log.

Octew Voice AI posts call lifecycle events to URLs you register, with an HMAC signature on every delivery. This is the primary integration point for syncing call results back into your stack.

There is also a flow-level on_call_end.fetch mechanism (described at the bottom) that fires a single configured request from inside a flow when it terminates — useful for one-shot integrations that don’t want to manage subscriptions.

Subscribe

curl -X POST "$VOICEAGENT_BASE/v1/webhooks" \
  -H "Authorization: Bearer $VOICEAGENT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://yourapp.example.com/voiceagent-events",
    "events": ["call.completed", "call.failed"],
    "headers": { "X-Tenant-Id": "your-internal-id" },
    "description": "Production event sink"
  }'

The 201 response is the only time the secret is shown. Save it in the same place you keep your platform credentials.

{
  "id": "1d9f6cde-...",
  "url": "https://yourapp.example.com/voiceagent-events",
  "events": ["call.completed", "call.failed"],
  "headers": { "X-Tenant-Id": "your-internal-id" },
  "secret": "0da7b9714041c66895780041b709401488f9004d263e2a2ee62f697044438ef5",
  "active": true,
  "created_at": "...",
  "consecutive_failures": 0
}

Supported events

EventFires when
call.completedA call reaches a terminal state with status = completed. Body has the full call shape (transcript, recording_url, cost, lead_score, outcome, variables, metadata).
call.failedA call ends with any non-completed terminal status (failed, no_answer, voicemail, dnc).

Wire format

POST <your subscription url>
Content-Type: application/json
X-VoiceAgent-Signature: <hex sha256 hmac of raw body>
X-VoiceAgent-Event: call.completed
X-VoiceAgent-Delivery: <delivery row id, stable across retries>
<...your custom headers, verbatim...>

{
  "event": "call.completed",
  "delivered_at": "2026-04-27T10:15:11.612Z",
  "call": {
    "id": "5b8a14f0-...",
    "call_sid": "CA...",
    "status": "completed",
    "duration_ms": 38716,
    "recording_url": "https://...",
    "transcript": "...",
    "lead_score": "warm",
    "outcome": "qualified",
    "variables": { /* what you passed on POST /v1/calls */ },
    "metadata":  { /* what you passed on POST /v1/calls */ },
    "...": "..."
  }
}

The call object is identical to GET /v1/calls/:id.

Verify the signature

Compute HMAC-SHA256 over the raw request body using your subscription secret:

import crypto from "crypto";

function isValid(rawBody: string, signatureHeader: string, secret: string): boolean {
  const expected = crypto
    .createHmac("sha256", secret)
    .update(rawBody)
    .digest("hex");
  const a = Buffer.from(expected, "utf8");
  const b = Buffer.from(signatureHeader, "utf8");
  return a.length === b.length && crypto.timingSafeEqual(a, b);
}

You must verify against the raw body bytes, not a re-stringified parsed object — Express’s express.json({ verify }) and similar parsers expose a req.rawBody you can use.

Retry policy

Each delivery is attempted up to 4 times with exponential backoff (1s, 4s, 16s) on:

  • any non-2xx response
  • a network error
  • a request taking longer than 8 seconds

After 5 consecutive failed deliveries across all events, the subscription is auto-disabled. Re-enable via:

curl -X PATCH "$VOICEAGENT_BASE/v1/webhooks/<id>" \
  -H "Authorization: Bearer $VOICEAGENT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "active": true }'

This resets the failure counter to zero.

Audit log

Every attempt — successful or not — is recorded:

curl "$VOICEAGENT_BASE/v1/webhooks/<id>/deliveries?limit=50" \
  -H "Authorization: Bearer $VOICEAGENT_API_KEY"
{
  "data": [
    {
      "id": 12345,
      "event": "call.completed",
      "call_id": "5b8a14f0-...",
      "attempt": 1,
      "response_status": 200,
      "response_body": "OK",
      "error": null,
      "duration_ms": 87,
      "attempted_at": "..."
    }
  ]
}

Use the X-VoiceAgent-Delivery header on receipt to correlate to a specific row in this list.

Idempotency

The same X-VoiceAgent-Delivery value is sent across all attempts of the same event delivery. Use it as your idempotency key on receipt:

const deliveryId = req.header("X-VoiceAgent-Delivery");
if (await alreadyProcessed(deliveryId)) return res.status(200).end();
await persist(req.body);
await markProcessed(deliveryId);

Different events for the same call get different delivery ids — call.completed and (if it ever fires) call.failed for the same call would each have their own.

Polling instead

If you don’t want webhooks, you can poll. Start a call with POST /v1/calls, then poll GET /v1/calls/:id until status reaches a terminal value. recording_url, transcript, lead_score, duration_ms, cost_paise, variables, and metadata are all populated by then.

Recommended for low-volume integrations where you control the dial. Webhooks are better when you want push delivery, audit logs, or are dialing from many places.

on_call_end.fetch (in-flow alternative)

A flow can also fire a single configured HTTP request from inside its end node, independent of the subscription system. Useful when:

  • You want different payloads per flow (subscriptions get the full call shape; in-flow fetch lets you template exactly what you send).
  • You don’t want to manage a subscription at all and the dial is initiated by the flow itself.
"on_call_end": {
  "fetch": {
    "method": "POST",
    "url": "https://crm.example.com/webhook/leads",
    "headers": { "Authorization": "Bearer your-crm-secret" },
    "body": {
      "city": "{{slots.city}}",
      "budget_paise": "{{slots.budget_paise}}",
      "property_type": "{{slots.property_type}}"
    },
    "timeout_ms": 4000
  }
}

The full tool-node fetch shape is described in the flow schema.

The in-flow fetch is fire-and-forget — no retries, no signature header, no delivery id. Use the subscription system if you need those.