Stream Channels API

Query, create, update, truncate, and delete chat channels.

OpenAPI Specification

getstream-channels-api-openapi.yml Raw ↑
openapi: 3.0.3
info:
  title: Stream Chat API (Server-side REST) Application Channels API
  description: 'Server-side REST API for Stream (GetStream.io) Chat. This is a curated subset of Stream''s published Chat protocol (https://getstream.github.io/protocol), grounding the endpoints modeled in the API Evangelist catalog against the real base URL and paths. The Chat API is addressed at https://chat.stream-io-api.com. Every request carries the application `api_key` as a query parameter and is authenticated with a JWT sent in the `Authorization` header together with a `Stream-Auth-Type: jwt` header. Server-side tokens (no `user_id` claim) are used for the operations in this document; client tokens are used to open the real-time WebSocket connection modeled in the companion AsyncAPI document.

    Path and method choices here are taken from Stream''s official chat-openapi.yaml (github.com/GetStream/protocol). Request and response bodies are represented generically; consult the linked protocol reference for the full schemas.'
  version: '1.0'
  contact:
    name: API Evangelist
    url: https://apievangelist.com
    email: kin@apievangelist.com
  license:
    name: API documentation - Stream Terms
    url: https://getstream.io/legal/terms/
servers:
- url: https://chat.stream-io-api.com
  description: Stream Chat API (edge, global)
security:
- JWT: []
  ApiKey: []
tags:
- name: Channels
  description: Query, create, update, truncate, and delete chat channels.
paths:
  /channels:
    post:
      operationId: QueryChannels
      tags:
      - Channels
      summary: Query channels
      description: Query the channels a user has access to, using a filter, sort, and pagination. Returns channel state including members, messages, reads, and channel configuration.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/QueryChannelsRequest'
      responses:
        '200':
          description: A list of channels with their state.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChannelsResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /channels/{type}/{id}:
    parameters:
    - $ref: '#/components/parameters/ChannelType'
    - $ref: '#/components/parameters/ChannelId'
    post:
      operationId: UpdateChannel
      tags:
      - Channels
      summary: Update a channel (overwrite)
      description: Overwrite a channel's custom data and, optionally, its member set.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
      responses:
        '200':
          $ref: '#/components/responses/Channel'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    patch:
      operationId: UpdateChannelPartial
      tags:
      - Channels
      summary: Partially update a channel
      description: Set or unset individual fields of a channel's custom data.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                set:
                  type: object
                unset:
                  type: array
                  items:
                    type: string
      responses:
        '200':
          $ref: '#/components/responses/Channel'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    delete:
      operationId: DeleteChannel
      tags:
      - Channels
      summary: Delete a channel
      description: Delete a channel and all of its messages (soft or hard delete).
      parameters:
      - name: hard_delete
        in: query
        schema:
          type: boolean
      responses:
        '200':
          $ref: '#/components/responses/Channel'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /channels/{type}/{id}/query:
    parameters:
    - $ref: '#/components/parameters/ChannelType'
    - $ref: '#/components/parameters/ChannelId'
    post:
      operationId: GetOrCreateChannel
      tags:
      - Channels
      summary: Get or create a channel
      description: Fetch a channel's full state, creating it if it does not yet exist, and optionally start watching it. This is the primary way to load a channel.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                watch:
                  type: boolean
                state:
                  type: boolean
                presence:
                  type: boolean
                data:
                  type: object
      responses:
        '200':
          $ref: '#/components/responses/Channel'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /channels/{type}/{id}/truncate:
    parameters:
    - $ref: '#/components/parameters/ChannelType'
    - $ref: '#/components/parameters/ChannelId'
    post:
      operationId: TruncateChannel
      tags:
      - Channels
      summary: Truncate a channel
      description: Remove all messages from a channel while keeping the channel itself.
      responses:
        '200':
          $ref: '#/components/responses/Channel'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /channels/{type}/{id}/read:
    parameters:
    - $ref: '#/components/parameters/ChannelType'
    - $ref: '#/components/parameters/ChannelId'
    post:
      operationId: MarkRead
      tags:
      - Channels
      summary: Mark a channel read
      description: Mark messages in a channel as read for a user, updating unread counts and emitting a `message.read` event.
      requestBody:
        content:
          application/json:
            schema:
              type: object
      responses:
        '200':
          description: Read state updated.
          content:
            application/json:
              schema:
                type: object
        '429':
          $ref: '#/components/responses/TooManyRequests'
components:
  schemas:
    Channel:
      type: object
      properties:
        id:
          type: string
        type:
          type: string
        cid:
          type: string
          description: The composite channel id, "{type}:{id}".
        member_count:
          type: integer
        created_by:
          $ref: '#/components/schemas/User'
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    ChannelsResponse:
      type: object
      properties:
        channels:
          type: array
          items:
            $ref: '#/components/schemas/ChannelStateResponse'
        duration:
          type: string
    ChannelStateResponse:
      type: object
      properties:
        channel:
          $ref: '#/components/schemas/Channel'
        messages:
          type: array
          items:
            $ref: '#/components/schemas/Message'
        members:
          type: array
          items:
            type: object
        read:
          type: array
          items:
            type: object
        duration:
          type: string
    User:
      type: object
      properties:
        id:
          type: string
        role:
          type: string
        name:
          type: string
        image:
          type: string
        online:
          type: boolean
        last_active:
          type: string
          format: date-time
        created_at:
          type: string
          format: date-time
    QueryChannelsRequest:
      type: object
      properties:
        filter_conditions:
          type: object
          description: MongoDB-style filter over channel fields.
        sort:
          type: array
          items:
            type: object
        limit:
          type: integer
        offset:
          type: integer
        watch:
          type: boolean
        state:
          type: boolean
        presence:
          type: boolean
    APIError:
      type: object
      properties:
        code:
          type: integer
        message:
          type: string
        StatusCode:
          type: integer
        duration:
          type: string
        more_info:
          type: string
    Message:
      type: object
      properties:
        id:
          type: string
        text:
          type: string
        type:
          type: string
          description: regular, ephemeral, error, reply, system, or deleted.
        cid:
          type: string
        user:
          $ref: '#/components/schemas/User'
        parent_id:
          type: string
        reaction_counts:
          type: object
          additionalProperties:
            type: integer
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
  parameters:
    ChannelId:
      name: id
      in: path
      required: true
      description: The channel id, unique within the channel type.
      schema:
        type: string
    ChannelType:
      name: type
      in: path
      required: true
      description: The channel type, e.g. messaging, livestream, team, gaming, commerce.
      schema:
        type: string
  responses:
    Unauthorized:
      description: Missing or invalid authentication.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/APIError'
    Channel:
      description: A channel and its state.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ChannelStateResponse'
    TooManyRequests:
      description: Rate limit exceeded for this app, platform, and endpoint. Inspect the X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset headers.
      headers:
        X-RateLimit-Limit:
          schema:
            type: integer
        X-RateLimit-Remaining:
          schema:
            type: integer
        X-RateLimit-Reset:
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/APIError'
  securitySchemes:
    JWT:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: 'A Stream JWT sent in the `Authorization` header. Server-side tokens omit the `user_id` claim; a `Stream-Auth-Type: jwt` header must accompany the request.'
    ApiKey:
      type: apiKey
      in: query
      name: api_key
      description: The application API key, sent as the `api_key` query parameter on every request.