Freeday Webchat Realtime API 1.0.0

Real-time messaging API for the Freeday webchat, powered by Centrifugo. For REST endpoints see the REST API docs.

Quick Start

Service URL
REST API https://api.freeday.ai
WebSocket wss://realtime.freeday.ai

All REST calls require X-Session-Id (client-generated UUID) and X-Company (from Settings → Company in the Freeday platform) headers.

  1. Create a conversation
  2. Get a connection token
  3. Connect — Open a WebSocket to wss://realtime.freeday.ai/connection/websocket with the token. See Centrifugo client SDK docs.
  4. Get a subscription token
  5. Subscribe — Subscribe to the channel from step 4 with a getToken callback.

Example (centrifuge-js):

const sub = client.newSubscription(channel, {
  getToken: async () => {
    const res = await fetch("https://api.freeday.ai/sdk/v1/auth/subscribe-token", {
      method: "POST",
      headers: { "Content-Type": "application/json", "X-Session-Id": sessionId, "X-Company": companyId },
      body: JSON.stringify({ conversation_id: conversationId }),
    });
    return (await res.json()).subscription_token;
  },
});
sub.on("publication", (ctx) => handleEnvelope(ctx.data));
sub.subscribe();

Message Flow

Sending: Publish a SendMessage via subscription.publish().

Receiving: The server streams MessageEnvelope objects. Envelopes carry a sequence number — discard out-of-order envelopes. Ignore envelopes with an unrecognized proto version.

Streaming example:

  1. { operation: "replace", sequence: 1, message_snapshot: { status: "partial", blocks: [{ id: "b1", type: "typing", typing: true }] } }
  2. { operation: "replace", sequence: 2, message_snapshot: { status: "partial", blocks: [{ id: "b2", type: "markdown", content: "Hello! I can" }] } }
  3. { operation: "complete", sequence: 3, message_snapshot: { status: "complete", blocks: [{ id: "b2", type: "markdown", content: "Hello! I can help you with that." }] } }

Servers

  • wss://realtime.freeday.ai/wssproduction

    Production Centrifugo server

    Security:
    • HTTP
      • Scheme: bearer
      • Bearer format: JWT

      JWT tokens are used for both connection and channel subscription authentication.

Operations

  • RECEIVE messages:companies.{companyId}.conversations.{conversationId}

    Real-time message channel for a specific conversation.

    Clients subscribe to receive messages from the digital employee, agents, and system. Clients publish to send user messages.

    History: 100 messages retained for 1 hour. See the Centrifugo history documentation for retrieval details.

    Receive a message envelope from the server

    The server sends MessageEnvelope objects containing the message state and an operation that tells the client how to process it. Messages stream in via replace → … → complete.

    Operation IDreceiveMessage

    Available only on servers:

    object
    companyIdstring
    required

    UUID of the company

    conversationIdstring
    required

    UUID of the conversation

    Accepts the following message:

    Message Envelope

    Server-to-client message wrapper with streaming semantics

    Message IDmessageEnvelope
    object

    Wrapper around a message with streaming/sequencing metadata

    Examples

  • SEND messages:companies.{companyId}.conversations.{conversationId}

    Real-time message channel for a specific conversation.

    Clients subscribe to receive messages from the digital employee, agents, and system. Clients publish to send user messages.

    History: 100 messages retained for 1 hour. See the Centrifugo history documentation for retrieval details.

    Send a user message

    Publish a user message via subscription.publish().

    Operation IDsendUserMessage

    Available only on servers:

    object
    companyIdstring
    required

    UUID of the company

    conversationIdstring
    required

    UUID of the conversation

    Accepts the following message:

    User Message

    User message (client-to-server)

    Message IDuserMessage
    allOf

    A message sent from the client to the server. Fields like status and trace_id are server-managed and should not be included.

    Examples

Messages

  • #1Message Envelope

    Server-to-client message wrapper with streaming semantics

    Message IDMessageEnvelope
    object

    Wrapper around a message with streaming/sequencing metadata

  • #2User Message

    User message (client-to-server)

    Message IDUserMessage
    allOf

    A message sent from the client to the server. Fields like status and trace_id are server-managed and should not be included.

Schemas

  • object

    Wrapper around a message with streaming/sequencing metadata

  • string

    Controls how the client should process the message

  • object

    Common fields shared by client-sent and server-delivered messages

  • allOf

    A message sent from the client to the server. Fields like status and trace_id are server-managed and should not be included.

  • allOf

    A full chat message as delivered by the server inside a MessageEnvelope. Contains both client-provided and server-managed fields.

  • object
  • string
  • string

    Current processing state of the message

  • oneOf

    Content block within a message. Additional block types may be introduced in future versions.

  • object
  • allOf
  • allOf
  • allOf