Fern Definition isn’t recommended for new customers and Fern isn’t accepting feature requests for this format. It remains supported for existing users.
WebSockets enable a user to create a connection with a server, over which bidirectional communication can be sent.
In Fern, you can specify WebSockets in your API definition. The WebSockets will be included in both the generated SDKs and the API documentation.
Each WebSocket is defined in its own file, where it is described by the channel object. Put your WebSocket definition files in your fern folder alongside your other API definition files.
A channel is defined by the following fields:
auth: The authentication scheme for the WebSocketpath: The path of the WebSocketheaders (Optional): Any headers the WebSocket will sendpath-parameters (Optional): Any path parameters in the WebSocket pathquery-parameters (Optional): Any query parameters used in the initial request of the WebSocketmessages (Optional): The schemas of the messages the WebSocket can send and receive once connected
origin: The entity that sent the message (e.g. client or server)body: The schema of the messageexamples: Example WebSocket connection (Optional)Fern renders a unique reference page for WebSockets. The Handshake section outlines the protocol for connecting with the server, while the Send and Receive sections outline the message schemas that can be sent between the client and server.
Users can connect to and use WebSockets from right within the API Reference (check one of Hume’s WebSockets here).
