D-12 Webhook Gateway
Brick D: Tools, skills, plugins, MCP, connectors. French version: D-12-webhook-gateway
1. Role and responsibilities
Receives inbound webhooks from third party systems, verifies the HMAC signature and publishes to NATS.
- Verify X-EAI-Signature (HMAC-SHA256) and the replay window
- Publish the event (fires C-10)
- Log deliveries
2. Position in the architecture and interactions
- Callers: External systems.
- Execution path: Synchronous (fast ack) then event driven.
- Every interaction goes through the Control Plane API v1 (
/v1) behind the API Gateway (D-14).
3. Open source component and developed part
- Open source: FastAPI, NATS
- Developed: Verification, normalization, log.
- External integration through an adapter
eai/integrations/<system>.pywith an in-process fallback when the URL is not configured.
4. Data model
Tables (schema eai, tenant_id RLS):
eai.webhook_deliveries
Common columns: id uuid, tenant_id uuid NOT NULL, created_at, updated_at; RLS policy current_setting('app.tenant_id', true)::uuid.
5. Contract
- Applied contract: connector-manifest
- JSON Schema:
contracts/v1/connector-manifest.schema.json - Key fields:
spec.webhooks - Validation:
POST /v1/contracts/{name}/validate; manifest apply:POST /v1/manifests/apply.
6. API endpoints
POST /v1/webhooks/{connector}GET /v1/webhooks/deliveries
Request POST /v1/webhooks/{connector}:
{
"event": "case.created",
"id": "evt_123",
"data": {
"case": "00012"
}
}
Response:
{
"delivery_id": "whd_501",
"status": "accepted"
}
7. SDK examples
Python:
from enterprise_ai import EnterpriseAI
client = EnterpriseAI(base_url="<control-plane-url>", api_key="eai_xxx_secret")
deliveries = client.connectors.webhook_deliveries(limit=50)
TypeScript:
import { EnterpriseAI } from "@enterprise-ai/sdk";
const client = new EnterpriseAI({ baseUrl: "<control-plane-url>", apiKey: process.env.EAI_API_KEY });
const deliveries = await client.webhooks.deliveries({ limit: 50 });
Java:
EnterpriseAIClient client = EnterpriseAIClient.builder()
.baseUrl("<control-plane-url>")
.apiKey(System.getenv("EAI_API_KEY"))
.build();
client.webhooks().deliveries(50);
Go:
c, _ := eai.NewClient(eai.WithBaseURL("<control-plane-url>"), eai.WithAPIKey(os.Getenv("EAI_API_KEY")))
c.Webhooks.Deliveries(ctx, 50)
8. Configuration
- Environment variables:
EAI_NATS_URL,EAI_DATABASE_URL - Helm values keys:
nats.enabled
9. Security controls
- Invalid signature -> 401
- Body size limited
- Every request carries the tenant resolved from the credential; PostgreSQL RLS
- Every mutation and policy decision writes a hash-chained audit event
10. Observability
- Prometheus metrics:
eai_webhook_deliveries_total{status} - Traces: OpenTelemetry spans with GenAI semantic conventions (
gen_ai.operation.name,gen_ai.agent.id,gen_ai.tool.name), attributeseai.tenant_id,eai.run_id,traceparentpropagation. - Audit actions:
webhook.receive
11. FinOps units
- Received deliveries.
- Emitted as Usage Event (
POST /v1/finops/usage) with tenant, project, agent and run.
12. Failure modes and resilience
- Deduplication by event id
- Outbox before NATS publication
- Normalized errors (error envelope, message_i18n en/fr)
13. Standalone adoption (client of a client)
- Control Plane + NATS; no SDK needed on the sender side.
- SDK:
enterprise_ai.tools / mcp / skills / plugins / connectors / channels - Minimal deployment: Helm chart with
controlPlane.enabled=trueand PostgreSQL; disabled external components use their in-process fallback.
14. Acceptance tests
- Timestamp outside window -> 401
- Duplicate -> a single delivery
- Cross-tenant access refused
- Error returned in fr with Accept-Language: fr