Skip to content

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

  1. Go to Org → Data Forwarding
  2. Click + New Profile
  3. Select HTTP Post as the type
  4. Enter your webhook URL
  5. Click Save

Step 2: Test Your Configuration

Before using your production endpoint, you can test with the built-in test endpoint:

  1. In the profile card, find the Test Endpoint section
  2. Copy the Test URL provided
  3. Create a new profile using this test URL
  4. Send data from your device
  5. 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

HeaderValue
Content-Typeapplication/json
AuthorizationBearer <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

FieldTypeDescription
agri_idstringFactor identifier (format: d-{org}-{device}-{channel}-{index})
tintegerUnix timestamp (seconds)
valuenumberFactor value
the_typeintegerFactor type code
org_idstringOrganization 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:

OptionRequiredDescription
URLYesYour webhook endpoint URL
Secret KeyNoFor request authentication
NameNoA friendly name for this profile
PriorityNoExecution order (higher = earlier)

Implementing Your Endpoint

To receive data from YenGear IoT Cloud, your endpoint should:

  1. Accept POST requests
  2. Parse the JSON array from the request body
  3. 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

ProblemSolution
No data receivedCheck the profile is Enabled and URL is correct
Connection errorsVerify your endpoint is publicly accessible
Authentication errorsVerify your Secret Key matches
Timeout errorsOptimize 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.