Reference
Webhooks & Real-time
AxosilDesk receives Stripe webhooks for billing and pushes live data to clients over Server-Sent Events (SSE).
Stripe webhooks
The endpoint POST /api/webhooks/stripe (outside /api/v1) handles subscription lifecycle events. Requests are verified with the Stripe signature, not with an API session.
| Event | Action |
|---|---|
| checkout.session.completed | Creates the subscription, assigns the plan, updates the workspace |
| customer.subscription.updated | Updates subscription status, seat count and billing period |
| customer.subscription.deleted | Marks the subscription as cancelled |
| invoice.paid | Records the payment and updates the invoice status |
| invoice.payment_failed | Sets the subscription status from Stripe (usually past due); suspension only follows subscription updates |
Configuring Stripe
- In the Stripe Dashboard open Developers → Webhooks.
- Add the endpoint
https://<your-axosildesk-host>/api/webhooks/stripe. - Select
checkout.session.completed,customer.subscription.*andinvoice.*. - Copy the signing secret into the
STRIPE_WEBHOOK_SECRETenvironment variable.
Server-Sent Events (SSE)
Three authenticated GET endpoints keep a connection open and push a JSON snapshot on a fixed interval. They accept the browser session cookie or a Bearer token. Data is scoped to what the caller may see: admins the whole workspace, managers their team, everyone else their own data.
| Endpoint | Event name | Interval |
|---|---|---|
| /api/v1/realtime/dashboard | dashboard | 30 s |
| /api/v1/realtime/activity | activity | 15 s |
| /api/v1/realtime/notifications | message (default) | 15 s |
Dashboard metrics stream
SSE
GET /api/v1/realtime/dashboard
Accept: text/event-stream
event: dashboard
data: {"activeAgents":12,"productivityScore":78,"hoursTracked":"45.2","tasksCompleted":23,
"unreadNotifications":5,"productiveSec":28800,"neutralSec":7200,"unproductiveSec":3600,
"timestamp":"2026-01-15T09:00:00.000Z"}Activity stream
Activity from the last 10 minutes (at most 20 records) and agents seen in the last 5 minutes.
SSE
GET /api/v1/realtime/activity
Accept: text/event-stream
event: activity
data: {
"recentActivities": [
{ "id": "…", "userId": "…", "type": "app_usage", "appName": "VS Code",
"windowTitle": "index.ts — project", "url": null, "category": "productive",
"durationSeconds": 300, "startedAt": "…", "userName": "Jane Doe", "userEmail": "…" }
],
"onlineAgents": [
{ "id": "…", "userId": "…", "machineName": "WORK-PC-01", "status": "online",
"lastHeartbeat": "…", "userName": "Jane Doe", "userEmail": "…" }
],
"timestamp": "2026-01-15T09:00:00.000Z"
}Notification stream
The caller's unread count and five most recent notifications.
SSE
GET /api/v1/realtime/notifications
Accept: text/event-stream
data: {
"unreadCount": 3,
"notifications": [
{ "id": "…", "type": "timesheet_approved", "title": "Timesheet approved",
"body": "Your timesheet for Jan 13-17 was approved", "isRead": false,
"actionUrl": "…", "createdAt": "2026-01-17T14:30:00.000Z" }
]
}Client-side usage (React)
TypeScript
import { useEffect, useState } from 'react';
// Same-origin browser code: the session cookie is sent automatically.
// EventSource cannot set headers; outside the browser use an SSE client
// that can send "Authorization: Bearer <token>".
function useSSE<T>(url: string, eventName = 'message') {
const [data, setData] = useState<T | null>(null);
const [connected, setConnected] = useState(false);
useEffect(() => {
const es = new EventSource(url);
const onData = (e: MessageEvent<string>) => setData(JSON.parse(e.data) as T);
es.onopen = () => setConnected(true);
// When the server ends the stream (event "close", e.g. after 1 hour) EventSource
// reconnects on its own; it stops only after a non-200 answer such as 401.
es.onerror = () => setConnected(false);
es.addEventListener(eventName, onData);
return () => es.close();
}, [url, eventName]);
return { data, connected };
}
// const { data } = useSSE<DashboardMetrics>('/api/v1/realtime/dashboard', 'dashboard');Connection limits
- Each user may hold at most 5 open streams per server; more answer
429 TOO_MANY_STREAMSwithRetry-After: 30. - A stream ends after one hour, and after repeated server errors; both send
event: closefirst.EventSourcereconnects automatically. - It also closes when the user is deactivated, changes role or password, or the workspace is suspended; the reconnect then fails with
401or403.
Security
- Stripe webhooks are verified with
stripe.webhooks.constructEvent()and the signing secret. - SSE streams authenticate on connect and re-check the caller's access every 5 minutes.