The micro-VM for AI agents — light enough to embed on your laptop, elastic enough to power an agentic cloud.
Webhook Service
This service provides webhook functionality using Svix as the webhook delivery provider. It automatically creates Svix applications for new organizations and sends webhooks for various events.
Configuration
Set the following environment variables:
# Required: Your Svix authentication token
SVIX_AUTH_TOKEN=your_svix_auth_token_here
# Optional: Custom Svix server URL (for self-hosted instances)
SVIX_SERVER_URL=https://your-svix-instance.com
API Endpoints
Get App Portal Access
POST /api/webhooks/organizations/{organizationId}/app-portal-access
Response:
{
"url": "https://app.svix.com/consumer/..."
}
Returns a URL that provides access to the Svix Consumer App Portal for managing webhook endpoints, viewing delivery attempts, and monitoring webhook performance.
Send Custom Webhook
POST /api/webhooks/organizations/{organizationId}/send
Request Body:
{
"eventType": "custom.event",
"payload": {
"message": "Hello from BoxLite!",
"timestamp": "2025-01-01T00:00:00.000Z"
},
"eventId": "optional-unique-id"
}
Sends a custom webhook message to all configured endpoints for the specified organization.
Get Message Delivery Attempts
GET /api/webhooks/organizations/{organizationId}/messages/{messageId}/attempts
Response:
[
{
"id": "msg_attempt_123",
"status": 200,
"response": "OK",
"timestamp": "2025-01-01T00:00:00.000Z"
}
]
Returns the delivery attempts for a specific webhook message, including delivery status and response details.
Get Service Status
GET /api/webhooks/status
Response:
{
"enabled": true
}
Returns the current status of the webhook service, indicating whether it's properly configured and enabled.
Automatic Events
The service automatically sends webhooks for the following events:
Box Events
box.created- When a box is createdbox.state.updated- When box state changes
Snapshot Events
snapshot.created- When a snapshot is createdsnapshot.state.updated- When snapshot state changessnapshot.removed- When a snapshot is removed
Volume Events
volume.created- When a volume is createdvolume.state.updated- When volume state changes
Webhook Payload Format
All webhooks include event-specific data relevant to the resource being updated.
Example Box Created Payload
{
"id": "box-uuid",
"organizationId": "org-uuid",
"state": "STARTED",
"class": "SMALL",
"createdAt": "2025-01-01T00:00:00.000Z"
}
Example Box State Updated Payload
{
"id": "box-uuid",
"organizationId": "org-uuid",
"oldState": "STOPPED",
"newState": "STARTED",
"updatedAt": "2025-01-01T00:00:00.000Z"
}
Example Snapshot Created Payload
{
"id": "snapshot-uuid",
"name": "my-snapshot",
"organizationId": "org-uuid",
"state": "ACTIVE",
"createdAt": "2025-01-01T00:00:00.000Z"
}
Example Volume State Updated Payload
{
"id": "volume-uuid",
"name": "my-volume",
"organizationId": "org-uuid",
"oldState": "CREATING",
"newState": "READY",
"updatedAt": "2025-01-01T00:00:00.000Z"
}
Development
Adding New Event Types
- Add the event type to
webhook-events.constants.ts - Create an event handler in
webhook-event-handler.service.ts - Use the
@OnEvent()decorator to listen for the event - Define the payload structure for the new event type
- Add the events to the
openapi-webhooks.ts - Generate the openapi spec
- Upload the new schema to the Svix dashboard
Testing
Use the Svix Play webhook debugger during development:
- Set up a webhook endpoint pointing to your Svix Play URL
- Send test webhooks using the
/sendendpoint - Check the Svix dashboard for delivery status
- Monitor delivery attempts through the API
Local Development
For local development without Svix:
- Set
SVIX_AUTH_TOKENto an empty string or invalid value - The service will log warnings but continue to function
- Event handlers will skip webhook delivery when disabled
- Use the status endpoint to verify configuration
Dependencies
svix- Official Svix JavaScript SDK@nestjs/event-emitter- Event handling@nestjs/common- Core NestJS functionality
Event Flow
- System event occurs (e.g., box created)
- Event emitter publishes the event
- Webhook event handler catches the event
- Handler calls webhook service to send webhook
- Service delivers webhook through Svix
- Delivery status is tracked and available via API