Skip to main content

Creating a webhook

There are two ways to create a webhook, either through the webhook dashboard or through the API of the OpenTicket system. As mentioned in introduction, you require an application that can receive POST-requests from the OpenTicket system before you create a webhook.

The OpenTicket 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.

CreateUpdateDeleteRelationReorderScan
Eventxxxx
Orderxxxx
Ticketxxxx
Metadataxxx

Dashboard

You can create a webhook through the webhook dashboard as follows:

  1. Open the webhook dashboard
  2. Click the Create new button
  3. Change the Name and Destination URL
    • Name: a descriptive name of the webhook.
    • Destination URL: the URL that will receive the POST-requests.
  4. Select a resource and trigger in the dropdown menus
  5. Click the Create button

After you create a webhook, it will be listed on this dashboard.

API

You can create a webhook through the API by making a POST-request to https://webhooks.openticket.tech. 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.

$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.openticket.tech/webhook"
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;