Skip to content

Integrations API

POST /api/events/ingest

Webhook ingestion endpoint for AgentGate, FormBridge, and generic third-party sources. Events are mapped to AgentLens event types and persisted.

Request Body

json
{
  "source": "agentgate",
  "event": "request.approved",
  "data": {
    "requestId": "req_123",
    "action": "send_email",
    "decidedBy": "admin@company.com",
    "reason": "Approved for known recipient"
  },
  "timestamp": "2026-02-08T10:00:00.000Z",
  "context": {
    "agentlens_session_id": "sess_01HXYZ",
    "agentlens_agent_id": "my-agent"
  }
}
FieldTypeRequiredDescription
sourcestringagentgate, formbridge, or generic
eventstringSource-specific event name
dataobjectEvent payload
timestampstringISO 8601 timestamp (default: server time)
contextobjectCorrelation context for session linking
context.agentlens_session_idstringLink to an existing session
context.agentlens_agent_idstringAgent identifier

Signature Verification

For agentgate and formbridge sources, the request must include an HMAC-SHA256 signature:

X-Webhook-Signature: <hmac-sha256-hex-of-raw-body>

Generic webhooks don't require signatures.

AgentGate Events

Webhook EventMaps ToPayload
request.createdapproval_requestedrequestId, action, params, urgency
request.approvedapproval_grantedrequestId, action, decidedBy, reason?
request.deniedapproval_deniedrequestId, action, decidedBy, reason?
request.expiredapproval_expiredrequestId, action, decidedBy, reason?

FormBridge Events

Webhook EventMaps ToPayload
submission.createdform_submittedsubmissionId, formId, formName?, fieldCount
submission.completedform_completedsubmissionId, formId, completedBy, durationMs
submission.expiredform_expiredsubmissionId, formId, expiredAfterMs

Generic Events

For the generic source, the data object should include:

json
{
  "eventType": "custom",
  "type": "my-event-type",
  "data": { "key": "value" }
}

Response (201)

json
{
  "ok": true,
  "eventId": "01HXYZ...",
  "eventType": "approval_granted",
  "sessionId": "sess_01HXYZ"
}

Errors

StatusCause
400Invalid JSON, missing source, missing event, unknown event type
401Invalid webhook signature
500Webhook secret not configured for source

curl Examples

AgentGate webhook:

bash
# Compute signature
BODY='{"source":"agentgate","event":"request.approved","data":{"requestId":"req_123","action":"send_email","decidedBy":"admin"}}'
SIG=$(echo -n "$BODY" | openssl dgst -sha256 -hmac "your-secret" | awk '{print $2}')

curl -X POST http://localhost:3400/api/events/ingest \
  -H "Content-Type: application/json" \
  -H "X-Webhook-Signature: $SIG" \
  -d "$BODY"

Generic webhook (no signature required):

bash
curl -X POST http://localhost:3400/api/events/ingest \
  -H "Content-Type: application/json" \
  -d '{
    "source": "generic",
    "event": "custom",
    "data": {
      "eventType": "custom",
      "type": "deployment",
      "data": { "version": "2.0.0" }
    },
    "context": {
      "agentlens_session_id": "sess_01HXYZ",
      "agentlens_agent_id": "deploy-bot"
    }
  }'

Released under the MIT License.