Webhooks

Real-time notifications for test events

Overview

Webhooks allow you to receive real-time notifications when specific events occur in your AIToTest environment. This enables you to build automated workflows and integrate with other systems.

Event Types

Test Events

  • test.started
  • test.completed
  • test.failed
  • test.coverage.updated

Project Events

  • project.created
  • project.updated
  • project.deleted
  • project.imported

Webhook Format

Example Payload

{
  "id": "evt_123",
  "type": "test.completed",
  "created": "2025-02-24T16:37:20Z",
  "data": {
    "testId": "test_456",
    "projectId": "proj_789",
    "status": "success",
    "duration": 1234,
    "results": {
      "total": 10,
      "passed": 9,
      "failed": 1,
      "coverage": {
        "lines": 85,
        "functions": 90,
        "branches": 75
      }
    }
  }
}

Security

Webhook Signatures

Each webhook request includes a signature header for verification:

// Node.js example
const crypto = require('crypto');

const signature = req.headers['x-aitotest-signature'];
const timestamp = req.headers['x-aitotest-timestamp'];
const body = req.rawBody;

const expectedSignature = crypto
  .createHmac('sha256', webhookSecret)
  .update(`${timestamp}.${body}`)
  .digest('hex');

if (signature === expectedSignature) {
  // Webhook is valid
}

Configuration

Create Webhook

POST /v1/webhooks

{
  "url": "https://api.example.com/webhook",
  "events": ["test.*", "project.updated"],
  "description": "Test notification endpoint"
}

Update Webhook

PUT /v1/webhooks/{webhookId}

{
  "events": ["test.completed"],
  "active": true
}

Best Practices

Reliability

  • Implement retry logic
  • Use timeouts
  • Handle failures gracefully
  • Monitor webhook health

Security

  • Validate signatures
  • Use HTTPS endpoints
  • Rotate webhook secrets
  • Limit IP ranges

Performance

  • Process async
  • Quick response times
  • Batch processing
  • Scale horizontally

Debugging

Webhook Logs

GET /v1/webhooks/{webhookId}/deliveries

Response:
{
  "deliveries": [{
    "id": "dlv_123",
    "event": "test.completed",
    "url": "https://...",
    "status": 200,
    "duration": 123,
    "created": "2025-02-24T16:37:20Z"
  }]
}