Webhooks

Receive events in real time and keep your integration in sync with Easyflow.

On this page

Webhooks are the safest and most reliable way to stay up to date. Instead of asking the API for changes, your server receives an HTTP request from Easyflow as soon as something happens, such as an order being paid or a subscription being canceled.

How it works

  1. You register the URL of an endpoint on your server with Easyflow and choose the events you want to receive.
  2. When one of those events happens, Easyflow sends a POST request to your URL with a JSON body.
  3. Your server processes the event and answers with a 2xx status code.

Payload

Every delivery has the same envelope: the name of the event, when it was sent and its data.

{
  "event": "order.paid",
  "occurredAt": "2025-01-01T12:00:05.000Z",
  "payload": {
    "id": "1a3c5e7a-9c1e-4a5c-8e9a-1c3e5a7c0029",
    "status": "paid",
    "valueInCents": 4990,
    "createdAt": "2025-01-01T12:00:00.000Z"
  }
}
Field Description
event Name of the event, such as order.paid.
occurredAt Date and time when the notification was sent, in UTC.
payload Complete data of the resource at the moment of the event.

The fields of payload depend on the type of the event. The example above is shortened. See the complete payloads below.

Event types

Type Prefix Payload
Orders order. Order events
Subscriptions subscription. Subscription events
Subscription recurrences subscriptionRecurrence. Recurrence events
Payments payment. Payment events
Payment links paymentLink. Payment link events
Commissions commission. Commission events

For example, order.paid is sent when an order is fully paid and subscription.canceled when a subscription is canceled. The webhook events page lists every event name.

Group Events
Payment links paymentLink.created, paymentLink.updated, paymentLink.removed, paymentLink.published, paymentLink.unpublished, paymentLink.expired, paymentLink.canceled
Commissions commission.created, commission.updated, commission.released
  • subscription.deactivated and subscription.inactivated both leave the subscription with the status inactive, without canceling it. subscription.deactivated is automatic: it is sent when a recurrence used all its retries without being paid. subscription.inactivated is sent when the subscription is inactivated manually.
  • A recurrence is a billing cycle of the subscription, not a charge attempt. Its id stays the same across the retries, each attempt adds an item to payments, and subscriptionRecurrence.failed is sent for every attempt that fails. See Subscription cycles.
  • Only the first cycle, charged when the buyer subscribes, is an order with order.paid. The following cycles create no order and send subscriptionRecurrence.* events.
  • Every subscription.* event brings orderId, the order of the subscription, and paymentLinkId, the payment link that created it or null. Use orderId to match the subscription with its order. See Order and payment link of the subscription.
  • Every item of the order.* events brings subscription, with only the id of the subscription of the item, or null. order.created always comes with null, and order.paid of the first cycle can also come with null: then subscription.created brings the link. See Subscription of the item.
  • On a payment link with maxOrdersPerLink, paymentLink.canceled is sent when the limit is reached, and it can arrive before or after order.paid. Treat them as independent events. See the payment link events.

Receiving events

A minimal receiver in Node.js with Express:

import express from 'express';

const app = express();

app.post('/webhooks/easyflow', express.json(), (request, response) => {
  const { event, payload } = request.body;

  if (event === 'order.paid') {
    markOrderAsPaid(payload.id);
  }

  response.sendStatus(200);
});

app.listen(3000);

Best practices

  • Answer quickly. Return a 2xx status as soon as you receive the event and do heavy work in the background.
  • Handle repeated deliveries. When your endpoint fails, the notification is kept in a queue and sent again later. Use the resource id and its status to make your processing idempotent.
  • Check the current state. Compare the status in the payload with what you have stored, or fetch the resource from the API before taking irreversible actions.
  • Protect your endpoint. A webhook configuration can include custom headers, such as an Authorization token, that are sent with every delivery. When your webhook has them, check them before trusting a request. When you read the configuration back, for example in a list of webhooks or in the details of a webhook or of a delivery log, the header values are shown as [REDACTED]. Only the standard headers Accept, Accept-Encoding, Content-Encoding, Content-Length, Content-Type and User-Agent keep their values. Every delivery still sends the headers with their real values.
  • Use HTTPS. Your endpoint receives personal and financial data.