Server-Sent Events (SSE)
Stream real-time updates for admin dashboards.
Endpoint
GET /wp-json/wc-appointments/v2/sse
- Auth: Logged-in user with
X-WP-Nonce. - Resume:
since_idquery orLast-Event-IDheader. - Behavior: Streams up to 50 events, then ends.
Example
curl -H "X-WP-Nonce: YOUR_NONCE" \
"https://example.com/wp-json/wc-appointments/v2/sse?since_id=100"
Payload
{
"topic": "appointment.updated",
"resource": "appointment",
"resource_id": 123,
"payload": { "…": "minimal fields" },
"ts": 1730900000
}
Implementation
- Route:
includes/api/v2/class-wc-appointments-rest-v2-sse-controller.php - Events:
includes/class-wc-appointments-sse.php - Client:
EventSourcewith nonce header for admin pages.