# Copyright 2018 New Vector Ltd
# Copyright 2022 The Matrix.org Foundation C.I.C.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
openapi: 3.1.0
info:
  title: Matrix Client-Server Read Marker API
  version: 1.0.0
paths:
  "/rooms/{roomId}/read_markers":
    post:
      summary: Set the position of the read marker for a room.
      description: |-
        Sets the position of the read marker for a given room, and optionally
        the read receipt's location.
      operationId: setReadMarker
      security:
        - accessTokenQuery: []
        - accessTokenBearer: []
      parameters:
        - in: path
          name: roomId
          description: The room ID to set the read marker in for the user.
          required: true
          example: "!somewhere:example.org"
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                m.fully_read:
                  type: string
                  description: |-
                    The event ID the read marker should be located at. The
                    event MUST belong to the room.
                  example: $somewhere:example.org
                  x-changedInMatrixVersion:
                    "1.4": |
                      This property is no longer required.
                m.read:
                  type: string
                  description: |-
                    The event ID to set the read receipt location at. This is
                    equivalent to calling `/receipt/m.read/$elsewhere:example.org`
                    and is provided here to save that extra call.
                  example: $elsewhere:example.org
                m.read.private:
                  x-addedInMatrixVersion: "1.4"
                  type: string
                  description: |-
                    The event ID to set the *private* read receipt location at. This
                    equivalent to calling `/receipt/m.read.private/$elsewhere:example.org`
                    and is provided here to save that extra call.
                  example: $elsewhere:example.org
        description: The read marker and optional read receipt locations.
        required: true
      responses:
        "200":
          description: The read marker, and read receipt(s) if provided, have been updated.
          content:
            application/json:
              schema:
                type: object
                properties: {}
        "429":
          description: This request was rate-limited.
          content:
            application/json:
              schema:
                $ref: definitions/errors/rate_limited.yaml
      tags:
        - Read Markers
servers:
  - url: "{protocol}://{hostname}{basePath}"
    variables:
      protocol:
        enum:
          - http
          - https
        default: https
      hostname:
        default: localhost:8008
      basePath:
        default: /_matrix/client/v3
components:
  securitySchemes:
    accessTokenQuery:
      $ref: definitions/security.yaml#/accessTokenQuery
    accessTokenBearer:
      $ref: definitions/security.yaml#/accessTokenBearer
