You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
270 lines
12 KiB
YAML
270 lines
12 KiB
YAML
8 years ago
|
# Copyright 2016 OpenMarket Ltd
|
||
6 years ago
|
# Copyright 2018 New Vector Ltd
|
||
8 years ago
|
#
|
||
|
# 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.
|
||
9 years ago
|
swagger: '2.0'
|
||
|
info:
|
||
9 years ago
|
title: "Matrix Client-Server Room Creation API"
|
||
9 years ago
|
version: "1.0.0"
|
||
|
host: localhost:8008
|
||
|
schemes:
|
||
|
- https
|
||
|
- http
|
||
9 years ago
|
basePath: /_matrix/client/%CLIENT_MAJOR_VERSION%
|
||
9 years ago
|
consumes:
|
||
|
- application/json
|
||
|
produces:
|
||
|
- application/json
|
||
|
securityDefinitions:
|
||
9 years ago
|
$ref: definitions/security.yaml
|
||
9 years ago
|
paths:
|
||
|
"/createRoom":
|
||
|
post:
|
||
|
summary: Create a new room
|
||
|
description: |-
|
||
|
Create a new room with various configuration options.
|
||
8 years ago
|
|
||
|
The server MUST apply the normal state resolution rules when creating
|
||
|
the new room, including checking power levels for each event. It MUST
|
||
|
apply the events implied by the request in the following order:
|
||
|
|
||
5 years ago
|
1. The ``m.room.create`` event itself. Must be the first event in the
|
||
|
room.
|
||
|
|
||
|
2. An ``m.room.member`` event for the creator to join the room. This is
|
||
|
needed so the remaining events can be sent.
|
||
|
|
||
|
3. A default ``m.room.power_levels`` event, giving the room creator
|
||
6 years ago
|
(and not other members) permission to send state events. Overridden
|
||
|
by the ``power_level_content_override`` parameter.
|
||
6 years ago
|
|
||
5 years ago
|
4. Events set by the ``preset``. Currently these are the ``m.room.join_rules``,
|
||
6 years ago
|
``m.room.history_visibility``, and ``m.room.guest_access`` state events.
|
||
8 years ago
|
|
||
5 years ago
|
5. Events listed in ``initial_state``, in the order that they are
|
||
8 years ago
|
listed.
|
||
|
|
||
5 years ago
|
6. Events implied by ``name`` and ``topic`` (``m.room.name`` and ``m.room.topic``
|
||
6 years ago
|
state events).
|
||
8 years ago
|
|
||
5 years ago
|
7. Invite events implied by ``invite`` and ``invite_3pid`` (``m.room.member`` with
|
||
6 years ago
|
``membership: invite`` and ``m.room.third_party_invite``).
|
||
8 years ago
|
|
||
6 years ago
|
The available presets do the following with respect to room state:
|
||
|
|
||
|
======================== ============== ====================== ================ =========
|
||
|
Preset ``join_rules`` ``history_visibility`` ``guest_access`` Other
|
||
|
======================== ============== ====================== ================ =========
|
||
6 years ago
|
``private_chat`` ``invite`` ``shared`` ``can_join``
|
||
6 years ago
|
``trusted_private_chat`` ``invite`` ``shared`` ``can_join`` All invitees are given the same power level as the room creator.
|
||
6 years ago
|
``public_chat`` ``public`` ``shared`` ``forbidden``
|
||
6 years ago
|
======================== ============== ====================== ================ =========
|
||
|
|
||
6 years ago
|
The server will create a ``m.room.create`` event in the room with the
|
||
6 years ago
|
requesting user as the creator, alongside other keys provided in the
|
||
6 years ago
|
``creation_content``.
|
||
7 years ago
|
operationId: createRoom
|
||
9 years ago
|
security:
|
||
|
- accessToken: []
|
||
|
parameters:
|
||
|
- in: body
|
||
|
name: body
|
||
|
description: The desired room configuration.
|
||
5 years ago
|
required: true
|
||
9 years ago
|
schema:
|
||
|
type: object
|
||
7 years ago
|
example: {
|
||
6 years ago
|
"preset": "public_chat",
|
||
|
"room_alias_name": "thepub",
|
||
|
"name": "The Grand Duke Pub",
|
||
|
"topic": "All about happy hour",
|
||
|
"creation_content": {
|
||
|
"m.federate": false
|
||
9 years ago
|
}
|
||
6 years ago
|
}
|
||
9 years ago
|
properties:
|
||
|
visibility:
|
||
|
type: string
|
||
|
enum: ["public", "private"]
|
||
|
description: |-
|
||
|
A ``public`` visibility indicates that the room will be shown
|
||
|
in the published room list. A ``private`` visibility will hide
|
||
|
the room from the published room list. Rooms default to
|
||
|
``private`` visibility if this key is not included. NB: This
|
||
|
should not be confused with ``join_rules`` which also uses the
|
||
|
word ``public``.
|
||
|
room_alias_name:
|
||
|
type: string
|
||
|
description: |-
|
||
|
The desired room alias **local part**. If this is included, a
|
||
|
room alias will be created and mapped to the newly created
|
||
9 years ago
|
room. The alias will belong on the *same* homeserver which
|
||
9 years ago
|
created the room. For example, if this was set to "foo" and
|
||
|
sent to the homeserver "example.com" the complete room alias
|
||
|
would be ``#foo:example.com``.
|
||
6 years ago
|
|
||
|
The complete room alias will become the canonical alias for
|
||
|
the room.
|
||
9 years ago
|
name:
|
||
|
type: string
|
||
|
description: |-
|
||
|
If this is included, an ``m.room.name`` event will be sent
|
||
|
into the room to indicate the name of the room. See Room
|
||
|
Events for more information on ``m.room.name``.
|
||
|
topic:
|
||
|
type: string
|
||
|
description: |-
|
||
|
If this is included, an ``m.room.topic`` event will be sent
|
||
|
into the room to indicate the topic for the room. See Room
|
||
|
Events for more information on ``m.room.topic``.
|
||
|
invite:
|
||
|
type: array
|
||
|
description: |-
|
||
|
A list of user IDs to invite to the room. This will tell the
|
||
|
server to invite everyone in the list to the newly created room.
|
||
|
items:
|
||
|
type: string
|
||
9 years ago
|
invite_3pid:
|
||
|
type: array
|
||
|
description: |-
|
||
|
A list of objects representing third party IDs to invite into
|
||
|
the room.
|
||
|
items:
|
||
|
type: object
|
||
9 years ago
|
title: Invite3pid
|
||
9 years ago
|
properties:
|
||
|
id_server:
|
||
|
type: string
|
||
6 years ago
|
description: The hostname+port of the identity server which should be used for third party identifier lookups.
|
||
5 years ago
|
id_access_token:
|
||
|
type: string
|
||
5 years ago
|
description: |-
|
||
|
An access token previously registered with the identity server. Servers
|
||
|
can treat this as optional to distinguish between r0.5-compatible clients
|
||
|
and this specification version.
|
||
9 years ago
|
medium:
|
||
|
type: string
|
||
6 years ago
|
# TODO: Link to Identity Service spec when it eixsts
|
||
9 years ago
|
description: The kind of address being passed in the address field, for example ``email``.
|
||
|
address:
|
||
|
type: string
|
||
|
description: The invitee's third party identifier.
|
||
5 years ago
|
required: ["id_server", "id_access_token", "medium", "address"]
|
||
6 years ago
|
room_version:
|
||
|
type: string
|
||
|
description: |-
|
||
|
The room version to set for the room. If not provided, the homeserver is
|
||
|
to use its configured default. If provided, the homeserver will return a
|
||
|
400 error with the errcode ``M_UNSUPPORTED_ROOM_VERSION`` if it does not
|
||
|
support the room version.
|
||
|
example: "1"
|
||
9 years ago
|
creation_content:
|
||
|
title: CreationContent
|
||
|
type: object
|
||
|
description: |-
|
||
6 years ago
|
Extra keys, such as ``m.federate``, to be added to the content
|
||
|
of the `m.room.create`_ event. The server will clobber the following
|
||
6 years ago
|
keys: ``creator``, ``room_version``. Future versions of the specification
|
||
|
may allow the server to clobber other keys.
|
||
9 years ago
|
initial_state:
|
||
|
type: array
|
||
|
description: |-
|
||
|
A list of state events to set in the new room. This allows
|
||
|
the user to override the default state events set in the new
|
||
|
room. The expected format of the state events are an object
|
||
|
with type, state_key and content keys set.
|
||
8 years ago
|
|
||
6 years ago
|
Takes precedence over events set by ``preset``, but gets
|
||
9 years ago
|
overriden by ``name`` and ``topic`` keys.
|
||
|
items:
|
||
|
type: object
|
||
|
title: StateEvent
|
||
|
properties:
|
||
|
type:
|
||
|
type: string
|
||
6 years ago
|
description: The type of event to send.
|
||
9 years ago
|
state_key:
|
||
|
type: string
|
||
6 years ago
|
description: The state_key of the state event. Defaults to an empty string.
|
||
9 years ago
|
content:
|
||
7 years ago
|
type: object
|
||
6 years ago
|
description: The content of the event.
|
||
|
required: ["type", "content"]
|
||
9 years ago
|
preset:
|
||
|
type: string
|
||
|
enum: ["private_chat", "public_chat", "trusted_private_chat"]
|
||
|
description: |-
|
||
|
Convenience parameter for setting various default state events
|
||
6 years ago
|
based on a preset.
|
||
6 years ago
|
|
||
|
If unspecified, the server should use the ``visibility`` to determine
|
||
|
which preset to use. A visbility of ``public`` equates to a preset of
|
||
6 years ago
|
``public_chat`` and ``private`` visibility equates to a preset of
|
||
6 years ago
|
``private_chat``.
|
||
8 years ago
|
is_direct:
|
||
|
type: boolean
|
||
|
description: |-
|
||
8 years ago
|
This flag makes the server set the ``is_direct`` flag on the
|
||
|
``m.room.member`` events sent to the users in ``invite`` and
|
||
|
``invite_3pid``. See `Direct Messaging`_ for more information.
|
||
6 years ago
|
power_level_content_override:
|
||
|
title: Power Level Event Content
|
||
6 years ago
|
type: object
|
||
7 years ago
|
description: |-
|
||
6 years ago
|
The power level content to override in the default power level
|
||
6 years ago
|
event. This object is applied on top of the generated `m.room.power_levels`_
|
||
|
event content prior to it being sent to the room. Defaults to
|
||
|
overriding nothing.
|
||
9 years ago
|
responses:
|
||
|
200:
|
||
|
description: Information about the newly created room.
|
||
|
schema:
|
||
|
type: object
|
||
|
description: Information about the newly created room.
|
||
|
properties:
|
||
|
room_id:
|
||
|
type: string
|
||
|
description: |-
|
||
|
The created room's ID.
|
||
6 years ago
|
required: ['room_id']
|
||
9 years ago
|
examples:
|
||
7 years ago
|
application/json: {
|
||
6 years ago
|
"room_id": "!sefiuhWgwghwWgh:example.com"
|
||
6 years ago
|
}
|
||
9 years ago
|
400:
|
||
8 years ago
|
description: |-
|
||
|
|
||
|
The request is invalid. A meaningful ``errcode`` and description
|
||
|
error text will be returned. Example reasons for rejection include:
|
||
|
|
||
|
- The request body is malformed (``errcode`` set to ``M_BAD_JSON``
|
||
|
or ``M_NOT_JSON``).
|
||
|
|
||
|
- The room alias specified is already taken (``errcode`` set to
|
||
|
``M_ROOM_IN_USE``).
|
||
|
|
||
|
- The initial state implied by the parameters to the request is
|
||
|
invalid: for example, the user's ``power_level`` is set below
|
||
|
that necessary to set the room name (``errcode`` set to
|
||
|
``M_INVALID_ROOM_STATE``).
|
||
6 years ago
|
|
||
|
- The homeserver doesn't support the requested room version, or
|
||
|
one or more users being invited to the new room are residents
|
||
|
of a homeserver which does not support the requested room version.
|
||
|
The ``errcode`` will be ``M_UNSUPPORTED_ROOM_VERSION`` in these
|
||
|
cases.
|
||
6 years ago
|
schema:
|
||
|
"$ref": "definitions/errors/error.yaml"
|
||
9 years ago
|
tags:
|
||
|
- Room creation
|