CoinfiraEnergy API
API v1 API Reference

Webhooks

Coinfira sends terminal order events to the merchant-level HTTPS webhook URL configured in the dashboard.

#Events

Event Meaning
energy.order.active Delegation succeeded and billing was finalized.
energy.order.failed Activation or delegation failed without a charge.
energy.webhook.test Dashboard test delivery; not associated with an order.

Only API-created orders produce these events. Dashboard purchases do not send API webhooks merely because the merchant has configured a webhook URL.

#Headers

Content-Type: application/json
X-CF-API-Key: api-key-that-created-the-order
X-CF-Webhook-Id: 3d371ca4-1dce-4cb4-a5de-bb0580348730
X-CF-Timestamp: 2026-10-14T12:00:20.000Z
X-CF-Signature: base64-hmac-sha256-signature

The X-CF-API-Key selects the secret. This is unambiguous when a merchant has multiple active keys. Coinfira retains encrypted secrets for disabled keys so a pending order created before rotation can still deliver its webhook.

#Verify the signature

Read the request as raw bytes before JSON parsing. Build:

timestamp + "\n" + webhookId + "\n" + rawBody

Then calculate:

expected = Base64(HMAC-SHA256(apiSecret, canonicalWebhook))

Compare signatures with a constant-time function. Reject an invalid signature before using any payload field.

Node.js example:

const crypto = require('crypto');

function verifyWebhook({ secret, timestamp, webhookId, rawBody, signature }) {
  const prefix = Buffer.from(`${timestamp}\n${webhookId}\n`, 'utf8');
  const expected = crypto
    .createHmac('sha256', secret)
    .update(Buffer.concat([prefix, rawBody]))
    .digest();
  const supplied = Buffer.from(signature, 'base64');
  return supplied.length === expected.length
    && crypto.timingSafeEqual(supplied, expected);
}

#Acknowledge and deduplicate

Return any 2xx status after durable processing. Keep the handler fast; queue long-running business work before acknowledging the event.

Webhook delivery is at least once. Store event_id with a unique constraint. If the same ID arrives again, return 2xx without repeating business actions. The event_id and body remain stable across retries, while timestamp and signature are generated for each attempt.

#Retry schedule

Coinfira makes up to six delivery attempts. After a failed attempt, retries are scheduled after approximately:

10 seconds, 1 minute, 5 minutes, 30 minutes, 2 hours

A timeout, network failure, redirect, or non-2xx response triggers a retry. Redirects are not followed.

#URL requirements

  • HTTPS is required.
  • Embedded username/password and URL fragments are rejected.
  • The hostname must resolve only to public IP addresses.
  • Private, loopback, link-local, and internal destinations are rejected.
  • Configure one merchant-level URL in the Coinfira dashboard.
  • Use the dashboard test action after saving or changing the URL.