Skip to Content
GuidesSetting Up Webhooks

Setting Up Webhooks

Receive real-time notifications when invoice statuses change.

1. Create a webhook endpoint

bash
curl -X POST https://gateway.useyona.com/a/v1/organizations/9f8e7d6c-5b4a-3210-fedc-ba9876543210/webhooks \
  -H "Authorization: Bearer sk_test_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://your-app.com/webhooks/yona",
    "events": ["invoice.approved", "invoice.rejected", "invoice.submission_failed"],
    "description": "Invoice status notifications"
  }'

2. Build a receiver

Your endpoint must verify the signature, process the event, and return 200 within 10 seconds.

import express from 'express'; import { verifyWebhook } from '@useyona/einvoice-js/webhooks'; const app = express(); app.post('/webhooks/yona', express.json(), (req, res) => { try { const event = verifyWebhook( req.body, req.headers, process.env.WEBHOOK_SECRET!, ); switch (event.type) { case 'invoice.approved': handleApproved(event.data); break; case 'invoice.rejected': handleRejected(event.data); break; case 'invoice.submission_failed': handleFailed(event.data); break; } res.status(200).json({ received: true }); } catch (err) { res.status(400).json({ error: 'Invalid signature' }); } });
💡 Raw body or parsed JSON — both work

You can pass either the raw body (Buffer/string) or JSON.stringify(req.body) — the SDK handles both. Using express.json() or express.raw() are both fine.

3. Test your endpoint

bash
curl -X POST https://gateway.useyona.com/a/v1/organizations/9f8e7d6c-5b4a-3210-fedc-ba9876543210/webhooks/wh_6f7a8b9c-0d1e-2345-6789-0abcdef12345/test \
  -H "Authorization: Bearer sk_test_your_key_here"

Available events

Invoice events

EventWhen it fires
invoice.createdInvoice created (draft status)
invoice.updatedDraft invoice modified
invoice.submittedInvoice queued for submission to tax authority
invoice.approvedTax authority accepted the invoice
invoice.rejectedTax authority rejected the invoice
invoice.submission_failedSubmission failed before tax authority response
invoice.cancelledInvoice cancelled (credit note created)
invoice.status.changedInvoice status changed via authority callback
invoice.retry_scheduledFailed invoice re-queued for retry

Payment events

EventWhen it fires
payment.createdPayment initiated
payment.succeededPayment completed
payment.failedPayment declined or failed
billing_account.low_balanceCredit balance dropped below threshold

Seller & Buyer events

EventWhen it fires
seller.createdNew seller registered
seller.updatedSeller details changed
seller.tax_number_verifiedSeller TIN verification succeeded
buyer.createdNew buyer registered
buyer.updatedBuyer details changed
buyer.tax_number_verifiedBuyer TIN verification succeeded
💡 Full event list

See Core Concepts — Webhooks for the complete list of all event types including organization, user, subscription, and API key events.

Retry behavior

Failed deliveries are retried up to 3 total attempts (1 initial + 2 retries) with exponential backoff. You can manually retry:

bash
curl -X POST https://gateway.useyona.com/a/v1/organizations/9f8e7d6c-5b4a-3210-fedc-ba9876543210/webhooks/deliveries/del_8b9c0d1e-2f3a-4567-8901-bcdef1234567/retry \
  -H "Authorization: Bearer sk_test_your_key_here"
Last updated on