Docs · Developers

Integrations & results

An integration is an https address that a Spamurai outcome calls after a call, for example a small serverless function that creates a payment link. Business-specific code lives in the integration, never in Spamurai. Register it under Settings → Integrations (or with the API), then use it as a webhook action in an outcome.

Each integration gets a signing secret (to check that a request comes from Spamurai) and a result key srk_… (to send results back). Store both as secrets in your function.

1. What Spamurai sends

POST <your url>
Content-Type: application/json
User-Agent: Spamurai-Integrations/1
X-Spamurai-Event: outcome            (or test, cancel)
X-Spamurai-Signature: sha256=<hex>

{
  "event": "outcome",
  "id": "uuid", "at": "2026-11-20T10:15:00.000Z",
  "lead":    { "id", "name", "first_name", "phone", "email", "title", "fields": { … } },
  "list":    { "id", "name" },
  "outcome": { "id", "label", "category" },
  "details": { "package": "12 weeks", "amount": 997 },
  "caller":  { "name", "first_name", "email" },
  "resultUrl": "https://app.spamuraidialer.com/api/v1/leads/<lead id>/results"
}

details holds what the caller filled in on the outcome’s form. Spamurai waits 10 seconds for an answer and doesn’t retry.

Check the signature

X-Spamurai-Signature is sha256= plus the hex HMAC-SHA256 of the raw request body, keyed with the integration’s signing secret. Always check it, with a constant-time compare, before doing anything.

import crypto from 'node:crypto';

export function verify(rawBody, header, secret) {
  const expected = 'sha256=' + crypto.createHmac('sha256', secret).update(rawBody).digest('hex');
  const a = Buffer.from(expected), b = Buffer.from(header || '');
  return a.length === b.length && crypto.timingSafeEqual(a, b);
}

2. What you answer

200 with JSON. Every value can be used in the outcome’s messages as {{result.<name>}}; values under fields are also saved on the lead.

{ "payment_url": "https://pay.example.com/abc", "fields": { "payment_url": "https://pay.example.com/abc" } }

Any other status (optionally with {"error": "…"}) stops the outcome: nothing is texted or emailed and the caller sees the error.

3. Sending a result back

For example from your payment provider’s webhook. Put the Spamurai lead id in the payment’s metadata when you create the link, so you have it when the provider calls you.

POST https://app.spamuraidialer.com/api/v1/leads/<lead id>/results
Authorization: Bearer srk_…
Content-Type: application/json

{ "status": "paid", "amount": 997, "note": "order 123", "fields": { "order_id": "123" } }
  • The status the outcome waits for (e.g. paid): the lead is done, and amount counts as paid revenue.
  • failed, cancelled, canceled, expired, refunded, declined: the lead comes back as a callback straight away.
  • Anything else is noted on the lead.
  • fields are saved on the lead.

4. Cancel events

With await.live the caller stays on the lead after logging, sees the result come in, and can press Cancel. Spamurai then sends, signed the same way:

{ "event": "cancel", "lead": { "id", … }, "outcome": { … }, "caller": { … } }

Switch the link off and answer 200.

5. Testing

Send test in Settings → Integrations (or POST /api/v1/integrations/{id}/test) sends a signed event with "event": "test" and shows your answer. Each integration lists its last calls with their status.

Rules for the address

  • Must start with https:// (http://localhost is allowed for local testing on a self-hosted copy).
  • Answer within 10 seconds; do slow work after answering.