Endpoint API
The Endpoint API manages webhooks, callbacks, and event routing for external integrations and notifications.Overview
Service Name: endpoint-apiPort: 9005
Technology: Go + Gin Framework
Language: Go 1.25+
Primary Database: PostgreSQL (endpoint_db)
Purpose
The Endpoint API handles:- Webhook configuration and management
- Webhook event delivery
- Callback handling for external events
- Event routing and filtering
- Retry logic with exponential backoff
- Webhook signature verification
- Event history and replay
- Rate limiting and throttling
Key Features
Webhook Management
- Create and manage multiple webhooks
- Event type filtering
- Webhook versioning
- Webhook testing and validation
- Webhook signing for security
Event Delivery
- Reliable delivery with retries
- Exponential backoff strategy
- Event batching (optional)
- Timeout handling
- Delivery status tracking
Event Types
| Event | Trigger | Payload |
|---|---|---|
conversation.started | New conversation initiated | |
conversation.ended | Conversation completed | |
message.sent | Assistant sends message | |
message.received | User sends message | |
assistant.updated | Assistant config changed | |
assistant.deleted | Assistant removed | |
error.occurred | Error in conversation |
Architecture
API Endpoints
Database Schema
Webhooks TableConfiguration
Environment Variables
Source Code Structure
Webhook Management
Create Webhook
Test Webhook
Webhook Signature Verification
All webhooks are signed for security. Verify the signature:Signature Header
Verification Code
Webhook Event Format
Example Event
Retry Strategy
Exponential Backoff
Conditions for Retry
- Status code 408, 429, 500-599 (server errors)
- Connection timeout
- Network unreachable
- TLS handshake failure
Non-Retriable Errors
- Status code 4xx (client errors) except 408, 429
- Invalid URL
- Webhook deleted
- Max retries exceeded
Delivery History
View Delivery Status
Replay Events
Replay Failed Delivery
Rate Limiting
Per-Webhook Rate Limiting
Webhooks are rate-limited to prevent overwhelming external services:Batching (Optional)
For high-volume webhooks, batch events:Monitoring
Health Checks
Metrics Tracked
- Webhook delivery success rate
- Average delivery latency
- Retry frequency
- Failed deliveries count
- Queue depth
Logging
All webhook deliveries are logged:Building and Running
From Source
With Docker
Security Considerations
Webhook URL Validation
- Must be HTTPS in production
- Cannot be internal IP addresses (127.0.0.1, 10.x.x.x)
- DNS resolution verified
- Certificate validation enabled
Rate Limiting
- Per-webhook limits
- Per-IP limits
- Configurable quotas
Signature Verification
- All events signed with HMAC-SHA256
- Timestamp included in signature (prevent replay)
- Public key rotation support
Troubleshooting
Webhook Not Receiving Events
- Check webhook is active:
GET /api/v1/endpoint/webhooks/{id} - Check event filtering: ensure events are subscribed
- View delivery history:
GET /api/v1/endpoint/webhooks/{id}/deliveries - Test webhook:
POST /api/v1/endpoint/webhooks/{id}/test