Webhooks
Webhooks send HTTP POST requests to your server when events occur, so you don’t need to poll the API for changes.
Quick Start
const webhook = await sdk.webhooks.create({
url: "https://example.com/webhooks",
events: ["invoice.created", "invoice.paid", "payment.received"],
description: "Invoice notifications",
});
// Save the secret — it is only shown on creation
console.log("Webhook secret:", webhook.secret);Event Types
Subscribe to specific events or listen to all events for a category.
Browse the complete event catalog
Invoices
| Event | Trigger |
|---|---|
invoice.created | Invoice created |
invoice.updated | Invoice updated |
invoice.sent | Invoice sent to customer |
invoice.paid | Invoice fully paid |
invoice.overdue | Invoice past due date |
invoice.deleted | Invoice soft-deleted |
invoice.restored | Invoice restored from deletion |
invoice.voided | Invoice voided; the payload carries id, number and the void reason when one was given |
invoice.finalized | Invoice finalized (locked) |
Customers
| Event | Trigger |
|---|---|
customer.created | Customer created |
customer.updated | Customer updated |
customer.deleted | Customer soft-deleted |
customer.restored | Customer restored |
customer.permanently_deleted | Customer permanently removed |
Payments
| Event | Trigger |
|---|---|
payment.received | Payment received |
payment.updated | Payment updated |
payment.failed | Payment failed |
payment.deleted | Payment soft-deleted |
payment.restored | Payment restored |
payment.permanently_deleted | Payment permanently removed |
Expenses
| Event | Trigger |
|---|---|
expense.created | Expense created |
expense.updated | Expense updated |
expense.finalized | Expense finalized (locked) |
expense.voided | Expense voided |
expense.deleted | Expense deleted |
Estimates
| Event | Trigger |
|---|---|
estimate.created | Estimate created |
estimate.sent | Estimate sent |
estimate.accepted | Estimate accepted by customer |
estimate.rejected | Estimate rejected |
estimate.deleted | Estimate soft-deleted |
estimate.restored | Estimate restored |
Credit Notes
| Event | Trigger |
|---|---|
credit_note.created | Credit note created |
credit_note.updated | Credit note updated, including a fiscalization or authority status change |
credit_note.voided | Credit note voided; the payload carries id, number and reason when one was given |
credit_note.deleted | Credit note soft-deleted |
credit_note.restored | Credit note restored |
Fiscalization and authority status
When a fiscalization or tax-authority result is stored after the document was created (a late response, an automatic or manual retry, or an authority status change), the document sends its updated event: invoice.updated, credit_note.updated or advance_invoice.updated. Providers covered: furs (Slovenia), fina (Croatia), eet (Czechia), verifactu and ticketbai (Spain), nav (Hungary). The changed provider is named in changed_fields and its summary is under the same key. Fields that are not set are absent.
{ "id": "inv_abc123", "type": "invoice", "changed_fields": ["fina"], "fina": { "status": "success", "jir": "6f1e2d3c-4b5a-4c6d-8e7f-0a1b2c3d4e5f", "zki": "a1b2c3d4e5f60718293a4b5c6d7e8f90", "fiscalized_at": "2026-10-28T10:00:00.000Z" }}| Provider | Summary fields | Not sent while |
|---|---|---|
furs | status, eor, zoi, fiscalized_at | pending, skipped |
fina | status, jir, zki, fiscalized_at | pending |
eet | status, pok, registered_at, evidence_unit_id, pos_id | pending |
verifactu | status, record_id, csv, qr_url, error_code | pending |
ticketbai | status, identifier, qr_url, record_id, cancellation.status | pending, sending |
nav | status, transaction_id, operation, invoice_number, modification_index, completed_at, error_code | reserved, dispatching |
- Error details are not included;
status(anderror_codewhere the provider has one) tells you a submission failed; fetch the document for the message. - The event is sent once per change of status and receipt identifier (for example JIR, EOR, POK, CSV or NAV transaction id).
- A result returned while the document is being created comes back in the response to the create request; no
updatedevent is sent for it. - Certificate data and the request sent to the authority are never included. Customer and operator tax numbers are never included; authority identifiers and QR URLs can contain your own (issuer) tax number.
- Croatia (
fina): status ispending,successorfailed. While the request to FINA is still in flight, the document (GET) showsfina.status: "pending"and no webhook is sent; the result (successwith a JIR, orfailed) arrives as theupdatedevent shown above. Invoices to customers in other EU countries, and to business customers outside the EU (with a tax number), are not fiscalized in Croatia: they have nofinaobject at all and send no fiscal-status webhook.
Advance Invoices
| Event | Trigger |
|---|---|
advance_invoice.created | Advance invoice created |
advance_invoice.updated | Advance invoice updated, including a fiscalization or authority status change |
advance_invoice.paid | Advance invoice paid |
advance_invoice.applied | Advance applied to final invoice |
advance_invoice.voided | Advance invoice voided; the payload carries id, number and reason when one was given |
advance_invoice.deleted | Advance invoice soft-deleted |
advance_invoice.restored | Advance invoice restored |
Expenses
| Event | Trigger |
|---|---|
expense.created | Expense created as a draft or posted expense |
expense.updated | Expense updated or restored from void |
expense.finalized | Draft expense finalized and posted |
expense.voided | Posted expense voided |
expense.deleted | Draft expense soft-deleted |
Recurring Invoices
| Event | Trigger |
|---|---|
recurring_invoice.created | Schedule created |
recurring_invoice.updated | Schedule updated |
recurring_invoice.deleted | Schedule soft-deleted |
recurring_invoice.restored | Schedule restored |
recurring_invoice.permanently_deleted | Schedule permanently removed |
recurring_invoice.paused | Schedule paused |
recurring_invoice.resumed | Schedule resumed |
recurring_invoice.invoice_generated | Invoice generated from schedule |
recurring_invoice.generation_failed | Invoice generation failed |
recurring_invoice.completed | All invoices generated |
Items & Taxes
| Event | Trigger |
|---|---|
item.created | Item created |
item.updated | Item updated |
item.deleted | Item soft-deleted |
item.restored | Item restored |
item.permanently_deleted | Item permanently removed |
tax.created | Tax created |
tax.updated | Tax updated |
tax.deleted | Tax soft-deleted |
tax.restored | Tax restored |
tax.permanently_deleted | Tax permanently removed |
Orders & Delivery Notes
| Event | Trigger |
|---|---|
order.created | Order created |
order.updated | Order updated |
order.deleted | Order soft-deleted |
order.restored | Order restored |
order.permanently_deleted | Order permanently removed |
order.processed | Order processed |
order.cancelled | Order cancelled |
order.failed | Order processing failed |
order_integration.created | Order integration created |
order_integration.updated | Order integration updated |
order_integration.deleted | Order integration deleted |
shipment.created | Carrier shipment (parcel) registered for an order; the payload carries id, order_id, carrier, tracking_numbers and tracking_urls |
shipment.cancelled | Carrier shipment cancelled; same payload as shipment.created |
delivery_note.created | Delivery note created |
delivery_note.sent | Delivery note sent |
delivery_note.voided | Delivery note voided; the payload carries id, number and reason when one was given |
delivery_note.deleted | Delivery note soft-deleted |
delivery_note.restored | Delivery note restored |
Document Emails
Amazon SES reports what happened to a document email after it was sent. Every event carries { id, type, message_id }: the document ID, its type and the email’s message ID (also stored on the document’s sent activity). email.delivered, email.bounced and email.complained add recipients, the affected addresses; email.bounced also adds bounce_type and bounce_sub_type, and email.complained adds feedback_type. email.opened carries only { id, type, message_id }: SES does not say which recipient opened, and no IP address or user agent is stored.
| Event | Trigger |
|---|---|
email.delivered | The recipient’s mail server accepted the email |
email.bounced | The email bounced (permanent or temporary) |
email.complained | The recipient marked the email as spam |
email.opened | First open of the email; only when the entity enabled email_open_tracking_enabled |
Fiscalization Certificates
Sent once per reminder stage for FURS (Slovenia) and FINA (Croatia) certificates, to the entity’s webhooks and to the owning account’s account webhooks when subscribed there. They fire for every account, including white-label accounts. Both events carry { certificate_id, provider, entity_id, certificate_expiry, stage, days_until_expiry }: the certificate ID, furs or croatia_cis, the entity ID, the expiry as an ISO timestamp, the stage (30d, 7d, 1d or expired) and the whole days left (negative once expired). No certificate material is included.
| Event | Trigger |
|---|---|
fiscalization.certificate_expiring | A certificate is 30, 7 or 1 day from expiry (stages 30d, 7d, 1d) |
fiscalization.certificate_expired | A certificate has expired (stage expired) |
E-Invoicing & Integrations
The ksef.submission.* events carry { id, type, ksef }: the document ID, its type (invoice or credit_note), and the document’s KSeF state, the same object GET /invoices/{id}/ksef returns.
| Event | Trigger |
|---|---|
e_invoicing.submission.created | E-invoice submitted |
e_invoicing.submission.delivered | E-invoice delivered |
e_invoicing.submission.failed | E-invoice delivery failed |
e_invoicing.enrollment.verified | Entity enrollment verified for e-invoicing |
e_invoicing.enrollment.rejected | Entity enrollment rejected for e-invoicing |
e_invoicing.supplier.onboarded | Deprecated compatibility event emitted with e_invoicing.enrollment.verified |
e_invoicing.supplier.rejected | Deprecated compatibility event emitted with e_invoicing.enrollment.rejected |
ksef.submission.accepted | KSeF accepted a Polish invoice or credit note |
ksef.submission.rejected | KSeF rejected a Polish invoice or credit note |
ksef.submission.upo_available | The KSeF receipt (UPO) for a document is available to download |
stripe_app.connected | Stripe app connected |
stripe_app.disconnected | Stripe app disconnected |
stripe_app.settings_updated | Stripe app settings changed |
Subscribe to groups of events
Instead of listing every event name, the events array of a webhook also accepts patterns:
| Pattern | Matches |
|---|---|
* | Every event |
<resource>.* | Every event of one resource, e.g. invoice.*, credit_note.*, e_invoicing.submission.*, ksef.submission.* |
document.* | Every event of invoices, estimates, credit notes, advance invoices and delivery notes |
document.<action> | One action across all document types, e.g. document.created, document.updated, document.voided, document.paid |
{ "url": "https://example.com/webhooks", "events": ["document.updated", "customer.*"]}Things to know:
- Deliveries always carry the concrete event name, for example
credit_note.updated, so the event name tells you which kind of document changed. - A webhook receives at most one delivery per event, even when several entries in
eventsmatch it. - Patterns also pick up event types added later, so a webhook on
invoice.*receives new invoice events without any change. - Estimates and delivery notes do not send
.updated: editing one sendsestimate.createdordelivery_note.createdagain. Sodocument.updatedcovers invoices, credit notes and advance invoices.
Payload Format
Every webhook delivery sends a JSON payload:
{ "event": "invoice.paid", "data": { "id": "inv_abc123", "number": "INV-001", "..." }, "timestamp": "2024-01-15T10:30:00.000Z"}The data field contains the full resource object at the time of the event.
Delivery Headers
| Header | Description |
|---|---|
X-Webhook-Signature | HMAC-SHA256 signature (sha256=<hex>) |
X-Webhook-Timestamp | Unix timestamp (seconds) |
X-Webhook-Event | Event type |
X-Webhook-Delivery | Delivery ID, the same on every retry of this event to this webhook; use it as the idempotency key |
X-Webhook-Id | Webhook ID |
Content-Type | application/json |
Verifying Signatures
Every delivery is signed with your webhook secret using HMAC-SHA256. Always verify signatures to ensure requests are from Space Invoices.
import crypto from "node:crypto";
function verifyWebhookSignature(
secret: string,
payload: string,
signatureHeader: string,
): boolean {
const expected = crypto
.createHmac("sha256", secret)
.update(payload)
.digest("hex");
return signatureHeader === `sha256=${expected}`;
}
// In your webhook handler:
const rawBody = await request.text();
const signature = request.headers.get("X-Webhook-Signature")!;
if (!verifyWebhookSignature("your_webhook_secret", rawBody, signature)) {
throw new Error("Invalid webhook signature");
}Handling Events
Process events asynchronously and respond quickly with a 2xx status.
app.post("/webhooks", async (req, res) => {
const { event, data, timestamp } = req.body;
switch(event) {
case "invoice.paid":
await fulfillOrder(data.id);
break;
case "invoice.overdue":
await sendReminder(data.id);
break;
case "customer.created":
await syncToExternalCRM(data);
break;
}
// Always respond 2xx quickly
res.status(200).json({ received: true });
});Retry Policy
A delivery fails on a non-2xx response, a timeout or a network error. Your endpoint must respond within 10 seconds per attempt. Failed deliveries are retried, up to 5 attempts in total:
| Attempt | Sent (at the earliest) |
|---|---|
| 1 | Immediately |
| 2 | 1 minute after attempt 1 |
| 3 | 5 minutes after attempt 2 |
| 4 | 30 minutes after attempt 3 |
| 5 | 2 hours after attempt 4 |
Retries are sent by a job that runs every 5 minutes, so a retry can go out a few minutes after its delay has passed.
Deactivation
The following are permanent failures: they are not retried, and the webhook is deactivated immediately.
- A response with HTTP
400,401,403,404,405or410. - A
3xxredirect. Redirects are not followed and the response body is not stored on the delivery, so register the final URL of your endpoint. - A hostname that resolves to a private, loopback, link-local or otherwise reserved address. The hostname is resolved before each attempt, and if any of its addresses is reserved, nothing is sent.
- A hostname that does not exist (DNS “not found”).
Temporary DNS errors and timeouts are retried like other network errors.
A webhook is also deactivated after the 5th failed attempt.
Account owners and admins (or the entity email if there are none) get an email when the first attempt of a delivery fails and when a failed delivery deactivates the webhook, so a burst of failing events can send several emails.
To re-enable a webhook, set active back to true:
curl -X PATCH "https://eu.spaceinvoices.com/webhooks/$WEBHOOK_ID" \ -H "Authorization: Bearer $API_KEY" \ -H "x-entity-id: $ENTITY_ID" \ -H "Content-Type: application/json" \ -d '{ "active": true }'Events are not replayed. Events that happen while a webhook is inactive are not queued and have no delivery record, so they are never sent, even after you re-enable the webhook. Retries scheduled before deactivation can still be sent after you re-enable the webhook. To catch up, re-list the resources that changed since the webhook was deactivated (for example invoices updated since then) and re-read them. GET /webhooks/{id}/deliveries shows the deliveries attempted before deactivation.
Best Practices
- Respond 2xx quickly — Do heavy processing asynchronously after acknowledging the webhook
- Verify signatures — Always validate
X-Webhook-Signaturebefore processing - Handle duplicates — Use the
X-Webhook-Deliveryheader as an idempotency key; retries of the same event reuse it - Monitor deliveries — Check webhook delivery logs in the dashboard for failures
- Use specific events — Subscribe only to events you need rather than all events
- Secure your endpoint — Use HTTPS and restrict access to Space Invoices IP ranges if possible