Pular para o conteúdo principal

Receive Cancellation

When a company cancels a previously issued invoice, OlaClick sends a FISCAL_NOTES_CANCELATION_REQUEST event to your webhook.

Flow​

  1. A company cancels a completed invoice from OlaClick
  2. OlaClick sends a FISCAL_NOTES_CANCELATION_REQUEST event to your webhook URL
  3. You respond with 200 OK confirming receipt
  4. You cancel the fiscal document with the fiscal authority
  5. You notify OlaClick with the result via PATCH /v1/fiscal-notes/confirmation (see Confirm Cancellation)

Webhook event​

The FISCAL_NOTES_CANCELATION_REQUEST event payload is identical to FISCAL_NOTES_REQUEST — only the event_type differs. The data field contains order_id, country_code, and electronic_invoice_id.

Event reference: FISCAL_NOTES_CANCELATION_REQUEST — full payload and schema.

info

If you need the full order or invoice data, use GET /v1/orders/:id with data.order_id.

Complete flow example​

app.post('/webhooks/olaclick', async (req, res) => {
// 1. Verify signature (see Signature Verification)
if (!verifySignature(req.rawBody, req.headers['x-olaclick-signature'], SIGNING_SECRET)) {
return res.status(401).json({ error: 'invalid_signature' });
}

const { event_type, data } = req.body;

if (event_type === 'FISCAL_NOTES_CANCELATION_REQUEST') {
const { order_id, country_code } = data;

// 2. Get a Company Token
// companyId comes from your storage — mapped from the merchant_id
// you received in the CONNECTION_CREATED binding event
const token = await getCompanyToken(companyId);

// 3. Cancel the fiscal document with the fiscal authority
const result = await cancelInvoice(order_id, country_code);

// 4. Confirm result to OlaClick
await fetch('https://public-api.olaclick.app/v1/fiscal-notes/confirmation', {
method: 'PATCH',
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
order_id,
status: result.success ? 'CANCELLED' : 'CANCELLED_ERROR',
message: result.message,
}),
});
}

res.json({ status: 'received' });
});

Next step​

→ Confirm Cancellation — Notify OlaClick with the result via PATCH /v1/fiscal-notes/confirmation