How It Works
Lifecycle Stages
1. Registration (One-Time Setup)
Register your app in the Developer Console:- Package Name: Unique identifier (e.g.,
com.example.myapp) - Webhook URL: Where MentraOS sends session requests
- API Key: Secret for authentication
- Permissions: What device data your app needs
2. Session Start
When a user starts your app:- MentraOS Cloud sends HTTP POST to your webhook URL
- Webhook includes
sessionIdanduserId - Your server establishes WebSocket connection
- Your server sends connection init message
- Cloud confirms connection
3. Active Session
While the session is active:- Subscribe to events (transcription, button presses, etc.)
- Handle incoming events with callbacks
- Update the display using layouts
- Access device capabilities
4. Session End
Session ends when:- User stops the app
- Glasses disconnect
- Network error occurs
- Your server disconnects
Key Components
| Component | Purpose |
|---|---|
| AppServer | Your server class that handles webhooks and connections |
| AppSession | Represents one user’s active connection to your app |
| WebSocket | Real-time bidirectional communication channel |
| Events | Data streams from glasses (voice, sensors, buttons) |
| Layouts | What displays on the glasses screen |
Important Notes
Sessions are isolated per user. Each user who starts your app gets their own
AppSession instance with a unique userId.Next Steps
Learn About AppServer
Understand the server class that powers your app
Learn About AppSession
Work with individual user sessions
Handle Events
Subscribe to real-time data from glasses
Set Permissions
Control what data your app can access

