Skip to main content
Version: next

Simulating Prismic Webhook

Learn how to simulate Prismic webhooks in your development environment to refresh content without restarting the application.

Overview

In production, webhooks ensure that Front-Commerce always fetches the latest version of your Prismic content. However, in a development environment, you can:

  1. Skip webhook configuration initially - content will refresh based on your FRONT_COMMERCE_PRISMIC_API_CACHE_TTL_IN_SECONDS setting
  2. Manually simulate webhooks when needed to fetch the latest content without restarting the application

Simulating a Webhook

You can trigger a manual content refresh by sending a POST request to the webhook endpoint:

http://localhost:4000/prismic/webhook

The request must include:

  • Method: POST
  • Content-Type: application/json
  • Body: A JSON object with the following structure:

Example using cURL:

curl --request POST 'http://localhost:4000/prismic/webhook' \
--header 'Content-Type: application/json' \
--data-raw '{
"secret": "the value of FRONT_COMMERCE_PRISMIC_WEBHOOK_SECRET",
"type": "api-update",
"masterRef": true
}'
Convenient One-liner

From your Front-Commerce project root, you can use this convenient one-liner that automatically uses your environment variables:

source .env ; PAYLOAD=`printf '{"secret": "%s", "type": "api-update", "masterRef": true}' $FRONT_COMMERCE_PRISMIC_WEBHOOK_SECRET` ; curl -H "Content-Type: application/json" -d "$PAYLOAD" $FRONT_COMMERCE_URL/prismic/webhook