Skip to main content
This is what the device does over its own WebSocket connection. An application asks for an OTP with POST /device/otp/generate instead — see Organization access.
A Melody device can request an OTP over its active WebSocket connection rather than making a separate HTTP call.

Frame Types


Message Definitions

OTPRequest (device → server):
OTPResponse (server → device):

Flow

  1. Device sends an OTP_REQUEST frame with a serialized (empty) OTPRequest message over the existing WebSocket connection.
  2. Server generates the OTP and replies with an OTP_RESPONSE frame on the same connection.
  3. If generation fails, error is non-empty — otp should be ignored in this case.

Code Example


Notes

  • The OTP is scoped to the requesting device’s connection — it is not broadcast to other subscribers.
  • The server answers within 10 seconds, or the request times out.
  • POST /device/otp/generate remains available as an alternative for obtaining an OTP without an active WebSocket connection.