> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docku.mertani.com/api-reference/webhook-api/receive-sensor-data/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docku.mertani.com/_mcp/server. # Receive Sensor Data POST https://yourdomain.co.id/external/v1/webhook/sensor-data Content-Type: application/json Endpoint simulasi untuk webhook. Digunakan untuk testing payload sebelum integrasi sebenarnya. Reference: https://docku.mertani.com/api-reference/webhook-api/receive-sensor-data ## Authentication - `X-API-KEY` header (required) — API Key authentication via header ## Request ### Body (application/json) This endpoint expects a WebhookEnvelope. - `event` (string, required) - `device_id` (string, required) - `timestamp` (datetime, required) - `data` (map from string to any, required) — Flexible payload - `metadata` (map from string to any, optional) ## Response ### 200 Success - `message` (string, optional) ## Errors ### 401 Unauthorized Error Unauthorized - `any` ### 429 Too Many Requests Error Too Many Requests - `any` ## Examples ### Complex payload **Request** ```json { "event": "sensor.data", "device_id": "MTI-002", "timestamp": "2025-01-01T00:00:00Z", "data": { "sensors": [ { "id": "temp", "value": 28.5 }, { "id": "humidity", "value": 80 } ] }, "metadata": { "source": "iot-device" } } ``` **Response** ```json { "message": "Data received successfully" } ``` **SDK Code** ```python Complex payload import requests url = "https://yourdomain.co.id/external/v1/webhook/sensor-data" payload = { "event": "sensor.data", "device_id": "MTI-002", "timestamp": "2025-01-01T00:00:00Z", "data": { "sensors": [ { "id": "temp", "value": 28.5 }, { "id": "humidity", "value": 80 } ] }, "metadata": { "source": "iot-device" } } headers = { "X-API-KEY": "", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript Complex payload const url = 'https://yourdomain.co.id/external/v1/webhook/sensor-data'; const options = { method: 'POST', headers: {'X-API-KEY': '', 'Content-Type': 'application/json'}, body: '{"event":"sensor.data","device_id":"MTI-002","timestamp":"2025-01-01T00:00:00Z","data":{"sensors":[{"id":"temp","value":28.5},{"id":"humidity","value":80}]},"metadata":{"source":"iot-device"}}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go Complex payload package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://yourdomain.co.id/external/v1/webhook/sensor-data" payload := strings.NewReader("{\n \"event\": \"sensor.data\",\n \"device_id\": \"MTI-002\",\n \"timestamp\": \"2025-01-01T00:00:00Z\",\n \"data\": {\n \"sensors\": [\n {\n \"id\": \"temp\",\n \"value\": 28.5\n },\n {\n \"id\": \"humidity\",\n \"value\": 80\n }\n ]\n },\n \"metadata\": {\n \"source\": \"iot-device\"\n }\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("X-API-KEY", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby Complex payload require 'uri' require 'net/http' url = URI("https://yourdomain.co.id/external/v1/webhook/sensor-data") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["X-API-KEY"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"event\": \"sensor.data\",\n \"device_id\": \"MTI-002\",\n \"timestamp\": \"2025-01-01T00:00:00Z\",\n \"data\": {\n \"sensors\": [\n {\n \"id\": \"temp\",\n \"value\": 28.5\n },\n {\n \"id\": \"humidity\",\n \"value\": 80\n }\n ]\n },\n \"metadata\": {\n \"source\": \"iot-device\"\n }\n}" response = http.request(request) puts response.read_body ``` ```java Complex payload import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://yourdomain.co.id/external/v1/webhook/sensor-data") .header("X-API-KEY", "") .header("Content-Type", "application/json") .body("{\n \"event\": \"sensor.data\",\n \"device_id\": \"MTI-002\",\n \"timestamp\": \"2025-01-01T00:00:00Z\",\n \"data\": {\n \"sensors\": [\n {\n \"id\": \"temp\",\n \"value\": 28.5\n },\n {\n \"id\": \"humidity\",\n \"value\": 80\n }\n ]\n },\n \"metadata\": {\n \"source\": \"iot-device\"\n }\n}") .asString(); ``` ```php Complex payload request('POST', 'https://yourdomain.co.id/external/v1/webhook/sensor-data', [ 'body' => '{ "event": "sensor.data", "device_id": "MTI-002", "timestamp": "2025-01-01T00:00:00Z", "data": { "sensors": [ { "id": "temp", "value": 28.5 }, { "id": "humidity", "value": 80 } ] }, "metadata": { "source": "iot-device" } }', 'headers' => [ 'Content-Type' => 'application/json', 'X-API-KEY' => '', ], ]); echo $response->getBody(); ``` ```csharp Complex payload using RestSharp; var client = new RestClient("https://yourdomain.co.id/external/v1/webhook/sensor-data"); var request = new RestRequest(Method.POST); request.AddHeader("X-API-KEY", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"event\": \"sensor.data\",\n \"device_id\": \"MTI-002\",\n \"timestamp\": \"2025-01-01T00:00:00Z\",\n \"data\": {\n \"sensors\": [\n {\n \"id\": \"temp\",\n \"value\": 28.5\n },\n {\n \"id\": \"humidity\",\n \"value\": 80\n }\n ]\n },\n \"metadata\": {\n \"source\": \"iot-device\"\n }\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift Complex payload import Foundation let headers = [ "X-API-KEY": "", "Content-Type": "application/json" ] let parameters = [ "event": "sensor.data", "device_id": "MTI-002", "timestamp": "2025-01-01T00:00:00Z", "data": ["sensors": [ [ "id": "temp", "value": 28.5 ], [ "id": "humidity", "value": 80 ] ]], "metadata": ["source": "iot-device"] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://yourdomain.co.id/external/v1/webhook/sensor-data")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Example 2 **Request** ```json { "event": "sensor.data", "device_id": "MTI-001", "timestamp": "2025-01-01T00:00:00Z", "data": { "temperature": 28.5 } } ``` **Response** ```json { "message": "Data received successfully" } ``` **SDK Code** ```python import requests url = "https://yourdomain.co.id/external/v1/webhook/sensor-data" payload = { "event": "sensor.data", "device_id": "MTI-001", "timestamp": "2025-01-01T00:00:00Z", "data": { "temperature": 28.5 } } headers = { "X-API-KEY": "", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://yourdomain.co.id/external/v1/webhook/sensor-data'; const options = { method: 'POST', headers: {'X-API-KEY': '', 'Content-Type': 'application/json'}, body: '{"event":"sensor.data","device_id":"MTI-001","timestamp":"2025-01-01T00:00:00Z","data":{"temperature":28.5}}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://yourdomain.co.id/external/v1/webhook/sensor-data" payload := strings.NewReader("{\n \"event\": \"sensor.data\",\n \"device_id\": \"MTI-001\",\n \"timestamp\": \"2025-01-01T00:00:00Z\",\n \"data\": {\n \"temperature\": 28.5\n }\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("X-API-KEY", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://yourdomain.co.id/external/v1/webhook/sensor-data") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["X-API-KEY"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"event\": \"sensor.data\",\n \"device_id\": \"MTI-001\",\n \"timestamp\": \"2025-01-01T00:00:00Z\",\n \"data\": {\n \"temperature\": 28.5\n }\n}" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://yourdomain.co.id/external/v1/webhook/sensor-data") .header("X-API-KEY", "") .header("Content-Type", "application/json") .body("{\n \"event\": \"sensor.data\",\n \"device_id\": \"MTI-001\",\n \"timestamp\": \"2025-01-01T00:00:00Z\",\n \"data\": {\n \"temperature\": 28.5\n }\n}") .asString(); ``` ```php request('POST', 'https://yourdomain.co.id/external/v1/webhook/sensor-data', [ 'body' => '{ "event": "sensor.data", "device_id": "MTI-001", "timestamp": "2025-01-01T00:00:00Z", "data": { "temperature": 28.5 } }', 'headers' => [ 'Content-Type' => 'application/json', 'X-API-KEY' => '', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://yourdomain.co.id/external/v1/webhook/sensor-data"); var request = new RestRequest(Method.POST); request.AddHeader("X-API-KEY", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"event\": \"sensor.data\",\n \"device_id\": \"MTI-001\",\n \"timestamp\": \"2025-01-01T00:00:00Z\",\n \"data\": {\n \"temperature\": 28.5\n }\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "X-API-KEY": "", "Content-Type": "application/json" ] let parameters = [ "event": "sensor.data", "device_id": "MTI-001", "timestamp": "2025-01-01T00:00:00Z", "data": ["temperature": 28.5] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://yourdomain.co.id/external/v1/webhook/sensor-data")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```