# Status page: service-status-sdk -> same-origin /api/status -> Pages Function # -> private Service Binding -> service-status-monitor. // functions/api/status.js import { createStatusPagesHandler } from "service-status-sdk/cloudflare-pages"; export const onRequest = createStatusPagesHandler({ product: "dictum", // Replace with a product ID supported by the monitor. bindingName: "SERVICE_STATUS_MONITOR", }); // In the Pages project's wrangler.jsonc: "services": [ { "binding": "SERVICE_STATUS_MONITOR", "service": "service-status-monitor" } ] // In the product's own Status page: import { getAggregateServiceStatus } from "service-status-sdk"; let status = "unknown"; try { const response = await fetch("/api/status", { headers: { "X-Request-Id": crypto.randomUUID() }, }); if (response.ok) status = getAggregateServiceStatus(await response.json()); } catch { // Keep the unavailable state. } // Render the product's own UI. Never display "unknown" as healthy. # Successful monitor responses are cached for 60 seconds; failures are not. # Error format from /api/status: { ok: false, rid: string | null, # error: { code: string, message: string, category: "internal", retryable: boolean } }. # Example HTTP 502 with X-Request-Id: status-example-1: # {"ok":false,"rid":"status-example-1","error":{"code":"service_binding_failed","message":"The status monitor is unavailable.","category":"internal","retryable":true}} # Local code/status pairs: METHOD_NOT_ALLOWED/405, invalid_product/400, # QUERY_NOT_ALLOWED/400, request_body_forbidden/400, request_id_required/500, # service_binding_unavailable/500, service_binding_failed/502. # Every failure sends Cache-Control: no-store; X-Request-Id appears when rid is a string. # The monitor is private; its own response is validated before a successful status reaches the site. # Full contract: https://github.com/a44238587-sudo/service-status-sdk/blob/main/README.md