Webhooks

Webhooks notify your systems when important events happen — key errors, earnings, payouts, and rotation updates. Configure endpoints in the dashboard under Settings → Webhooks.

Available events

EventTriggerTiming
key.errorA request routed through your key returned an error from the upstream providerImmediate
key.degradedYour key's priority score dropped below 0.3Immediate
key.inactiveYour key was revoked or its request budget was exhaustedImmediate
key.liveness_failedA scheduled liveness re-check failedImmediate
key.rotation_startedA key rotation overlap window beganImmediate
key.rotation_completeA key rotation finished and the new key was promotedImmediate
payout.createdA payout was queued for processingImmediate
payout.completedA payout was confirmed by the payment providerImmediate
payout.failedA payout attempt failedImmediate
earning.batch_creditedNew earnings accumulatedEvery 5 min

The earning.batch_credited event is batched every 5 minutes to avoid overwhelming your endpoint with per-request events. It includes a summary of earnings grouped by provider.

Payload format

Every webhook delivery is a POST request with a JSON body:

{
  "id": "del_abc123",
  "event": "key.error",
  "timestamp": "2025-03-20T14:32:00Z",
  "sellerId": "sel_xyz",
  "data": {
    // event-specific fields
  }
}

Verifying signatures

Every webhook includes an X-CN2-Signature header containing an HMAC-SHA256 signature of the raw request body, computed with your endpoint's secret.

X-CN2-Signature: sha256=a1b2c3...

To verify: compute HMAC-SHA256 of the raw body using your endpoint secret, then compare with the header value. Reject requests where the signature does not match.

Retries

If your endpoint returns a non-2xx status, cn2.ai retries with exponential backoff:

  1. Immediately
  2. After 1 minute
  3. After 5 minutes
  4. After 30 minutes
  5. After 2 hours (final attempt)

If your endpoint has been failing continuously for more than 1 hour, you receive an email notification. Webhooks are never auto-disabled — you manage delivery status in the dashboard.