Webhooks
What are Plate Webhooks
Webhooks allow you to receive real-time notifications when specific events occur in your Plate application. This guide explains how to create, configure, and use webhooks to integrate with external systems. They provide a way to receive instant notifications about:
- Content changes (posts, elements, sections)
- Form submissions
- User authentication events
- Site translations
- Content object modifications
Available Events
The following event types are available for webhook configuration:
Content Events
- Posts: Create, Update, Status Change, Destroy
- Elements: Create, Update, Destroy
- Sections: Create, Update, Destroy
- Content Objects: Create, Update, Destroy
Form Events
- Form Messages: Create
Authentication Events
- Authentication Objects: Create, Update, Destroy, Confirm Email
Site Events
- Site Translations: Update
Create a Webhook
Create a new webhook by clicking the API button under the header 'Development' in the sidebar and create a new webhook. You need to configure the following parameters:
- Name: A name for your webhook
- Event Class: The specific event type to listen for
- URL: The endpoint where webhook data will be sent
- Active Status: Whether the webhook is enabled or disabled
Plate generates a signing secret for every webhook. You find it on the webhook's edit page. Use it to verify that requests come from Plate.
Webhook Payload Structure
When a webhook is triggered, your webhook endpoint will receive a POST request with the following JSON structure:
{
"event": "post.create",
"data": {
"id": "123",
"type": "post",
"attributes": {
"title": "Sample Post",
"content": "Post content...",
"status": "published"
}
}
}
Payload Fields
| Field | Description | Example |
|---|---|---|
event | The event type in resource.action format | post.create, element.update |
data | The complete data object for the involved content item, formatted as API JSON | {"id": "123", "type": "post", "attributes": {...}} |
Handling Deleted Content Items
If a content item has been deleted, the payload will contain minimal information:
{
"event": "post.destroy",
"data": {
"id": "123"
}
}
Event Filtering
You can configure filters to receive webhooks only for specific conditions:
Available Filters
- Element Type: Filter by specific element types
- Section Type: Filter by specific section types
- Post Type: Filter by specific post types
- Content Type: Filter by content object types
- Authentication Type: Filter by authentication object types
Filter Configuration
- Select an event class that supports filtering
- Choose the filter type from the dropdown
- Select the specific value to filter on
- Add multiple filters as needed
Example: Configure a webhook for "Post Create" events, filtered to only trigger for "Blog Post" type posts.
Testing Webhooks
Send Test Webhook
Test your webhook by clicking the 'test' button in the webhook index page.
This allows you to verify:
- URL accessibility
- Request format
- Response handling
Testing Checklist
- Webhook URL is accessible
- Server responds with 2xx status code
- Request headers are properly set
- JSON payload is valid
- Your application processes the data correctly
HTTP Request Details
Headers
Webhook requests include the following headers:
Content-Type: application/json
User-Agent: PlateWebhooks
Accept: */*
webhook-id: msg_2b7a0c1e-4f3d-4a8e-9c61-0d5e7f2a9b34
webhook-timestamp: 1761750000
webhook-signature: v1,K5oZfzN95Z9UVu1EsfQmfVNQhnkZ2pj9o9NDN/H/pI4=
| Header | Description |
|---|---|
webhook-id | Unique ID of this message |
webhook-timestamp | Time the message was sent, in Unix seconds |
webhook-signature | Signature of the request, see Verifying Webhook Signatures |
Request Method
All webhook requests use the POST method.
Verifying Webhook Signatures
Plate signs every webhook request, including test webhooks, so you can check that a request comes from Plate and was not changed on the way. Signatures follow the Standard Webhooks specification, so you can also use one of its official libraries instead of writing the check yourself.
Get the Signing Secret
Open the webhook's edit page and copy the signing secret. It starts with whsec_. Store it in your receiving application's configuration, the same way you store other secrets.
Note: Keep the signing secret private. Anyone who has it can create requests that pass verification.
Verify a Request
To verify a request:
- Remove the
whsec_prefix from the signing secret and base64-decode the rest. The result is the signing key. - Build the signed content:
{webhook-id}.{webhook-timestamp}.{body}, wherebodyis the raw request body. - Calculate the HMAC-SHA256 of the signed content with the signing key, and base64-encode the result.
- Compare it with the value after
v1,in thewebhook-signatureheader. Use a constant-time comparison. - Reject the request if
webhook-timestampis more than a few minutes away from the current time. This prevents replay attacks.
Note: Use the raw request body exactly as received. If you parse the JSON and serialize it again, the signature does not match.
The webhook-signature header can contain multiple space-separated signatures. Accept the request if any of them matches.
Example (Node.js)
import crypto from "node:crypto";
const TOLERANCE_IN_SECONDS = 5 * 60;
function verifyPlateWebhook(rawBody, headers, secret) {
const id = headers["webhook-id"];
const timestamp = headers["webhook-timestamp"];
const signatures = headers["webhook-signature"];
if (Math.abs(Date.now() / 1000 - Number(timestamp)) > TOLERANCE_IN_SECONDS) {
return false;
}
const key = Buffer.from(secret.replace(/^whsec_/, ""), "base64");
const expected = crypto
.createHmac("sha256", key)
.update(`${id}.${timestamp}.${rawBody}`)
.digest("base64");
return signatures.split(" ").some((signature) => {
const [version, value] = signature.split(",");
return (
version === "v1" &&
value.length === expected.length &&
crypto.timingSafeEqual(Buffer.from(value), Buffer.from(expected))
);
});
}
Regenerate the Signing Secret
If the signing secret leaks, click Regenerate signing secret on the webhook's edit page. Plate signs all following requests with the new secret.
Warning: Requests signed with the new secret fail verification until you update the secret in your receiving application. The old secret stops working immediately.