Skip to main content
The Webhooks API lets you register HTTP endpoints that receive real-time notifications when events occur in your PolyAI account. Webhooks are currently used by the Alerts API and will expand to other services in the future.

Key features

  • Signed delivery - Every webhook includes an HMAC-SHA256 signature you can verify
  • Automatic retries - Failed deliveries retry with exponential backoff
  • Secret rotation - Rotate signing secrets without recreating the endpoint

Limits

ResourceMaximum per account
Webhook endpoints10

Event types

EventDescription
alerts.triggeredAn alert rule transitioned into a firing state
alerts.resolvedA firing alert transitioned back to ok

Webhook headers

Each webhook request includes these headers:
HeaderDescription
X-PolyAI-TimestampUnix timestamp (seconds) when the webhook was sent
X-PolyAI-SignatureHMAC-SHA256 signature for verification
X-PolyAI-Event-IDUnique event identifier for deduplication

Retry policy

Failed webhook deliveries are retried with exponential backoff:
AttemptDelayCumulative time
1Immediate0
21 minute1 minute
35 minutes6 minutes
415 minutes21 minutes
51 hour~1.5 hours
64 hours~5.5 hours
Retried failures:
  • Timeout
  • Network error
  • HTTP 408, 429, 5xx
Not retried:
  • Other 4xx errors

Signature verification

Verify webhook signatures to ensure requests are from PolyAI. Algorithm: HMAC-SHA256 Signed message format: {timestamp}.{raw_request_body}
import hmac
import hashlib
import time

def verify_webhook(payload: bytes, timestamp: str, signature: str, secret: str) -> bool:
    # Reject requests older than 5 minutes
    if abs(time.time() - int(timestamp)) > 300:
        return False
    
    # Compute expected signature
    message = f"{timestamp}.{payload.decode('utf-8')}"
    expected = hmac.new(
        secret.encode('utf-8'),
        message.encode('utf-8'),
        hashlib.sha256
    ).hexdigest()
    
    # Constant-time comparison
    return hmac.compare_digest(expected, signature)
Use X-PolyAI-Event-ID for deduplication since retries can deliver the same event more than once.

Authentication

All Webhooks API endpoints use API key authentication via the x-api-key header. Resources are automatically scoped to your account.
API keys are not yet available through self-service. To request an API key, email developers@poly.ai.