Understand how a MentraOS app registers, initializes a session, connects to the cloud, subscribes to events, updates the display, and terminates cleanly.
packageName
: A unique identifier (e.g., com.example.myapp
).name
: A human-readable name.description
: A description of your app.webhookURL
: The URL where MentraOS Cloud will send session start requests.logoURL
: (Optional) URL to your app’s logo.apiKey
: A secret key for authenticating your app with the cloud.permissions
: An array of permissions your app needs. See the Permissions guide for details.Share with Testers
section.
webhookURL
. This request includes:
type
: "session_request"
sessionId
: A unique identifier for this session.userId
: The ID of the user who started the app.timestamp
: When the request was sent.webhookPath
(default: /webhook
).
session_request
, your app establishes a WebSocket connection to MentraOS Cloud. The AppServer
class in the SDK handles this for you automatically. You provide the cloud’s WebSocket URL in the AppServerConfig
:
tpa_connection_init
message to the cloud. This message includes:
type
: "tpa_connection_init"
sessionId
: The session ID from the webhook request.packageName
: Your app’s package name.apiKey
: Your app’s API key.AppSession
class handles sending this message automatically.
subscribe()
method or the events
object (see Events for details). This informs MentraOS Cloud which data to send to your app.
session.events.onTranscription()
).
LayoutManager
(accessible through session.layouts
) to create and send these requests.
stop_request
webhook to your app when a session ends. You can override the onStop
method in your AppServer
to handle any necessary cleanup. The AppSession
also emits a disconnected
event.
IMPORTANT: After making changes to your app code or restarting your server, you must restart your app inside the MentraOS phone app.This restart is necessary because the MentraOS phone app maintains a connection to your cloud app. When you make code changes or restart your server, you need to establish a fresh connection.