Appearance
HTTP Post Forwarding
Send device data to any HTTP endpoint in real-time. HTTP Post forwarding is ideal for integrating with custom APIs, automation platforms, and third-party services.
Overview
When your devices report data to YenGear IoT Cloud, the platform can automatically forward that data to your specified URL via HTTP POST requests.
Quick Start
Step 1: Create a Forwarding Profile
- Go to Org → Data Forwarding
- Click + New Profile
- Select HTTP Post as the type
- Enter your webhook URL
- Click Save
Step 2: Test Your Configuration
Before using your production endpoint, you can test with the built-in test endpoint:
- In the profile card, find the Test Endpoint section
- Copy the Test URL provided
- Create a new profile using this test URL
- Send data from your device
- Click View Test Data to see received payloads in JSON format
Note: Test endpoints store up to 50 records per organization. Older records are automatically removed.
Step 3: Verify Data Reception
Once configured, your endpoint will receive POST requests containing device data.
Request Format
HTTP Headers
| Header | Value |
|---|---|
Content-Type | application/json |
Authorization | Bearer <secret_key> (if configured) |
Request Body
The request body is a JSON array containing one or more data points:
json
[
{
"agri_id": "d-1000-abc-1-00",
"t": 1709856000,
"value": 25.5,
"the_type": 2001,
"org_id": "your-org-slug"
},
{
"agri_id": "d-1000-abc-1-01",
"t": 1709856000,
"value": 65.2,
"the_type": 2002,
"org_id": "your-org-slug"
}
]Field Descriptions
| Field | Type | Description |
|---|---|---|
agri_id | string | Factor identifier (format: d-{org}-{device}-{channel}-{index}) |
t | integer | Unix timestamp (seconds) |
value | number | Factor value |
the_type | integer | Factor type code |
org_id | string | Organization slug |
Example: Multiple Factors
json
[
{
"agri_id": "d-1000-abc-1-00",
"t": 1709856000,
"value": 25.5,
"the_type": 2001,
"org_id": "my-org"
},
{
"agri_id": "d-1000-abc-1-01",
"t": 1709856000,
"value": 65.2,
"the_type": 2002,
"org_id": "my-org"
},
{
"agri_id": "d-1000-def-1-00",
"t": 1709856000,
"value": 18.3,
"the_type": 2001,
"org_id": "my-org"
}
]Configuration Options
When creating an HTTP Post profile, you can configure:
| Option | Required | Description |
|---|---|---|
| URL | Yes | Your webhook endpoint URL |
| Secret Key | No | For request authentication |
| Name | No | A friendly name for this profile |
| Priority | No | Execution order (higher = earlier) |
Implementing Your Endpoint
To receive data from YenGear IoT Cloud, your endpoint should:
- Accept POST requests
- Parse the JSON array from the request body
- Return a 2xx status code on success
Example: Node.js (Express)
javascript
const express = require('express');
const app = express();
app.use(express.json());
const SECRET_KEY = 'your-secret-key';
app.post('/webhook/iot-data', (req, res) => {
// Verify authorization (optional)
const authHeader = req.headers['authorization'];
if (SECRET_KEY && authHeader !== `Bearer ${SECRET_KEY}`) {
return res.status(401).json({ error: 'Unauthorized' });
}
// Process data array
const dataPoints = req.body;
dataPoints.forEach(point => {
console.log(`Factor: ${point.agri_id}`);
console.log(`Value: ${point.value}`);
console.log(`Timestamp: ${point.t}`);
});
res.json({ success: true });
});
app.listen(3000);Example: Python (Flask)
python
from flask import Flask, request, jsonify
app = Flask(__name__)
SECRET_KEY = 'your-secret-key'
@app.route('/webhook/iot-data', methods=['POST'])
def receive_data():
# Verify authorization (optional)
auth_header = request.headers.get('Authorization', '')
if SECRET_KEY and auth_header != f'Bearer {SECRET_KEY}':
return jsonify({'error': 'Unauthorized'}), 401
# Process data array
data_points = request.json
for point in data_points:
print(f"Factor: {point['agri_id']}")
print(f"Value: {point['value']}")
print(f"Timestamp: {point['t']}")
return jsonify({'success': True})
if __name__ == '__main__':
app.run(port=3000)Security
Request Authentication
If you set a Secret Key, each request includes an authorization header:
Authorization: Bearer <your-secret-key>Use this to verify requests are from YenGear IoT Cloud.
Best Practices
- Always use HTTPS endpoints
- Set a Secret Key and verify the Authorization header
- Return 2xx status codes for successful processing
- Process requests quickly to avoid timeouts
Troubleshooting
| Problem | Solution |
|---|---|
| No data received | Check the profile is Enabled and URL is correct |
| Connection errors | Verify your endpoint is publicly accessible |
| Authentication errors | Verify your Secret Key matches |
| Timeout errors | Optimize your endpoint response time |
Use Cases
- Custom Dashboards: Feed real-time data to your visualization tools
- Automation: Trigger workflows in Zapier, Make, or n8n
- Alerts: Send data to monitoring systems for threshold alerts
- Data Lakes: Push data to your data processing pipelines
Need Help?
Contact us at [email protected] for technical support.
