> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docku.mertani.com/llms.txt.
> For full documentation content, see https://docku.mertani.com/llms-full.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

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: webhook-api
  version: 1.0.0
paths:
  /webhook/sensor-data:
    post:
      operationId: receive-sensor-data
      summary: Receive Sensor Data
      description: |
        Endpoint simulasi untuk webhook.
        Digunakan untuk testing payload sebelum integrasi sebenarnya.
      tags:
        - ''
      parameters:
        - name: X-API-KEY
          in: header
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                description: Any type
        '429':
          description: Too Many Requests
          content:
            application/json:
              schema:
                description: Any type
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WebhookEnvelope'
servers:
  - url: https://yourdomain.co.id/external/v1
components:
  schemas:
    WebhookEnvelope:
      type: object
      properties:
        event:
          type: string
        device_id:
          type: string
        timestamp:
          type: string
          format: date-time
        data:
          type: object
          additionalProperties:
            description: Any type
          description: Flexible payload
        metadata:
          type: object
          additionalProperties:
            description: Any type
      required:
        - event
        - device_id
        - timestamp
        - data
      title: WebhookEnvelope
    WebhookResponse:
      type: object
      properties:
        message:
          type: string
      title: WebhookResponse
  securitySchemes:
    webhookApiKey:
      type: apiKey
      in: header
      name: X-API-KEY

```

## SDK Code Examples

```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": "<apiKey>",
    "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': '<apiKey>', '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", "<apiKey>")
	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"] = '<apiKey>'
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<String> response = Unirest.post("https://yourdomain.co.id/external/v1/webhook/sensor-data")
  .header("X-API-KEY", "<apiKey>")
  .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
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->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' => '<apiKey>',
  ],
]);

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", "<apiKey>");
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": "<apiKey>",
  "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()
```

```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": "<apiKey>",
    "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': '<apiKey>', '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", "<apiKey>")
	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"] = '<apiKey>'
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<String> response = Unirest.post("https://yourdomain.co.id/external/v1/webhook/sensor-data")
  .header("X-API-KEY", "<apiKey>")
  .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
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->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' => '<apiKey>',
  ],
]);

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", "<apiKey>");
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": "<apiKey>",
  "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()
```