Skip to main content

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 by AppServer.onSession.
Example:
When this webhook is received, your 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 by AppServer.onStop.
Example:
When this webhook is received, your AppServer.onStop method is called with the sessionId, userId, and reason.

ServerRegistrationWebhookRequest

Webhook confirming successful registration of the App server with MentraOS Cloud.
Example:

SessionRecoveryWebhookRequest

Webhook sent when the cloud attempts to recover a potentially disconnected session.
Example:

ServerHeartbeatWebhookRequest

Webhook sent periodically to check App server health. Requires a success response.
Example:

WebhookResponse

Standard response structure App servers should return for webhook requests.
Example Success Response:
Example Error Response:

Type Guards

The SDK provides utility functions to check the type of webhook request:
Example (For Manual Webhook Processing):

Webhook Flow

  1. Registration: When your AppServer starts, it is registered with MentraOS Cloud.
  2. Server Registration Confirmation: MentraOS Cloud sends a SERVER_REGISTRATION webhook to confirm registration.
  3. Heartbeat: MentraOS Cloud periodically sends SERVER_HEARTBEAT webhooks to check if your server is still running.
  4. Session Initialization: When a user starts your App, MentraOS Cloud sends a SESSION_REQUEST webhook.
  5. Session Termination: When a user stops your App or there’s a system issue, a STOP_REQUEST webhook is sent.
  6. Session Recovery: If MentraOS Cloud restarts or detects a potential disconnection, it may send a SESSION_RECOVERY webhook.