Webhook
Overview
Endpoint allows you to register or update your application’s webhook URL for receiving real-time notifications from Komerce. Once set up, this webhook becomes a critical channel through which your system is informed of key order events, such as order status changes, pickup updates, delivery confirmations, cancellations, and more.
By using this endpoint, businesses no longer need to constantly poll the API for updates. Instead, Komerce will automatically push the latest data to your specified endpoint URL whenever an event occurs. This leads to faster system reactions, better resource efficiency, and a seamless user experience across your platform.
Key Feature
✅ Real-Time Event Notification : Automatically receive updates on order status changes without needing to query the API manually.
✅ Flexible URL Management : Easily update the destination URL at any time by sending a new webhook URL to this endpoint.
✅ Supports Multiple Event Types : Events include status updates like ‘Diajukan’, ‘Dijemput’, ‘Dikirim’, ‘Dibatalkan’, ‘Selesai’, etc.
✅ Secure Data Push : Komerce sends structured JSON payloads to your system, allowing you to process updates automatically.
✅ Single Source of Truth : Synchronize internal databases, user interfaces, and notification systems based on real-time data from Komerce.
How it Works
- You Register the Webhook : Send a PUT request to /webhook with your desired webhook URL in the request body.
- Komerce Stores the URL : Komerce saves the URL as the destination for all future event notifications related to your orders.
- Events are Triggered : When a tracked event (e.g., pickup confirmed, delivery completed, order canceled) occurs, Komerce triggers your webhook.
- Komerce Sends a Payload : Komerce sends a structured JSON payload to your webhook URL, including details such as the order number, status, timestamp, and other metadata.
- Your Server Processes the Data : Your server receives the payload and processes it — for example, updating a database, notifying users, or logging the event.
- You Respond with a 200 Status : To confirm that your system has received the payload successfully, return an HTTP 200 response to Komerce.
Request Body
- cURL
- JavaScript
- PHP
- GoLang
- Node
curl --location --request PUT 'your_webhook_handler_url' \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"order_no": "{{ order.no }}",
"cnote": "{{ awb.no }}",
"status": "{{ status }}"
}'
const myHeaders = new Headers();
myHeaders.append("accept", "application/json");
myHeaders.append("Content-Type", "application/json");
const raw = JSON.stringify({
"order_no": "{{ order.no }}",
"cnote": "{{ awb.no }}",
"status": "{{ status }}"
});
const requestOptions = {
method: "PUT",
headers: myHeaders,
body: raw,
redirect: "follow"
};
fetch("your_webhook_handler_url", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'your_webhook_handler_url',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS =>'{
"order_no": "{{ order_no }}",
"cnote": "{{ awb }}",
"status": "{{ status }}"
}',
CURLOPT_HTTPHEADER => array(
'accept: application/json',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "your_webhook_handler_url"
method := "PUT"
payload := strings.NewReader(`{
"order_no": "{{ order.no }}",
"cnote": "{{ awb }}",
"status": "{{ status }}"
}`)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("accept", "application/json")
req.Header.Add("Content-Type", "application/json")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
const axios = require('axios');
let data = JSON.stringify({
"order_no": "{{ order.no }}",
"cnote": "{{ awb }}",
"status": "{{ status }}"
});
let config = {
method: 'put',
maxBodyLength: Infinity,
url: 'your_webhook_handler_url',
headers: {
'accept': 'application/json',
'Content-Type': 'application/json'
},
data : data
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
Response
Response Structure
Key | Type | Description |
---|---|---|
order_no | string | Information on order_no that have change notifications |
cnote | string | Information on awb that have change notifications |
status | string | Current delivery status |
Tips to Avoid Error
✅ Use a valid, HTTPS-secured URL to ensure safe and trusted communication between Komerce and your system.
⚠️ Make sure your server can handle incoming POST requests and is always online to receive webhook notifications.
🛑 Always return a 200 OK HTTP response to signal successful receipt. Failure to do so may lead to retries or webhook deactivation.
🔐 Validate the incoming data to ensure the request is indeed from Komerce (you may implement signature validation for added security if supported).
🧪 Test your webhook handler before going live to verify that it processes the payload correctly and handles edge cases like empty or malformed data.
🔁 Avoid circular API calls that could be triggered by the webhook payload itself to prevent infinite loops in your system.
💾 Log all webhook events for auditing and debugging purposes, especially when errors occur.