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

  1. Go to Settings → Webhooks in the Optra platform.
  2. Click Add Webhook and enter your endpoint URL.
  3. Select the event types you want to subscribe to.
  4. Copy the signing secret — use it to verify incoming payloads.

Event Types

Event Description
device.connectedDevice came online
device.disconnectedDevice went offline
device.registeredNew device registered
rule.triggeredA rule condition was met
telemetry.thresholdTelemetry 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.