Webhooks
Webhooks let CloudInfraOS push real-time event notifications to your own HTTP endpoints. Use them to integrate with Slack, Discord, CI/CD pipelines, or custom automation.
Webhook Endpoints
Webhook endpoints are configured per organization. Each endpoint subscribes to one or more event types and receives a POST request when those events occur.
Create a Webhook Endpoint
POST /api/webhooks{
"url": "https://hooks.example.com/stackpilot",
"events": ["resource.created", "alert.triggered", "cost.threshold_exceeded"],
"secret": "your_webhook_signing_secret"
}Available Event Types
resource.createdβ a new resource was discovered during syncresource.deletedβ a previously synced resource no longer existsresource.updatedβ a resource configuration changedalert.triggeredβ an alert rule condition was metalert.resolvedβ a triggered alert returned to normalcost.threshold_exceededβ spend exceeded a configured thresholdsync.completedβ a provider sync finishedsync.failedβ a provider sync encountered an error
Webhook Delivery
Each webhook is delivered as an HTTP POST with a JSON body and an X-StackPilot-Signature header for payload verification. CloudInfraOS retries failed deliveries up to 3 times with exponential backoff.
Verifying Payloads
Use the signing secret to verify that incoming webhooks originated from CloudInfraOS. Compute an HMAC-SHA256 of the raw request body and compare it to the signature header:
const crypto = require('crypto')
function verifySignature(payload, signature, secret) {
const expected = crypto
.createHmac('sha256', secret)
.update(payload)
.digest('hex')
return crypto.timingSafeEqual(
Buffer.from(signature),
Buffer.from(expected)
)
}Managing Endpoints
GET /api/webhooksβ list all webhook endpointsGET /api/webhooks/:idβ get endpoint details and delivery historyPATCH /api/webhooks/:idβ update endpoint URL, events, or secretDELETE /api/webhooks/:idβ delete an endpoint