Webhooks list

WebhooksFunctionality
users_register - New userThis triggers when a user registers in the database.
orders_register - New orderThis triggers when an order is registered in the database
orders_status_updated - Order status updateThis triggers when the status of an order is changed
orders_update_driver - Order driver updated (driver assigned)This is triggered when a driver is assigned to an order
orders_pending - Order pendingThis triggers when an order is repositioned in a pending state, not when it was created, but when it is already created and reverts to this state.
orders_completed - Order completedThis is triggered when an order is placed in the completed state.
orders_rejected - Order rejectedTriggers when an order is placed in the rejected state
orders_rejected_business - Order rejected by businessTriggers when an order is placed in the rejected by business state
orders_rejected_driver - Order rejected by driverTriggers when an order is placed in the rejected by driver state
orders_accepted_business - Order accepted by businessTriggers when an order is placed in the accepted by business state
orders_accepted_driver - Order accepted by driverTriggers when an order is placed in the accepted by driver state
orders_pickup_completed_driver - Order pickup completed by driverTriggers when an order is placed in the pickup completed by driver state
orders_pickup_failed_driver - Order pickup failed by driverTriggers when an order is placed in the pickup failed by driver state
orders_delivery_completed_driver - Order delivery completed by driverTriggers when an order is placed in the delivery completed by driver state
orders_delivery_failed_driver - Order delivery failed by driverTriggers, when an order is placed in the delivery failed by driver state

Example of webwooks

With this basic example you can see how a webhook works, what will be done is that any order that is received is automatically accepted by the business.

First of all the code that we use to do this, it must also be mounted on some URL

<?php

$data = json_decode(file_get_contents('php://input'));
$order = $data;

$api_key = 'Plese insert an API key';
$url = 'https://apiv4.ordering.co/v400/en/demo/orders/'.$order->id;
$data = http_build_query([
  "status" => 7
]);
$additional_headers = array (                                                                          
  'x-api-key: '.$api_key
);
$ch = curl_init($url);                                                                      
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");                                                                     
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);                                                                  
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
curl_setopt($ch, CURLOPT_HTTPHEADER, $additional_headers); 
curl_exec($ch);
curl_close($ch);

Let's suppose that the URL of the webhook is https://apiv4.ordering.co/autoAccept and since what we want to shoot is when an order is registered we use the hook orders_register. Then the data that we will use to add the webhook is the following.

{
  hook: 'orders_register',
  url: 'https://apiv4.ordering.co/autoAccept'
}