Webhooks: receiving and sending events
Use Espectro's two types of webhook: the incoming one, which brings in sales from a platform Espectro does not know yet (Other platform, in Integrations), and the outgoing one, the Postback, where Espectro notifies your other systems of each event: sale, click, checkout started, lead, comment and message. It also shows how your system checks that the notification really came from Espectro and which data goes out.
On this page
Who does it
The account owner creates, edits, tests, resends and deletes. The team can only see the destinations and the deliveries.
Before you start
- A webhook is an automatic notice between systems: when something happens (a sale, a payment, a lead), one system sends a POST with the data to the other system's address (URL), right away.
- For the incoming webhook: access to the dashboard of the sales platform where its webhook is set up. Espectro Pay and Zedy do not need this: they already have a ready-made integration (Integrations).
- For the outgoing webhook: the
https://address of your system (CRM, spreadsheet, ERP, customer service system) that will receive the notifications, and someone who can read the notifications in that system.
Step by step
Part A. Incoming webhook: sales from another platform
- In Settings > Integrations (incoming webhooks), open New integration and create the integration with Source Other platform (any checkout), the store name and the fees (Integrations).
- Copy the Webhook URL (secret included) and add it in your sales platform's dashboard as an orders webhook. No token is needed (the secret can also go in
Authorization: Bearer; the notification can be JSON or a form). Do not share this URL. While nothing has arrived, use Check again. - Place a test order. The first notification becomes the sample. Until you save the map, notifications are only logged and do not become sales.
- Click Map fields. The screen shows the Sample (first notification) on one side and the fields on the other.
- For each field, type (or pick from the list) its path in the notification, with dots, for example
data.customer.emailoritems[0].name. The value it picks up from the sample shows underneath. Groups:- Order: Order id (required), Status, Amount, Payment method, Product (name), Product (id), Quantity, Order date, Purchase id (the same as in espectro.compra) (only if the checkout calls
espectro.comprain the browser: with the same id in both, Meta counts the sale once; see at the checkout); - Customer: Name, Email, Phone, ZIP, Street, Number, Complement, District, City, UF;
- Origin (UTMs and click):
utm_source,utm_medium,utm_campaign,utm_content,utm_term, Click code (sck or esp_ck) andfbclid.
- Order: Order id (required), Status, Amount, Payment method, Product (name), Product (id), Quantity, Order date, Purchase id (the same as in espectro.compra) (only if the checkout calls
- In Amount comes in, choose cents (4990) or reais (49.90).
- In Status equivalence, type the values the platform uses for Paid, Pending, Refused and Refunded, separated by commas. Anything not on the list follows the known names (paid, approved, refunded...); if it is not recognized, it stays pending.
- Optional: in Sender signature (optional), fill in Header, Secret (at least 8 characters) and Algorithm if the platform signs its notifications. Notifications without the right signature are then refused. The Turn off the check switch goes back to accepting them without a signature.
- Click Preview to see How the sale would look. If it is right, click Save map. It shows "Map saved. Next notifications become sales." From then on, each notification becomes a sale like those from the other sources.
- If the sample is not good, click Use the next one and place another order.


Good to know: the CPF is not mapped. Each notification can be up to 64 KB and each URL receives up to 120 notifications per minute (above that, it responds 429). The sample is a real order: only the owner sees it.
Part B. Outgoing webhook (Postback): notify your systems
What it is for: Espectro notifies your other systems of each event: sale, click, checkout started, lead, comment and message. Sales come in through Integrations; the Postback (outgoing webhooks), in the Settings group, is the way out.
The formats:
| Format | What it sends |
|---|---|
| Signed webhook (all events) | All events, with a security signature (recommended). |
| JSON (POST with the standard body) | Sales only, with no customer data. |
| URL with macros | Sales only, to an address with macros such as {valor}, {status}, {click_id}, {campanha_id} (GET or POST). |
In the JSON and URL formats, the events are in When to send (Created (order placed), which goes out when the sale reaches Espectro, even before the PIX or boleto is created; Paid, Refused, Refunded, Chargeback), the token goes in Authorization: Bearer and in the {token} macro, and the button is called Send test. The format cannot be changed after it is created.
Create a destination (Signed webhook):
- Open New destination.
- Fill in Name and URL (your system's
https://address). If you want, Only from integration and Only product (they apply to sale events). - Check the events (a new destination comes with only Paid checked; the full list is in Part C):
- Tracking (espectro.js): Ad click (page arrival from an ad; visits without an ad are not sent) and Checkout started;
- Sales (from every source): Order created, Charge created (PIX/boleto), Paid, Refused or expired, Refunded, Chargeback, Abandoned cart;
- Meta (pages connected in Channels): New lead (Meta), New comment (Meta), New message (Meta).
- Include customer data (name, e-mail, phone, address; comment author; lead answers) comes turned off. Turn it on only if your system needs this data. Without it, the lead goes with only the field names, the comment goes without an author and the message goes with the conversation code masked. The CPF, the IP and the browser never go out.
- For Meta events, turn on I confirm this destination is my business and Meta data will not be sold or passed on. Without it, the destination does not save with those events ("To send Meta leads, comments or messages, confirm that this destination belongs to your own business.").
- Click Create destination. The Destination secret shows (it starts with
whsec_). Copy it now and keep it in your system: it is not shown again (afterwards the screen shows only the end of it). If you lose it, use Generate new (the old one stops working right away). - Pick an event and click Test. It sends sample data marked with
teste: true. The result shows right away ("Test delivered (HTTP 200, ... ms)."). The test has no retry. - Deliveries shows the last 50 deliveries of that destination, with the body sent (cut at 3,000 characters) and the Resend button.
- The Active switch turns the destination on and off (when off it shows the Off badge). Delete removes the destination and takes its resends out of the queue.


How the notification reaches your system (for the developer):
POSTwith JSON, only tohttps://. HeadersX-Espectro-Evento(the event name),X-Espectro-Id(the notification id),X-Espectro-Tentativa(1 the first time) andX-Espectro-Assinatura(sha256=+ HMAC-SHA256 of the raw body with the secret; Part D). The Node and PHP examples are also on the screen itself.- A 2xx response = delivered. Any other response, or more than 8 seconds, = retry in 1, 5, 15, 60 and 180 minutes (each wait counts from the previous attempt; after the 5th retry, Espectro gives up), with the same body and the next attempt number in the header. This applies to all three formats. Espectro does not follow redirects, and the address cannot be on an internal network.
- The
idis the same for the same fact: your system can ignore repeats. Each event goes out once per destination and per sale. Test sales do not create a postback. - Latest deliveries (all destinations) is at the bottom of the screen. In the retry queue now is in the JSON and URL with macros (sales only) card.
Be careful: leads, comments and messages are Meta data: only for your own business's systems, never to sell or pass on (Meta's rule). Leads, comments and messages only go out when they arrive through Meta's notification (with the Page updates turned on in Channels); a manual fetch does not trigger them.
Part C. Event list
| Event | On the screen | When it goes out |
|---|---|---|
clique.registrado | Ad click | Someone arrived on the page with the Espectro script coming from an ad. Direct visits, organic visits or visits from a link without an ad do not count. |
checkout.iniciado | Checkout started | The person clicked the buy button (repeats within 30 minutes do not count again). |
pedido.criado | Order created | New sale. |
cobranca.gerada | Charge created (PIX/boleto) | PIX or boleto created. |
pedido.pago | Paid | Sale paid. |
pedido.recusado | Refused or expired | Sale refused or PIX expired. |
pedido.reembolsado | Refunded | Sale refunded. |
pedido.chargeback | Chargeback | Chargeback. |
carrinho.abandonado | Abandoned cart | Cart abandoned at the checkout. |
meta.lead | New lead (Meta) | New lead from Meta forms. |
meta.comentario | New comment (Meta) | New customer comment on the connected Pages and Instagram. |
meta.mensagem | New message (Meta) | New customer message (Messenger, Instagram or WhatsApp). |
Sale events apply to all sources (Espectro Pay, Zedy and Other platform) and each one goes out once per destination and per sale.
Example body of pedido.pago (shortened, without the customer data option):
{
"evento": "pedido.pago",
"id": "evt_3f1c9a7b2e",
"quando": "2026-10-16T12:00:00.000Z",
"conta": "minhaloja",
"teste": false,
"dados": {
"origem": "espectro-pay",
"integracao": { "id": "int-abc123", "nome": "Minha Loja", "loja": "Minha Loja" },
"venda": {
"id": "v-123",
"pedido": "EP-ABCD2345",
"status": "paga",
"valorCentavos": 9790,
"valor": 97.9,
"moeda": "BRL",
"metodo": "pix",
"pagaEm": "2026-10-16T12:00:00.000Z",
"produto": { "id": "livro", "nome": "Livro", "quantidade": 1 }
},
"rastreio": {
"utm_source": "FB",
"utm_campaign": "Livros|120000000000001",
"plataforma": "meta",
"campanhaId": "120000000000001"
}
}
}
Part D. Check the signature in your system
Each notification carries in the X-Espectro-Assinatura header the value sha256= followed by the HMAC-SHA256 of the raw body (the text exactly as it arrived, before parsing the JSON), made with the destination's whsec_ secret. Your system calculates the same value and compares. If it does not match, refuse the notification: it did not come from Espectro.
In Node (Express):
const express = require('express');
const { createHmac, timingSafeEqual } = require('node:crypto');
const SEGREDO = process.env.ESPECTRO_SEGREDO; // whsec_...
const app = express();
app.post('/espectro', express.raw({ type: 'application/json' }), (req, res) => {
const esperado = 'sha256=' + createHmac('sha256', SEGREDO).update(req.body).digest('hex');
const recebido = String(req.get('X-Espectro-Assinatura') || '');
const ok = recebido.length === esperado.length && timingSafeEqual(Buffer.from(recebido), Buffer.from(esperado));
if (!ok) return res.status(401).end();
const evento = JSON.parse(req.body.toString('utf8'));
// evento.evento, evento.id, evento.dados
res.status(200).end();
});
In PHP:
<?php
$segredo = getenv('ESPECTRO_SEGREDO'); // whsec_...
$corpo = file_get_contents('php://input');
$esperado = 'sha256=' . hash_hmac('sha256', $corpo, $segredo);
$recebido = $_SERVER['HTTP_X_ESPECTRO_ASSINATURA'] ?? '';
if (!hash_equals($esperado, $recebido)) { http_response_code(401); exit; }
$evento = json_decode($corpo, true);
// $evento['evento'], $evento['id'], $evento['dados']
http_response_code(200);
After checking, if you want, ignore an id that was already processed and notifications with a very old quando.
Part E. Data rules
- The CPF never goes out. Document fields are dropped, and a CPF written in the text of a comment, a message or a lead answer becomes
[cpf removido]. The buyer's IP and browser never go out either. - Customer data only with the option turned on (Part B, step 4). With it off, the lead goes with only the field names, the comment goes without an author and the message goes with the conversation code masked.
- Leads, comments and messages only for your own business's systems. This is Meta's rule: this data cannot be sold or passed on to other companies. That is why Espectro asks for your confirmation before sending these events. Once the data reaches your system, it is your responsibility (see the Privacy Policy, item 3).
How to know it worked
- Incoming: after saving the map, the test order shows in Sales, and the integration card shows Events received going up and Fields mapped.
- Outgoing: Test shows your system's response ("Test delivered (HTTP 200, ... ms)."), and Deliveries lists each delivery with its response code.
- Your system checks the signature (Part D) and receives the same
idagain only when Espectro resends.
Common problems and fixes
| What shows | What to do |
|---|---|
| The other platform's notifications arrive but do not become sales. | The map was not saved (Part A, steps 4 to 9). Before the map, notifications are only logged. |
| The platform gets 401 when sending the notification. | The URL was copied without the secret, or the sender signature is on with the wrong secret. Copy the URL again and check Part A, step 8. |
| The platform gets 429. | It went over 120 notifications per minute on the same URL. Wait and resend. |
| The sale amount came in 100 times too high or too low. | Cents and reais swapped: change Amount comes in and save the map. |
| Your system rejects the Postback notifications. | Signature calculated wrong or wrong secret. Calculate it on the raw body (before parsing the JSON), with the right whsec_ secret; if you lost it, Generate new and update it in your system. |
| Leads, comments and messages do not go out in the Postback. | Page without updates turned on in Channels, or destination without those events checked. Turn on the Page updates; check the events and the Meta data confirmation (without it the destination does not save). |
| An event arrived twice. | It is a resend (your system did not respond 2xx in time). Ignore the repeated id. |