Use this file to discover all available pages before exploring further.
Creating NFT collections and minting or editing NFTs are operations that must be sent to a blockchain. Transaction confirmation on the blockchain can take a few seconds, but during network congestion, it may take several minutes. Webhooks and the action status API allow you to stay up to date on the status of these asynchronous operations.Some cases where you may want to listen to when transactions are confirmed include:
Notifying your customers via email that their NFT is ready to access
Updating your database with the NFT id for the user
Showing in your website that that the mint has been successful
Call the following API to check the status of an action:
cURL
# Set your variablesenv=staging # or "www" for productionYOUR_API_KEY=<ENTER_YOUR_API_KEY>actionId=<ENTER_YOUR_actionId># Execute the curl commandcurl --request GET \--url "https://${env}.crossmint.com/api/2022-06-09/actions/${actionId}" \--header 'accept: application/json' \--header "x-api-key: ${YOUR_API_KEY}"
API Reference
Where can I find the actionId and API_KEY?
actionID is returned from any async API calls you perform.
YOUR_API_KEY can be found in the Developers -> API Keys tab of the Production or Staging consoles.
2. Configure the endpoint to read and parse webhook events
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 ingestionexport default function handler(req, res) { if (req.method === "POST") { console.log(`[webhook] Successfully minted ${req.body.id}`); } res.status(200).json({});}
Don’t be strict with payload validations as Crossmint may add new fields to
the webhooks as products evolve.
Here are some examples of the webhook results (with dummy data):
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.
Add an endpoint for the event mint.succeeded by following this guide.Once completed, you’ll be redirected to the endpoint details page. Here, you can find the signing secret for verifying webhooks and view a table of all triggered webhook events.
The final step is to test the endpoint. To do so, mint one or two NFTs with the API and observe the responses to verify setup success.