Skip to content

Webhooks

Outcome
Receive and verify asynchronous platform events.
Prerequisites
A public HTTPS endpoint that preserves the raw request body.
You'll use
Webhook secret, delivery ID, and event-specific handlers.

Webhooks send HTTP POST requests to your server when events occur, so you don’t need to poll the API for changes.

Quick Start

Create a webhooktypescript
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

EventTrigger
invoice.createdInvoice created
invoice.updatedInvoice updated
invoice.sentInvoice sent to customer
invoice.paidInvoice fully paid
invoice.overdueInvoice past due date
invoice.deletedInvoice soft-deleted
invoice.restoredInvoice restored from deletion
invoice.voidedInvoice voided; the payload carries id, number and the void reason when one was given
invoice.finalizedInvoice finalized (locked)

Customers

EventTrigger
customer.createdCustomer created
customer.updatedCustomer updated
customer.deletedCustomer soft-deleted
customer.restoredCustomer restored
customer.permanently_deletedCustomer permanently removed

Payments

EventTrigger
payment.receivedPayment received
payment.updatedPayment updated
payment.failedPayment failed
payment.deletedPayment soft-deleted
payment.restoredPayment restored
payment.permanently_deletedPayment permanently removed

Expenses

EventTrigger
expense.createdExpense created
expense.updatedExpense updated
expense.finalizedExpense finalized (locked)
expense.voidedExpense voided
expense.deletedExpense deleted

Estimates

EventTrigger
estimate.createdEstimate created
estimate.sentEstimate sent
estimate.acceptedEstimate accepted by customer
estimate.rejectedEstimate rejected
estimate.deletedEstimate soft-deleted
estimate.restoredEstimate restored

Credit Notes

EventTrigger
credit_note.createdCredit note created
credit_note.updatedCredit note updated, including a fiscalization or authority status change
credit_note.voidedCredit note voided; the payload carries id, number and reason when one was given
credit_note.deletedCredit note soft-deleted
credit_note.restoredCredit 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"
}
}
ProviderSummary fieldsNot sent while
fursstatus, eor, zoi, fiscalized_atpending, skipped
finastatus, jir, zki, fiscalized_atpending
eetstatus, pok, registered_at, evidence_unit_id, pos_idpending
verifactustatus, record_id, csv, qr_url, error_codepending
ticketbaistatus, identifier, qr_url, record_id, cancellation.statuspending, sending
navstatus, transaction_id, operation, invoice_number, modification_index, completed_at, error_codereserved, dispatching
  • Error details are not included; status (and error_code where 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 updated event 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 is pending, success or failed. While the request to FINA is still in flight, the document (GET) shows fina.status: "pending" and no webhook is sent; the result (success with a JIR, or failed) arrives as the updated event 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 no fina object at all and send no fiscal-status webhook.

Advance Invoices

EventTrigger
advance_invoice.createdAdvance invoice created
advance_invoice.updatedAdvance invoice updated, including a fiscalization or authority status change
advance_invoice.paidAdvance invoice paid
advance_invoice.appliedAdvance applied to final invoice
advance_invoice.voidedAdvance invoice voided; the payload carries id, number and reason when one was given
advance_invoice.deletedAdvance invoice soft-deleted
advance_invoice.restoredAdvance invoice restored

Expenses

EventTrigger
expense.createdExpense created as a draft or posted expense
expense.updatedExpense updated or restored from void
expense.finalizedDraft expense finalized and posted
expense.voidedPosted expense voided
expense.deletedDraft expense soft-deleted

Recurring Invoices

EventTrigger
recurring_invoice.createdSchedule created
recurring_invoice.updatedSchedule updated
recurring_invoice.deletedSchedule soft-deleted
recurring_invoice.restoredSchedule restored
recurring_invoice.permanently_deletedSchedule permanently removed
recurring_invoice.pausedSchedule paused
recurring_invoice.resumedSchedule resumed
recurring_invoice.invoice_generatedInvoice generated from schedule
recurring_invoice.generation_failedInvoice generation failed
recurring_invoice.completedAll invoices generated

Items & Taxes

EventTrigger
item.createdItem created
item.updatedItem updated
item.deletedItem soft-deleted
item.restoredItem restored
item.permanently_deletedItem permanently removed
tax.createdTax created
tax.updatedTax updated
tax.deletedTax soft-deleted
tax.restoredTax restored
tax.permanently_deletedTax permanently removed

Orders & Delivery Notes

EventTrigger
order.createdOrder created
order.updatedOrder updated
order.deletedOrder soft-deleted
order.restoredOrder restored
order.permanently_deletedOrder permanently removed
order.processedOrder processed
order.cancelledOrder cancelled
order.failedOrder processing failed
order_integration.createdOrder integration created
order_integration.updatedOrder integration updated
order_integration.deletedOrder integration deleted
shipment.createdCarrier shipment (parcel) registered for an order; the payload carries id, order_id, carrier, tracking_numbers and tracking_urls
shipment.cancelledCarrier shipment cancelled; same payload as shipment.created
delivery_note.createdDelivery note created
delivery_note.sentDelivery note sent
delivery_note.voidedDelivery note voided; the payload carries id, number and reason when one was given
delivery_note.deletedDelivery note soft-deleted
delivery_note.restoredDelivery 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.

EventTrigger
email.deliveredThe recipient’s mail server accepted the email
email.bouncedThe email bounced (permanent or temporary)
email.complainedThe recipient marked the email as spam
email.openedFirst 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.

EventTrigger
fiscalization.certificate_expiringA certificate is 30, 7 or 1 day from expiry (stages 30d, 7d, 1d)
fiscalization.certificate_expiredA 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.

EventTrigger
e_invoicing.submission.createdE-invoice submitted
e_invoicing.submission.deliveredE-invoice delivered
e_invoicing.submission.failedE-invoice delivery failed
e_invoicing.enrollment.verifiedEntity enrollment verified for e-invoicing
e_invoicing.enrollment.rejectedEntity enrollment rejected for e-invoicing
e_invoicing.supplier.onboardedDeprecated compatibility event emitted with e_invoicing.enrollment.verified
e_invoicing.supplier.rejectedDeprecated compatibility event emitted with e_invoicing.enrollment.rejected
ksef.submission.acceptedKSeF accepted a Polish invoice or credit note
ksef.submission.rejectedKSeF rejected a Polish invoice or credit note
ksef.submission.upo_availableThe KSeF receipt (UPO) for a document is available to download
stripe_app.connectedStripe app connected
stripe_app.disconnectedStripe app disconnected
stripe_app.settings_updatedStripe app settings changed

Subscribe to groups of events

Instead of listing every event name, the events array of a webhook also accepts patterns:

PatternMatches
*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 events match 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 sends estimate.created or delivery_note.created again. So document.updated covers 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

HeaderDescription
X-Webhook-SignatureHMAC-SHA256 signature (sha256=<hex>)
X-Webhook-TimestampUnix timestamp (seconds)
X-Webhook-EventEvent type
X-Webhook-DeliveryDelivery ID, the same on every retry of this event to this webhook; use it as the idempotency key
X-Webhook-IdWebhook ID
Content-Typeapplication/json

Verifying Signatures

Every delivery is signed with your webhook secret using HMAC-SHA256. Always verify signatures to ensure requests are from Space Invoices.

Verify webhook signaturetypescript
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.

Handle webhook eventstypescript
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:

AttemptSent (at the earliest)
1Immediately
21 minute after attempt 1
35 minutes after attempt 2
430 minutes after attempt 3
52 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, 405 or 410.
  • A 3xx redirect. 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:

Terminal window
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

  1. Respond 2xx quickly — Do heavy processing asynchronously after acknowledging the webhook
  2. Verify signatures — Always validate X-Webhook-Signature before processing
  3. Handle duplicates — Use the X-Webhook-Delivery header as an idempotency key; retries of the same event reuse it
  4. Monitor deliveries — Check webhook delivery logs in the dashboard for failures
  5. Use specific events — Subscribe only to events you need rather than all events
  6. Secure your endpoint — Use HTTPS and restrict access to Space Invoices IP ranges if possible