Introduction
Webhook is a notification of an event published in a URL of your choice.Webhooks are useful for integration with third-party services and other external APIs that support them.
Qapla' webhook is part of the API of Qapla'.
API Key
In order to use the APIs it is necessary to be aware of the Private API Keys assigned to your channel(s), which are located on the Control Panel in section "Settings \ [CHANNEL_NAME]"This API key must be protected and kept secret.

Security
The IP addresses from which it will be possible to receive the POST of the webhook are:- 34.96.89.1
- 35.195.3.242
- 35.205.84.188
- 35.205.236.254
- 34.78.56.172
- 35.195.153.127
- 35.205.146.223
Shipments webhook
Each change of shipment status communicated by the courier (ex: if the shipment changes from "delivery" to "delivered"), a POST in JSON format is sent to the URL indicated in the channel configuration on the Qapla' control panel.POSThttps://[YOUR_ENDPOINT]
HTTP POST
In a POST at the endpoint indicated in the channel configuration Qapla' Control Panel, like:POST / HTTP/1.1 Content-Type: application/json; Content-Length: 1232 Host: webhook.qapla.it Connection: Keep-Alive User-Agent: Mozilla/5.0it will be sent the following communication: "statusDetails" will be sent if necessary as follows. For example, note the "STOCK" status detail, referring to the "EXCEPTION" status.
Description
Following the description of the individual parameters.Parameter | Description |
---|---|
apiKey(string) | The API Key of the channel from which we are receiving the notification. |
trackingNumber(string) | The tracking number of the shipment |
return(int) | It is 1 if it is a return shipment |
hasChildren(int) | It is 1 if the shipment has "child" shipments |
isChild(int) | It is 1 if the shipment is a "child" shipment |
courier(string) | The Qapla' courier code |
reference(string) | Order's alphanumeric reference |
date(string) | The status date, as reported by the courier |
courierStatus(string) | The status communicated by the courier |
place(string) | The place communicated by the courier |
qaplaStatusID(string) | The "translation" of the status of the courier in the Qapla' status |
qaplaStatus | Status description |
statusDetails | The ID of possible detail |
custom1 | Possible custom1 value of the shipment |
custom2 | Possible custom2 value of the shipment |
custom3 | Possible custom3 value of the shipment |
Response
The response from URL called must be:{"result": "OK"}
Only in case of error will be:
{"result": "KO"}
Retry
The result "KO" or any other type of wrong answer that is not "OK" will force the webhook to retry the transmission 2 more times in the following hours.
Abuse
After 100 failed transmission attempts (i.e. with "KO" response or non-compliant response) the service will be disabled.
Enpoint example
POSThttps://[YOUR_URL]/qaplaWebhook.php
The following example of a "listening" page takes the JSON content and processes it.
<?php //...I set the content-type as JSON header('Content-type: application/json; charset=utf-8'); //...API Key that I expect const API_KEY = '[API_KEY]'; //...I obtain the string sent as a POST $data = file_get_contents('php://input'); //...If it is empty I get very angry if(empty($data)): exit('{"result": "KO"}'); endif; //...I turn it in a JSON $json = json_decode($data); //...If it's an incorrect JSON, I get even more angry if(($json === false)) exit('{"result": "KO"}'); endif; //...I verify that the API KEY posted matches, security check. if($json->apiKey !== API_KEY): exit('{"result": "KO"}'); endif; //...I update the potential table $sql = "UPDATE orders-shipments SET status = ".$json->qaplaStatusID." WHERE id = ".$json->reference; //...Everything right, I write "result": "OK" in JSON echo '{"result": "OK"}'; ?>
Test
Test your endpoint and send a typical Qapla' transmission.
Shipments return webhook
Each return request from the end customer * will be sent to an endpoint defined on the Qapla 'Control Panel , details of the return shipment.POSThttps://[YOUR_ENDPOINT]*This service is only available after enabling, configuring and purchasing the Automatic Returns (Type 3 Returns) service on the Qapla 'Store.
HTTP POST
Below is a detailed example of the POSTPOST / HTTP/1.1 Content-Type: application/json; Content-Length: 1232 Host: webhook.qapla.it Connection: Keep-Alive User-Agent: Mozilla/5.0
Description
Below is the description of the individual parameters.Parameter | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
apiKey(string) | The API Key of the channel from which we are receiving the notification. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
returnShipments(object[]) |
|
Response
The response of the URL named should be :{"result": "OK"}
While only in case of error will it be:
{"result": "KO"}
Retry
The result "KO" or any other type of incorrect response other than "OK" will force the webhook to retry the transmission 2 more times in the following hours.
Abuse
After 100 failed transmission attempts (ie with "KO" or non-compliant response) the service will be deactivated.
Orders webhook
Webhook can be configured to be sent when the shipment is created (label printing) or sent (sending confirmation to the courier), in the appropriate section on Control Panel of Qapla'.
POSThttps://[YOUR_ENDPOINT]
HTTP POST
In a POST at the endpoint indicated in the channel configuration on Qapla' Control Panel, like:POST / HTTP/1.1 Content-Type: application/json; Content-Length: 1232 Host: webhook.qapla.it Connection: Keep-Alive User-Agent: Mozilla/5.0it will be sent the following communication:
Description
apiKey(string) | The API Key of the channel from which we are receiving the notification. | ||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
orders(array) |
It is an array of orders.
|
Test
Test your endpoint and send a typical Qapla' transmission.
Qapla' Status
It is the interpretation of the status of the shipment with values that Qapla' assigns to each possible state of the courier.
id | detailID | Name | Description | |
---|---|---|---|---|
0 | PROCESSING WAIT | |||
1 | PENDING | Shipment found but any news yet from courier. | ||
2 | WAITING FOR PICK-UP | The courier didn’t pick up the shipment yet. | ||
20 | DEPARTED | Shipment departed. | ||
3 | IN TRANSIT | The goods are in transit. | ||
50 | PROCESSING | Processing | ||
50 | 1 | PROCESSING • CUSTOMS | ||
4 | OUT FOR DELIVERY | Shipment in delivery. | ||
5 | FAILED DELIVERY ATTEMPT | Delivery failed. Early warning for potential problems. | ||
8 | DELAY | Shipment is suffering delay. | ||
6 | EXCEPTION | There is a problem; generic or explained by additional icons. | ||
6 | 1 | EXCEPTION • STOCK | ||
6 | 2 | EXCEPTION • RETURN | ||
6 | 3 | EXCEPTION • DAMAGED | ||
6 | 4 | EXCEPTION • LOST | ||
6 | 5 | EXCEPTION • PARTIAL DELIVERY | ||
10 | PICKUP POINT | Delivered to a PickUp Point. | ||
95 | RETURNED | Shipment returned to sender. | ||
99 | DELIVERED | The shipment has been delivered to the recipient. |