Webhook Settings
Learn how to configure webhook message templates to extract data from incoming JSON payloads.
Message Template Syntax
When creating a webhook, you define a message template that determines how incoming JSON data is formatted into notifications.
Basic Patterns
| Pattern | Description |
|---|---|
* | Output the entire JSON payload |
%field% | Extract a top-level field |
%object.field% | Extract a nested field |
%array.0% | Get first element of an array |
%array.0.field% | Get a field from array element |
Examples
Example JSON Payload
Consider this incoming webhook payload:
json
{
"event": {
"title": "New Order",
"message": "A new order has been placed with ID 12345",
"tags": ["order", "new"],
"users": [
{"first": "Dale", "last": "Murphy", "age": 44, "nets": ["ig", "fb", "tw"]},
{"first": "Roger", "last": "Craig", "age": 68, "nets": ["fb", "tw"]},
{"first": "Jane", "last": "Murphy", "age": 47, "nets": ["ig", "tw"]}
]
}
}Template Configuration
text
*text
Title: %event.title%
Message: %event.message%
Tags: %event.tags%
Users: %event.users.0%
First user: %event.users.0.first% %event.users.0.last%Output Result
Title: New Order
Message: A new order has been placed with ID 12345
Tags: ["order","new"]
Users: {"age":44,"first":"Dale","last":"Murphy","nets":["ig","fb","tw"]}
First user: Dale MurphyCommon Integrations
GitHub Webhooks
text
🔔 %action%: %repository.full_name%
%sender.login%: %commits.0.message%Sentry Error Tracking
text
🚨 %project_name%: %message%
Level: %level%
URL: %url%Grafana Alerts
text
⚠️ %state%: %title%
%message%
Status: %status%Uptime Robot
text
🔴 %monitorFriendlyName%
Status: %alertTypeFriendlyName%
Details: %alertDetails%Advanced Path Syntax
For complex JSON extraction, we use GJSON Path Syntax.
Useful Patterns
| Pattern | Description |
|---|---|
%users.#% | Count of array items |
%users.#.first% | Array of all first values |
%users.@reverse% | Reverse array order |
%data.@pretty% | Pretty-print JSON |
Learn More
Full documentation: GJSON Path Syntax
Testing Your Webhook
After creating a webhook, you can test it:
bash
curl -X POST "https://api.pocketalert.app/v1/webhooks/receive/YOUR_WEBHOOK_URL" \
-H "Content-Type: application/json" \
-d '{"event": {"title": "Test", "message": "Hello World"}}'javascript
await fetch('https://api.pocketalert.app/v1/webhooks/receive/YOUR_WEBHOOK_URL', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
event: { title: 'Test', message: 'Hello World' }
})
});python
import requests
requests.post(
'https://api.pocketalert.app/v1/webhooks/receive/YOUR_WEBHOOK_URL',
json={'event': {'title': 'Test', 'message': 'Hello World'}}
)php
Http::post('https://api.pocketalert.app/v1/webhooks/receive/YOUR_WEBHOOK_URL', [
'event' => [
'title' => 'Test',
'message' => 'Hello World',
],
]);This will send a test notification to your devices using your configured message template.
