APIs & Integrations
Webhooks
Receive real-time event notifications pushed directly to your endpoint when things happen on the Optra platform.
Webhooks let Optra push event notifications to a URL you control — no polling required. When a subscribed event occurs, Optra sends an HTTP POST with a JSON payload to your endpoint within seconds.
Setting Up a Webhook
- Go to Settings → Webhooks in the Optra platform.
- Click Add Webhook and enter your endpoint URL.
- Select the event types you want to subscribe to.
- Copy the signing secret — use it to verify incoming payloads.
Event Types
| Event | Description |
|---|---|
| device.connected | Device came online |
| device.disconnected | Device went offline |
| device.registered | New device registered |
| rule.triggered | A rule condition was met |
| telemetry.threshold | Telemetry value crossed a threshold |
Verifying Signatures
Every webhook request includes an X-Optra-Signature header — an HMAC-SHA256 digest of the raw request body signed with your secret. Always verify this before processing the payload:
const crypto = require('crypto');
function verifyWebhook(rawBody, signature, secret) {
const expected = crypto
.createHmac('sha256', secret)
.update(rawBody)
.digest('hex');
return crypto.timingSafeEqual(
Buffer.from(expected),
Buffer.from(signature)
);
}
Retry Policy
If your endpoint returns a non-2xx status code or times out, Optra retries with exponential backoff — up to 5 attempts over 24 hours. Respond with 200 OK as quickly as possible and process the payload asynchronously.