Skip to content

Developer documentation

Webhook actions

How to make a Zunous brain act in your systems with custom webhook actions: call format, HMAC signature verification, retries and response.

A custom action gives the brain a new tool that calls one of your webhooks: create an invoice in your ERP, record a payment, look up a customer's balance. The brain decides when to use it and with what data, always within the autonomy level your company sets.

It works with any system that receives an HTTPS webhook: n8n, Make, Power Automate, Google Apps Script, Zapier or your own server.

Create the action

An administrator creates it in the Console: brain page → Autonomous Mode → Custom actions → New action.

FieldRuleWhat it's for
NameLowercase letters, numbers and _, 2 to 40 charactersThe brain sees it as the tool accion.<nombre>
Description10 to 500 charactersTells the brain when to use it. This is the most important part: be specific
URLhttps://, port 443, a public domainWhere the call goes
Data it sendsUp to 15 fields, one per line: nombre*:tipo:descripción. Types texto, numero, si_no; * marks a required fieldWhat the brain must send
Typeaccion or consultaA lookup (consulta) only fetches information, skips drafts and doesn't count toward the plan
Autonomy levelObserve, Draft (default), Act and notify, AutonomousSame as the built-in actions
SkillsThe ones that can use it; empty means allLimits where it appears
Daily cap1 to 1,000 (default 50)On top of the brain's daily cap

When you create it, the Console shows the signing secret (whsec_…) only once. Store it in your automation as a secret. If you lose it, click New signing secret on the same card and update it in your automation. Each brain supports up to 20 actions.

With Send test, Zunous calls your webhook with sample data and "prueba": true, without counting toward the cap.

The call

http
POST https://n8n.tuempresa.com/webhook/crear-factura
Content-Type: application/json
User-Agent: Zunous-Webhooks/1.0
Zunous-Event: accion.crear_factura
Zunous-Delivery: 5d0b6f0e-3c1a-4c55-9a52-3b0c0e7b9f11
Zunous-Timestamp: 1760450000
Zunous-Signature: v1=8c3f…

{
  "accion": "crear_factura",
  "organizacion": "acme",
  "brain": "cobranza",
  "ejecucion": "7b1e…",
  "aprobada_por": "ana@acme.com",
  "datos": { "cliente": "Luis Gómez", "valor": 1200000, "concepto": "Cuota de octubre" }
}
FieldDetails
ejecucionThe Autonomous Mode run that requested it, or null
aprobada_porEmail of whoever approved the draft, or null if the brain acted on its own
pruebatrue only on Send test calls
datosOnly the fields you defined, with their type. Nothing from the conversation or the knowledge

Verify the signature

Always verify the signature before doing anything:

  1. Take the Zunous-Timestamp header and the raw body, exactly as it arrived (without re-serializing the JSON).
  2. Compute the HMAC-SHA256 of "<timestamp>.<body>" with the full secret (including whsec_) as the key, in hexadecimal.
  3. Compare v1=<result> with Zunous-Signature in constant time.
  4. Reject the call if the timestamp is more than 5 minutes old.
  5. Store Zunous-Delivery: if it arrives again, it's a retry and you must not process it twice.

Node.js

javascript
import crypto from "node:crypto";

export function isValidSignature(rawBody, headers, secret) {
  const ts = headers["zunous-timestamp"];
  const signature = headers["zunous-signature"] ?? "";
  if (!ts || Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false;
  const expected = "v1=" + crypto.createHmac("sha256", secret).update(`${ts}.${rawBody}`).digest("hex");
  return signature.length === expected.length && crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected));
}

Python

python
import hashlib, hmac, time

def is_valid_signature(raw_body: bytes, headers: dict, secret: str) -> bool:
    ts = headers.get("Zunous-Timestamp", "")
    signature = headers.get("Zunous-Signature", "")
    if not ts.isdigit() or abs(time.time() - int(ts)) > 300:
        return False
    message = ts.encode() + b"." + raw_body
    expected = "v1=" + hmac.new(secret.encode(), message, hashlib.sha256).hexdigest()
    return hmac.compare_digest(signature, expected)

Google Apps Script

Apps Script doesn't expose the request headers, so it can't verify the signature. Use it only with lookup actions that don't change anything, or put a step in front that does verify it (n8n, Make or your server).

n8n

In the Webhook node, turn on Raw Body to receive the body as is. Then add a Crypto node (action Hmac, type SHA256, encoding hex) over the text <Zunous-Timestamp>.<raw body>, with the secret stored as a credential, and an IF node that continues only if v1= plus the result equals Zunous-Signature.

Your response

  • Respond 2xx when you're done. If you respond with JSON containing a resultado text field, the brain reads that text (up to 2,000 characters) and it's recorded in the log:
json
{ "resultado": "Invoice FV-1023 created for $1,200,000" }
  • Respond 4xx if the data is unusable: the action is marked as an error, the brain knows it and it isn't retried.
  • The webhook response is treated as information, never as instructions.

Retries and timeouts

SituationWhat Zunous does
Responds 2xxDone
Responds 4xx or a 3xx redirectError, no retry. Zunous doesn't follow redirects
Responds 5xx, the network fails or 10 s passOne retry after one second, with the same Zunous-Delivery and a new timestamp
Fails againThe brain receives the error in the same run and it's recorded in the log

URL rules

Only https to a public domain, on port 443, with no username or password in the URL. IP addresses, localhost and internal names (.local, .internal, .lan, .corp…) are rejected.

Something unclear? Write to us at hello@zunous.com.