Creating a webhook
There are two ways to create a webhook, either through the
webhook dashboard or through the API of the Weeztix system. As mentioned in introduction, you require an application that can receive POST-requests from the Weeztix system before you create a webhook.
The Weeztix system has various resources for which webhooks can be created. Listed below are the resources for which webhooks can be created and the triggers that can invoke the webhook for that resource.
| Revision | Scan | Order | |||||||
|---|---|---|---|---|---|---|---|---|---|
| Create | Update | Delete | Relation | Reorder | Scan | Paid | Updated | Placed | |
| order | x | x | x | ||||||
| shop | x | x | x | x | |||||
| ticket | x | x | x | x | x | x | |||
| event | x | x | x | x | x | ||||
| ticket_type | x | ||||||||
| scanner | x | ||||||||
| scannertype | x | x | x | x | |||||
| product | x | x | x | x | x | ||||
| productgroup | x | x | x | x | x | ||||
| export | x | x | x | ||||||
| eventdate | x | x | x | x | |||||
| eventlocation | x | x | |||||||
| coupon | x | x | x | x | |||||
| couponcode | x | x | |||||||
| metadata | x | x | x | x | |||||
| waitinglist | x | x | x | ||||||
| signup - waiting list | x | x | |||||||
| company | x | ||||||||
Dashboard
You can create a webhook through the webhook dashboard as follows:
- Open the webhook dashboard
- Click the Create new button
- Change the
NameandDestination URLName: a descriptive name of the webhook.Destination URL: the URL that will receive the POST-requests.
- Select a resource and trigger in the dropdown menus
- Click the Create button
After you create a webhook, it will be listed on this dashboard.
Triggered by child resources
It can be desirable to receive a webhook for any specific trigger related to a single resource. For
example, a webhook receiving all newly created product- and ticket-types for some event. This is
supported using the so-called Triggered by child resources option. The
Triggered by child resources option, which allows users to create webhooks that are invoked by its
direct triggers, but aso by triggers of related resources.
It used to be available to just "child" resources, but this is no longer the case. An apter name would thus be
Triggered by related resources.
Triggers on some resource propagate to all webhooks registered
on the same trigger with the Triggered by child resources option enabled, even when there is no
webhook registered for that resource.
The following table shows which triggers on which resources can propagate. The rows depict the
source resource that initiates the trigger. The columns show the resources the trigger can propagate
to when Triggered by child resources is enabled. The values in the cells depict the trigger types
that propagate.
| Event | Ticket | Ticket Type | Product | Shop | |
|---|---|---|---|---|---|
| Revision - all resources | Create, Update, Delete, Relation, Reorder | - | - | - | - |
| Scanner | Scan | Scan | Scan | Scan | - |
| Order | Paid, Updated, Placed | Paid, Updated, Placed | - | Paid, Updated, Placed | Paid, Updated, Placed |
Consider an example where a webhook is configured for the Ticket resource on trigger "paid" with
Triggered by child by resource enabled. When an Order — a related resource of Ticket — is
paid, the Triggered by child resource setting triggers the webhook for the Ticket resource.
The same holds for a webhook for the Event resource on trigger "create". When enabling
Triggered by child resources in the settings of this webhook, the webhook will also trigger when a
Ticket or Product has been created.
API
You can create a webhook through the API by making a POST-request to
https://webhooks.weeztix.com. For this, you require the following information:
name: the name for the webhook.url: the callback URL to which the POST-request notifications will be sent.resource: the type of resource for which the webhook will be created.trigger: the trigger that invokes the webhook. This is one of create, update, delete, relation, reorder or scan.retries: maximum number of retries for failed POST-requests, see remarks.
In addition to the required information, you can supply the following information to the POST-request:
identifier: the GUID of a specific resource type for which the webhook should be created (for example, only invoke the webhook when a chosen event is updated).
See the code blocks below for examples of these requests and their expected response.
- PHP
- GO
- Node
- Shell
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer $accessToken"
],
CURLOPT_POSTFIELDS => [
"name" => "My Example Webhook",
"url" => "https =>//example.com/webhook/receive",
"resource" => "shop",
"trigger" => "create",
"retries" => 3
],
CURLOPT_URL => "https://webhooks.weeztix.com/webhook"
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
payloadBuf := new(bytes.Buffer)
json.NewEncoder(payloadBuf).Encode({
"name": "My Example Webhook",
"url": "https://example.com/webhook/receive",
"resource": "shop",
"trigger": "create",
"retries": 3
})
req, _ := http.NewRequest("PUT", "https://webhooks.weeztix.com/webhook", bytes.NewBuffer(body))
req.Header.Add("Authorization", "Bearer " + accessToken)
resp, _ := http.DefaultClient.Do(req)
respBody, _ := io.ReadAll(resp.Body)
fmt.Println(string(respBody))
const options = {
"method": "POST",
"headers": {
"Authorization": `Bearer ${accessToken}`,
"Content-Type": "application/json"
},
"body": JSON.stringify({
"name": "My Example Webhook",
"url": "https://example.com/webhook/receive",
"resource": "shop",
"trigger": "create",
"retries": 3
})
};
fetch("https://webhooks.weeztix.com/webhook", options)
.then(response => response.json())
.then(response => console.log(response))
curl -X POST \
-H "Authorization: Bearer $accessToken" \
-F "name=My Example Webhook" \
-F "url=https://example.com/webhook/receive" \
-F "resource=shop" \
-F "trigger=create" \
-F "retries=3" \
"https://webhooks.weeztix.com/webhook"
Response
{
"guid": "96007e9b-b570-454c-aa3b-66a33a88280a",
"created_at": "2023-07-19T09:43:50Z",
"updated_at": "2023-07-19T09:43:50Z",
"deleted_at": null,
"company_id": "d0a3f370-cd43-11ed-9c9c-bbcffde24a48",
"name": "My Example Webhook",
"url": "https://example.com/webhook/receive",
"retries": 3,
"resource": "ticket",
"identifier": "",
"nonce": "5aK2HMgcUlDCWLuC3KWa",
"trigger": "create",
"triggered_by_child_resources": false,
"invocations": null
}