> This page is part of EVVA for Developers (https://developers.evvahub.com), the documentation of the EVVA Partner API. The API is in developer preview and the SDK packages are not yet published: do not suggest installing them. Index: https://developers.evvahub.com/llms.txt

# Realtime connection

GET /realtime

The control frames of a realtime connection: the handshake, subscriptions, acknowledgements and liveness checks.

All realtime traffic shares one WebSocket, `wss://api.evvahub.com/realtime`, or WebTransport at
`https://realtime.evvahub.com` (HTTP/3) with the same frames. [Realtime](/realtime) walks through a whole session.

**Frames on this page**

- Frames that belong to the connection rather than to a channel. They carry `channel: null`.
- The `subscribe` and `unsubscribe` commands and their answers.
- `ack`, which names its channel in the envelope.

Reference: https://developers.evvahub.com/api-reference/realtime/realtime-connection

## AsyncAPI Specification

```yaml
asyncapi: 2.6.0
info:
  title: Realtime connection
  version: subpackage_realtime.Realtime connection
  description: >-
    The control frames of a realtime connection: the handshake, subscriptions,
    acknowledgements and liveness checks.


    All realtime traffic shares one WebSocket, `wss://api.evvahub.com/realtime`,
    or WebTransport at

    `https://realtime.evvahub.com` (HTTP/3) with the same frames.
    [Realtime](/realtime) walks through a whole session.


    **Frames on this page**


    - Frames that belong to the connection rather than to a channel. They carry
    `channel: null`.

    - The `subscribe` and `unsubscribe` commands and their answers.

    - `ack`, which names its channel in the envelope.
channels:
  /realtime:
    description: >-
      The control frames of a realtime connection: the handshake, subscriptions,
      acknowledgements and liveness checks.


      All realtime traffic shares one WebSocket,
      `wss://api.evvahub.com/realtime`, or WebTransport at

      `https://realtime.evvahub.com` (HTTP/3) with the same frames.
      [Realtime](/realtime) walks through a whole session.


      **Frames on this page**


      - Frames that belong to the connection rather than to a channel. They
      carry `channel: null`.

      - The `subscribe` and `unsubscribe` commands and their answers.

      - `ack`, which names its channel in the envelope.
    publish:
      operationId: subpackage_realtime.Realtime connection-publish
      summary: Server messages
      message:
        oneOf:
          - $ref: >-
              #/components/messages/subpackage_realtime.Realtime
              connection-server-0-receiveHello
          - $ref: >-
              #/components/messages/subpackage_realtime.Realtime
              connection-server-1-receiveSubscribe
          - $ref: >-
              #/components/messages/subpackage_realtime.Realtime
              connection-server-2-receiveUnsubscribe
          - $ref: >-
              #/components/messages/subpackage_realtime.Realtime
              connection-server-3-receivePing
          - $ref: >-
              #/components/messages/subpackage_realtime.Realtime
              connection-server-4-receiveAck
    subscribe:
      operationId: subpackage_realtime.Realtime connection-subscribe
      summary: sendConnectionError
      message:
        name: sendConnectionError
        title: sendConnectionError
        payload:
          $ref: '#/components/schemas/connection_error'
servers:
  Production. Sandbox applications use the same host with `evpa_test_` tokens.:
    url: wss://api.evvahub.com/
    protocol: wss
    x-default: true
components:
  messages:
    subpackage_realtime.Realtime connection-server-0-receiveHello:
      name: receiveHello
      title: receiveHello
      description: >-
        Send your `evpa_` access token as `credential` with `principal:
        "application"`, never with `agencyId`.


        **Errors**


        - No valid `hello` within the handshake window, 5 seconds by default:
        the connection closes with `HANDSHAKE_TIMEOUT`.

        - An unsupported protocol version: an `error`
        `UNSUPPORTED_PROTOCOL_VERSION` with `supportedVersions`, then a close
          with `PROTOCOL_VERSION_UNSUPPORTED`.
        - A credential that does not authenticate: an `error` `UNAUTHENTICATED`
        (or `SESSION_REVOKED`), then a close with
          `UNAUTHENTICATED`.
      payload:
        $ref: '#/components/schemas/connection_hello'
    subpackage_realtime.Realtime connection-server-1-receiveSubscribe:
      name: receiveSubscribe
      title: receiveSubscribe
      description: >-
        You can ask for at most 32 channels per frame and 128 per connection
        (the defaults).


        When the connection resumed, a granted reliable channel replays what
        your client missed. A gap that cannot be

        replayed is reported with an `error` `RESUME_REJECTED` that names the
        channel in its envelope.
      payload:
        $ref: '#/components/schemas/connection_subscribe'
    subpackage_realtime.Realtime connection-server-2-receiveUnsubscribe:
      name: receiveUnsubscribe
      title: receiveUnsubscribe
      payload:
        $ref: '#/components/schemas/connection_unsubscribe'
    subpackage_realtime.Realtime connection-server-3-receivePing:
      name: receivePing
      title: receivePing
      payload:
        $ref: '#/components/schemas/connection_ping'
    subpackage_realtime.Realtime connection-server-4-receiveAck:
      name: receiveAck
      title: receiveAck
      payload:
        $ref: '#/components/schemas/connection_ack'
  schemas:
    ProtocolVersion:
      type: integer
      description: The version this server speaks.
      title: ProtocolVersion
    FrameType:
      type: string
      enum:
        - hello
        - welcome
        - subscribe
        - subscribed
        - unsubscribe
        - unsubscribed
        - event
        - error
        - ping
        - pong
        - ack
      title: FrameType
    ChannelRef:
      type: string
      pattern: ^[a-z][a-z0-9_]*:[a-z][a-z0-9_]{0,31}:[A-Za-z0-9_-]+$
      maxLength: 128
      description: >-
        A logical channel name, `<domain>:<resource>:<publicReference>`: a
        lowercase domain, a lower snake_case resource and a UUID or cuid
        reference. Your application's channel is
        `partner:application:<applicationId>`.
      title: ChannelRef
    HelloPayloadPrincipal:
      type: string
      enum:
        - application
      description: >-
        Set it to `application`. The connection is chosen explicitly as your
        application's, never from the token's shape. Refused together with
        `agencyId`; any other value is refused.
      title: HelloPayloadPrincipal
    ResumeRequestCursorsItems:
      type: object
      properties:
        channel:
          $ref: '#/components/schemas/ChannelRef'
        seq:
          type: integer
          minimum: 0
        cursor:
          type: string
          pattern: ^[A-Za-z0-9._~-]{1,512}$
          description: >-
            For the application channel only: the feed `cursor` of the last
            event you handled. EVVA replays the recorded events after it and
            continues at `seq + 1`, independently of `token`. The cursor is
            opaque and encrypted, at most 512 characters. Only a cursor of your
            application that covers the whole feed is accepted: another
            application's, a webhook's `whc1.` cursor, or a consumer-group
            lease's cursor that covers only some partitions is answered
            `RESUME_REJECTED` for the channel.
      required:
        - channel
        - seq
      title: ResumeRequestCursorsItems
    ResumeRequest:
      type: object
      properties:
        token:
          type: string
          description: The `connectionRef` from the previous connection's `welcome`.
        cursors:
          type: array
          items:
            $ref: '#/components/schemas/ResumeRequestCursorsItems'
        supersede:
          type: boolean
          description: Close the previous connection's session if it is still open.
      required:
        - token
        - cursors
      title: ResumeRequest
    HelloPayload:
      type: object
      properties:
        credential:
          type: string
          maxLength: 4096
          description: 'Your `evpa_` access token, sent with `principal: "application"`.'
        agencyId:
          type: string
          description: >-
            Not for applications. A `hello` with `agencyId` and `principal:
            "application"` together is refused.
        principal:
          $ref: '#/components/schemas/HelloPayloadPrincipal'
          description: >-
            Set it to `application`. The connection is chosen explicitly as your
            application's, never from the token's shape. Refused together with
            `agencyId`; any other value is refused.
        resume:
          $ref: '#/components/schemas/ResumeRequest'
      title: HelloPayload
    connection_hello:
      type: object
      properties:
        protocolVersion:
          $ref: '#/components/schemas/ProtocolVersion'
        type:
          $ref: '#/components/schemas/FrameType'
        frameId:
          type: string
          pattern: ^[A-Za-z0-9._-]{1,64}$
          description: A response echoes the frameId of the request it answers.
        sentAt:
          type: string
          format: date-time
          description: >-
            A timestamp, for telemetry only. The server never decides anything
            from a client's clock.
        channel:
          oneOf:
            - $ref: '#/components/schemas/ChannelRef'
            - type: 'null'
        seq:
          type:
            - integer
            - 'null'
          minimum: 0
          description: >-
            The per-channel delivery sequence, on reliable `event` frames and on
            `ack`. `null` on other frames.
        correlationId:
          type:
            - string
            - 'null'
        payload:
          $ref: '#/components/schemas/HelloPayload'
          description: The frame body (a JSON object).
      required:
        - protocolVersion
        - type
        - frameId
        - sentAt
        - channel
        - seq
        - correlationId
        - payload
      description: >-
        The envelope of every frame, in both directions. The server ignores
        unknown top-level fields and your client must ignore them too: the
        protocol grows by adding fields, without a version bump. On server
        frames, `channel`, `seq` and `correlationId` are an explicit `null`,
        never absent.
      title: connection_hello
    ChannelListPayload:
      type: object
      properties:
        channels:
          type: array
          items:
            type: string
      required:
        - channels
      title: ChannelListPayload
    connection_subscribe:
      type: object
      properties:
        protocolVersion:
          $ref: '#/components/schemas/ProtocolVersion'
        type:
          $ref: '#/components/schemas/FrameType'
        frameId:
          type: string
          pattern: ^[A-Za-z0-9._-]{1,64}$
          description: A response echoes the frameId of the request it answers.
        sentAt:
          type: string
          format: date-time
          description: >-
            A timestamp, for telemetry only. The server never decides anything
            from a client's clock.
        channel:
          oneOf:
            - $ref: '#/components/schemas/ChannelRef'
            - type: 'null'
        seq:
          type:
            - integer
            - 'null'
          minimum: 0
          description: >-
            The per-channel delivery sequence, on reliable `event` frames and on
            `ack`. `null` on other frames.
        correlationId:
          type:
            - string
            - 'null'
        payload:
          $ref: '#/components/schemas/ChannelListPayload'
          description: The frame body (a JSON object).
      required:
        - protocolVersion
        - type
        - frameId
        - sentAt
        - channel
        - seq
        - correlationId
        - payload
      description: >-
        The envelope of every frame, in both directions. The server ignores
        unknown top-level fields and your client must ignore them too: the
        protocol grows by adding fields, without a version bump. On server
        frames, `channel`, `seq` and `correlationId` are an explicit `null`,
        never absent.
      title: connection_subscribe
    connection_unsubscribe:
      type: object
      properties:
        protocolVersion:
          $ref: '#/components/schemas/ProtocolVersion'
        type:
          $ref: '#/components/schemas/FrameType'
        frameId:
          type: string
          pattern: ^[A-Za-z0-9._-]{1,64}$
          description: A response echoes the frameId of the request it answers.
        sentAt:
          type: string
          format: date-time
          description: >-
            A timestamp, for telemetry only. The server never decides anything
            from a client's clock.
        channel:
          oneOf:
            - $ref: '#/components/schemas/ChannelRef'
            - type: 'null'
        seq:
          type:
            - integer
            - 'null'
          minimum: 0
          description: >-
            The per-channel delivery sequence, on reliable `event` frames and on
            `ack`. `null` on other frames.
        correlationId:
          type:
            - string
            - 'null'
        payload:
          $ref: '#/components/schemas/ChannelListPayload'
          description: The frame body (a JSON object).
      required:
        - protocolVersion
        - type
        - frameId
        - sentAt
        - channel
        - seq
        - correlationId
        - payload
      description: >-
        The envelope of every frame, in both directions. The server ignores
        unknown top-level fields and your client must ignore them too: the
        protocol grows by adding fields, without a version bump. On server
        frames, `channel`, `seq` and `correlationId` are an explicit `null`,
        never absent.
      title: connection_unsubscribe
    ChannelsConnectionMessagesPingPayload:
      type: object
      properties: {}
      description: The frame body (a JSON object).
      title: ChannelsConnectionMessagesPingPayload
    connection_ping:
      type: object
      properties:
        protocolVersion:
          $ref: '#/components/schemas/ProtocolVersion'
        type:
          $ref: '#/components/schemas/FrameType'
        frameId:
          type: string
          pattern: ^[A-Za-z0-9._-]{1,64}$
          description: A response echoes the frameId of the request it answers.
        sentAt:
          type: string
          format: date-time
          description: >-
            A timestamp, for telemetry only. The server never decides anything
            from a client's clock.
        channel:
          oneOf:
            - $ref: '#/components/schemas/ChannelRef'
            - type: 'null'
        seq:
          type:
            - integer
            - 'null'
          minimum: 0
          description: >-
            The per-channel delivery sequence, on reliable `event` frames and on
            `ack`. `null` on other frames.
        correlationId:
          type:
            - string
            - 'null'
        payload:
          $ref: '#/components/schemas/ChannelsConnectionMessagesPingPayload'
          description: The frame body (a JSON object).
      required:
        - protocolVersion
        - type
        - frameId
        - sentAt
        - channel
        - seq
        - correlationId
        - payload
      description: >-
        The envelope of every frame, in both directions. The server ignores
        unknown top-level fields and your client must ignore them too: the
        protocol grows by adding fields, without a version bump. On server
        frames, `channel`, `seq` and `correlationId` are an explicit `null`,
        never absent.
      title: connection_ping
    ChannelsConnectionMessagesAckPayload:
      type: object
      properties: {}
      description: The frame body (a JSON object).
      title: ChannelsConnectionMessagesAckPayload
    connection_ack:
      type: object
      properties:
        protocolVersion:
          $ref: '#/components/schemas/ProtocolVersion'
        type:
          $ref: '#/components/schemas/FrameType'
        frameId:
          type: string
          pattern: ^[A-Za-z0-9._-]{1,64}$
          description: A response echoes the frameId of the request it answers.
        sentAt:
          type: string
          format: date-time
          description: >-
            A timestamp, for telemetry only. The server never decides anything
            from a client's clock.
        channel:
          $ref: '#/components/schemas/ChannelRef'
        seq:
          type: integer
          minimum: 0
          description: >-
            The per-channel delivery sequence, on reliable `event` frames and on
            `ack`. `null` on other frames.
        correlationId:
          type:
            - string
            - 'null'
        payload:
          $ref: '#/components/schemas/ChannelsConnectionMessagesAckPayload'
          description: The frame body (a JSON object).
      required:
        - protocolVersion
        - type
        - frameId
        - sentAt
        - channel
        - seq
        - correlationId
        - payload
      description: >-
        The envelope of every frame, in both directions. The server ignores
        unknown top-level fields and your client must ignore them too: the
        protocol grows by adding fields, without a version bump. On server
        frames, `channel`, `seq` and `correlationId` are an explicit `null`,
        never absent.
      title: connection_ack
    RealtimeErrorCode:
      type: string
      enum:
        - INVALID_FRAME
        - SUBSCRIPTION_LIMIT_EXCEEDED
        - UNSUPPORTED_PROTOCOL_VERSION
        - UNAUTHENTICATED
        - INTERNAL_ERROR
        - SESSION_REVOKED
        - RESUME_REJECTED
        - ACK_INVALID
        - SUBSCRIPTION_REVOKED
      title: RealtimeErrorCode
    ErrorPayload:
      type: object
      properties:
        code:
          $ref: '#/components/schemas/RealtimeErrorCode'
        detail:
          type: string
          maxLength: 200
        supportedVersions:
          type: array
          items:
            type: integer
          description: >-
            The protocol versions the server supports, sent with
            `UNSUPPORTED_PROTOCOL_VERSION`.
      required:
        - code
        - detail
      title: ErrorPayload
    connection_error:
      type: object
      properties:
        protocolVersion:
          $ref: '#/components/schemas/ProtocolVersion'
        type:
          $ref: '#/components/schemas/FrameType'
        frameId:
          type: string
          pattern: ^[A-Za-z0-9._-]{1,64}$
          description: A response echoes the frameId of the request it answers.
        sentAt:
          type: string
          format: date-time
          description: >-
            A timestamp, for telemetry only. The server never decides anything
            from a client's clock.
        channel:
          oneOf:
            - $ref: '#/components/schemas/ChannelRef'
            - type: 'null'
        seq:
          type:
            - integer
            - 'null'
          minimum: 0
          description: >-
            The per-channel delivery sequence, on reliable `event` frames and on
            `ack`. `null` on other frames.
        correlationId:
          type:
            - string
            - 'null'
        payload:
          $ref: '#/components/schemas/ErrorPayload'
          description: The frame body (a JSON object).
      required:
        - protocolVersion
        - type
        - frameId
        - sentAt
        - channel
        - seq
        - correlationId
        - payload
      description: >-
        The envelope of every frame, in both directions. The server ignores
        unknown top-level fields and your client must ignore them too: the
        protocol grows by adding fields, without a version bump. On server
        frames, `channel`, `seq` and `correlationId` are an explicit `null`,
        never absent.
      title: connection_error

```