Send changes to a webhook
A webhook sends changes to your Morphic content to an address you choose, as a JSON request. Your endpoint can use the sequence number and signature to check each request.
Before you start
- You need an administrator account.
- You need a public endpoint that accepts
POSTrequests with a JSON body. Morphic rejects an address that is not a publichttporhttpsaddress.
Steps
- Go to Settings > Webhooks.
- Select Add webhook.
- In Address, enter the URL of your endpoint. For example:
https://example.com/hooks/morphic - In Signing secret, enter a secret. Leave the field empty to send unsigned requests.
- Select Generate to create a random secret.
- In Models, select the models to send. If you select none, Morphic sends changes for all models.
- In Changes, select the kinds of change to send. If you select none, Morphic sends every change.
- Select Save webhooks.
Result
- Morphic saves the webhook. The status shows Up to date, or N changes waiting when changes are still to be delivered.
- For each change, Morphic sends an HTTP request with a JSON body that describes it.
- Each request carries the header
X-Morphic-Seqwith the sequence number of the change. Changes arrive in sequence order. - If you set a secret, each request also carries
X-Morphic-Signature: sha256=followed by the HMAC-SHA256 of the raw body, computed with the secret. - Delivery runs in the background every minute. Each request times out after 5 seconds.
If the address does not answer 2xx
Morphic stops at the first change that the address does not accept. It shows Delivery paused with the address and the answer. It retries that change every minute until the address answers with any 2xx status. Later changes wait until then, so none are skipped.
Related
- Webhook delivery is paused
- Webhooks settings
- Error codes and messages reference
- Morphic hooks and filters reference
Next steps
- Verify the signature in your endpoint. The Webhooks tab links to the verification examples through How to verify signatures.