Webhook Types
This page documents the webhook interfaces used for communication between MentraOS Cloud and App servers. Webhooks are HTTP requests sent from MentraOS Cloud to your App server to manage the lifecycle of App sessions.BaseWebhookRequest
The base structure for all webhook requests sent to App servers.SessionWebhookRequest
Webhook sent to initiate a new App session. Handled byAppServer.onSession
.
AppServer.onSession
method is called with a new AppSession
instance, the sessionId
, and the userId
.
StopWebhookRequest
Webhook sent to request stopping a App session. Handled byAppServer.onStop
.
AppServer.onStop
method is called with the sessionId
, userId
, and reason
.
ServerRegistrationWebhookRequest
Webhook confirming successful registration of the App server with MentraOS Cloud.SessionRecoveryWebhookRequest
Webhook sent when the cloud attempts to recover a potentially disconnected session.ServerHeartbeatWebhookRequest
Webhook sent periodically to check App server health. Requires a success response.WebhookResponse
Standard response structure App servers should return for webhook requests.Type Guards
The SDK provides utility functions to check the type of webhook request:Webhook Flow
- Registration: When your
AppServer
starts, it is registered with MentraOS Cloud. - Server Registration Confirmation: MentraOS Cloud sends a
SERVER_REGISTRATION
webhook to confirm registration. - Heartbeat: MentraOS Cloud periodically sends
SERVER_HEARTBEAT
webhooks to check if your server is still running. - Session Initialization: When a user starts your App, MentraOS Cloud sends a
SESSION_REQUEST
webhook. - Session Termination: When a user stops your App or there’s a system issue, a
STOP_REQUEST
webhook is sent. - Session Recovery: If MentraOS Cloud restarts or detects a potential disconnection, it may send a
SESSION_RECOVERY
webhook.