Webhooks API

POST /api/webhooks

Create a webhook.

Auth: Admin

Request:

curl -X POST http://localhost:8080/api/webhooks \
  -H "Content-Type: application/json" \
  -u admin@example.com:changeme \
  -d '{
    "name": "Prod Notifications",
    "url": "https://yourapp.com/webhooks",
    "events": ["agent.created", "agent.deleted"],
    "max_retries": 5
  }'

Response (201):

{
  "webhook": {
    "id": "webhook_123",
    "name": "Prod Notifications",
    "url": "https://yourapp.com/webhooks",
    "events": ["agent.created", "agent.deleted"],
    "is_active": true,
    "max_retries": 5
  },
  "secret": "whsec_abc123..."
}

GET /api/webhooks

List all webhooks.

Auth: Admin

Response (200):

{
  "webhooks": [
    {
      "id": "webhook_123",
      "name": "Prod Notifications",
      "url": "https://yourapp.com/webhooks",
      "events": ["agent.created", "agent.deleted"],
      "is_active": true,
      "consecutive_fails": 0
    }
  ]
}

GET /api/webhooks/:id

Get a webhook.

Auth: Admin

Response (200):

{
  "webhook": {
    "id": "webhook_123",
    "name": "Prod Notifications",
    "url": "https://yourapp.com/webhooks",
    "events": ["agent.created", "agent.deleted"],
    "is_active": true,
    "max_retries": 5,
    "created_at": "2026-03-01T12:00:00Z"
  }
}

PUT /api/webhooks/:id

Update a webhook.

Auth: Admin

Request:

{
  "name": "Updated Name",
  "is_active": false,
  "max_retries": 3
}

DELETE /api/webhooks/:id

Delete a webhook.

Auth: Admin

Response: 204 No Content


POST /api/webhooks/:id/test

Test a webhook.

Auth: Admin

Request:

curl -X POST http://localhost:8080/api/webhooks/webhook_123/test \
  -H "Content-Type: application/json" \
  -u admin@example.com:changeme \
  -d '{"event": "webhook.test"}'

Response (200):

{
  "success": true,
  "status_code": 200
}

GET /api/webhooks/:id/deliveries

Get delivery history.

Auth: Admin

Response (200):

{
  "deliveries": [
    {
      "id": "delivery_123",
      "event": "agent.created",
      "status": "delivered",
      "attempts": 1,
      "last_attempt_at": "2026-03-01T12:00:01Z"
    }
  ]
}

GET /api/webhook-events

List available event types.

Auth: Admin

Response (200):

{
  "events": [
    "agent.created",
    "agent.deleted",
    "agent.updated",
    "agent.credentials_rotated",
    "token.issued",
    "token.validation_success",
    "token.validation_failed",
    "webhook.created",
    "webhook.updated",
    "webhook.deleted",
    "webhook.test"
  ]
}