apps/api/src/webhook/README.md
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.
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
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.
POST /api/webhooks/organizations/{organizationId}/send
Request Body:
{
"eventType": "custom.event",
"payload": {
"message": "Hello from Daytona!",
"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 /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 /api/webhooks/status
Response:
{
"enabled": true
}
Returns the current status of the webhook service, indicating whether it's properly configured and enabled.
The service automatically sends webhooks for the following events:
sandbox.created - When a sandbox is createdsandbox.state.updated - When sandbox state changessnapshot.created - When a snapshot is createdsnapshot.state.updated - When snapshot state changessnapshot.removed - When a snapshot is removedvolume.created - When a volume is createdvolume.state.updated - When volume state changesAll webhooks include event-specific data relevant to the resource being updated.
{
"id": "sandbox-uuid",
"organizationId": "org-uuid",
"state": "STARTED",
"class": "SMALL",
"createdAt": "2025-01-01T00:00:00.000Z"
}
{
"id": "sandbox-uuid",
"organizationId": "org-uuid",
"oldState": "STOPPED",
"newState": "STARTED",
"updatedAt": "2025-01-01T00:00:00.000Z"
}
{
"id": "snapshot-uuid",
"name": "my-snapshot",
"organizationId": "org-uuid",
"state": "ACTIVE",
"createdAt": "2025-01-01T00:00:00.000Z"
}
{
"id": "volume-uuid",
"name": "my-volume",
"organizationId": "org-uuid",
"oldState": "CREATING",
"newState": "READY",
"updatedAt": "2025-01-01T00:00:00.000Z"
}
webhook-events.constants.tswebhook-event-handler.service.ts@OnEvent() decorator to listen for the eventopenapi-webhooks.tsUse the Svix Play webhook debugger during development:
/send endpointFor local development without Svix:
SVIX_AUTH_TOKEN to an empty string or invalid valuesvix - Official Svix JavaScript SDK@nestjs/event-emitter - Event handling@nestjs/common - Core NestJS functionality