# Copyright 2016 OpenMarket Ltd # Copyright 2023 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. swagger: '2.0' info: title: "Matrix Client-Server message event send API" version: "1.0.0" host: localhost:8008 schemes: - https - http basePath: /_matrix/client/v3 consumes: - application/json produces: - application/json securityDefinitions: $ref: definitions/security.yaml paths: "/rooms/{roomId}/send/{eventType}/{txnId}": put: summary: Send a message event to the given room. description: |- This endpoint is used to send a message event to a room. Message events allow access to historical events and pagination, making them suited for "once-off" activity in a room. The body of the request should be the content object of the event; the fields in this object will vary depending on the type of event. See [Room Events](/client-server-api/#room-events) for the m. event specification. operationId: sendMessage security: - accessToken: [] parameters: - in: path type: string name: roomId description: The room to send the event to. required: true x-example: "!636q39766251:example.com" - in: path type: string name: eventType description: The type of event to send. required: true x-example: "m.room.message" - in: path name: txnId type: string description: |- The [transaction ID](/client-server-api/#transaction-identifiers) for this event. Clients should generate an ID unique across requests with the same access token; it will be used by the server to ensure idempotency of requests. required: true x-example: "35" - in: body name: body required: true schema: type: object example: { "msgtype": "m.text", "body": "hello" } responses: 200: description: "An ID for the sent event." examples: application/json: { "event_id": "$YUwRidLecu:example.com" } schema: type: object properties: event_id: type: string description: |- A unique identifier for the event. required: - event_id 400: description: |- The request is invalid. A [standard error response](/client-server-api/#standard-error-response) will be returned. As well as the normal common error codes, other reasons for rejection include: - `M_DUPLICATE_ANNOTATION`: The request is an attempt to send a [duplicate annotation](/client-server-api/#avoiding-duplicate-annotations). schema: "$ref": "definitions/errors/error.yaml" tags: - Room participation