Webhooks allow you to track the status of an order. Every phase of the checkout has its own webhook events, making it easy to track each stage of the checkout process.

How to Set up Webhooks

In this guide, you will use nodejs to create an API endpoint to listen for and parse webhook events. To get started:

1. Create an endpoint route

Using a standard nodejs API server, create an endpoint.

2. Configure the endpoint to read and parse webhook events

Webhook events are sent as HTTP POST requests. To process them, your server must parse the request body and handle the event accordingly. On this endpoint, modify the code to handle POST requests only. When a POST request comes through, parse the webhook event of the request body. Ensure your webhook listener responds with a 200 status code. Otherwise the webhook may be sent until you acknowledge it.

The snippet below is an example handler that parses webhook events:

// endpoint.js

// listen to webhook ingestion
export default function handler(req, res) {
    if (req.method === "POST") {
        console.log(`[webhook] Successfully minted ${req.body.id}`);
        return;
    }
    res.status(200).json({});
}

Do not be strict with payload validations as Crossmint may add new fields to the webhooks as products evolve.

Your server must return a 2xx HTTP status so the webhook is marked as delivered.

3. Pre & post processing

Add your pre and post processing logic when setting up your webhook listener. For example, you can call back to your database when a certain id has succeeded or even use Sendgrid or EmailJS to send an email to a recipient when a mint completes.

4. Setting Up Webhooks on the Crossmint Console

Register your newly created endpoint in the Crossmint Developer Console for the relevant webhook event types by following [this guide] (/introduction/platform/webhooks/add-endpoint). Once done, you’ll be redirected to the endpoint details page. Here, you can find the signing secret for verifying webhooks and see a table of all triggered webhook events.

The last step is to test the endpoint. To do this, purchase some NFTs and observe the responses to ensure everything is set up correctly.

Webhooks Available

The quote phase events are only available on Checkout V3.
TypeDescription
orders.quote.createdTriggered when a new order is created in the system, initiating the checkout process.
orders.quote.updatedTriggered when an existing order is updated, such as when modifying the recipient or item details.
orders.payment.succeededTriggered as soon as a payment is successfully processed and confirmed.
orders.payment.failedTriggered when a payment attempt fails, for example, due to insufficient funds or invalid payment details.
orders.delivery.initiatedTriggered when the delivery process begins after the payment has been successfully processed.
orders.delivery.completedTriggered when the delivery of the order is successfully completed and confirmed by the system.
orders.delivery.failedTriggered when the delivery of an order fails, for example, due to an item being unavailable during the minting process.

You can check the responses of each event in the webhooks section in the Developer Console.