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.
matrix-spec/data/api/client-server/account-data.yaml

390 lines
13 KiB
YAML

# Copyright 2016 OpenMarket Ltd
#
# 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 Client Config API
version: 1.0.0
paths:
"/user/{userId}/account_data/{type}":
put:
summary: Set some account data for the user.
description: |-
Set some account data for the client. This config is only visible to the user
that set the account data. The config will be available to clients through the
top-level `account_data` field in the homeserver response to
[/sync](/client-server-api/#get_matrixclientv3sync).
operationId: setAccountData
security:
- accessTokenQuery: []
- accessTokenBearer: []
parameters:
- in: path
name: userId
required: true
description: |-
The ID of the user to set account data for. The access token must be
authorized to make requests for this user ID.
example: "@alice:example.com"
schema:
type: string
- in: path
name: type
required: true
description: |-
The event type of the account data to set. Custom types should be
namespaced to avoid clashes.
example: org.example.custom.config
schema:
type: string
requestBody:
content:
application/json:
schema:
type: object
example: {
"custom_account_data_key": "custom_config_value"
}
description: The content of the account data.
required: true
responses:
"200":
description: The account data was successfully added.
content:
application/json:
schema:
type: object
examples:
response:
value: {}
"400":
description: |-
The request body is not a JSON object. Errcode: `M_BAD_JSON`
or `M_NOT_JSON`.
content:
application/json:
schema:
$ref: ../client-server/definitions/errors/error.yaml
examples:
response:
value: {
"errcode": "M_NOT_JSON",
"error": "Content must be a JSON object."
}
"403":
description: |-
The access token provided is not authorized to modify this user's account
data. Errcode: `M_FORBIDDEN`.
content:
application/json:
schema:
$ref: ../client-server/definitions/errors/error.yaml
examples:
response:
value: {
"errcode": "M_FORBIDDEN",
"error": "Cannot add account data for other users."
}
"405":
description: |-
This `type` of account data is controlled by the server; it cannot be
modified by clients. Errcode: `M_BAD_JSON`.
content:
application/json:
schema:
$ref: ../client-server/definitions/errors/error.yaml
examples:
response:
value: {
"errcode": "M_BAD_JSON",
"error": "Cannot set m.fully_read through this API."
}
tags:
- User data
get:
summary: Get some account data for the user.
description: |-
Get some account data for the client. This config is only visible to the user
that set the account data.
operationId: getAccountData
security:
- accessTokenQuery: []
- accessTokenBearer: []
parameters:
- in: path
name: userId
required: true
description: |-
The ID of the user to get account data for. The access token must be
authorized to make requests for this user ID.
example: "@alice:example.com"
schema:
type: string
- in: path
name: type
required: true
description: |-
The event type of the account data to get. Custom types should be
namespaced to avoid clashes.
example: org.example.custom.config
schema:
type: string
responses:
"200":
description: The account data content for the given type.
content:
application/json:
schema:
type: object
example: {
"custom_account_data_key": "custom_config_value"
}
"403":
description: |-
The access token provided is not authorized to retrieve this user's account
data. Errcode: `M_FORBIDDEN`.
content:
application/json:
schema:
$ref: ../client-server/definitions/errors/error.yaml
examples:
response:
value: {
"errcode": "M_FORBIDDEN",
"error": "Cannot add account data for other users."
}
"404":
description: |-
No account data has been provided for this user with the given `type`.
Errcode: `M_NOT_FOUND`.
content:
application/json:
schema:
$ref: ../client-server/definitions/errors/error.yaml
examples:
response:
value: {
"errcode": "M_NOT_FOUND",
"error": "Account data not found."
}
tags:
- User data
"/user/{userId}/rooms/{roomId}/account_data/{type}":
put:
summary: Set some account data for the user that is specific to a room.
description: |-
Set some account data for the client on a given room. This config is only
visible to the user that set the account data. The config will be delivered to
clients in the per-room entries via [/sync](/client-server-api/#get_matrixclientv3sync).
operationId: setAccountDataPerRoom
security:
- accessTokenQuery: []
- accessTokenBearer: []
parameters:
- in: path
name: userId
required: true
description: |-
The ID of the user to set account data for. The access token must be
authorized to make requests for this user ID.
example: "@alice:example.com"
schema:
type: string
- in: path
name: roomId
required: true
description: The ID of the room to set account data on.
example: "!726s6s6q:example.com"
schema:
type: string
- in: path
name: type
required: true
description: |-
The event type of the account data to set. Custom types should be
namespaced to avoid clashes.
example: org.example.custom.room.config
schema:
type: string
requestBody:
content:
application/json:
schema:
type: object
example: {
"custom_account_data_key": "custom_account_data_value"
}
description: The content of the account data.
required: true
responses:
"200":
description: The account data was successfully added.
content:
application/json:
schema:
type: object
examples:
response:
value: {}
"400":
description: |-
The request body is not a JSON object (errcode `M_BAD_JSON` or
`M_NOT_JSON`), or the given `roomID` is not a valid room ID
(errcode `M_INVALID_PARAM`).
content:
application/json:
schema:
$ref: ../client-server/definitions/errors/error.yaml
examples:
response:
value: {
"errcode": "M_NOT_JSON",
"error": "Content must be a JSON object."
}
"403":
description: |-
The access token provided is not authorized to modify this user's account
data. Errcode: `M_FORBIDDEN`.
content:
application/json:
schema:
$ref: ../client-server/definitions/errors/error.yaml
examples:
response:
value: {
"errcode": "M_FORBIDDEN",
"error": "Cannot add account data for other users."
}
"405":
description: |-
This `type` of account data is controlled by the server; it cannot be
modified by clients. Errcode: `M_BAD_JSON`.
content:
application/json:
schema:
$ref: ../client-server/definitions/errors/error.yaml
examples:
response:
value: {
"errcode": "M_BAD_JSON",
"error": "Cannot set m.fully_read through this API."
}
tags:
- User data
get:
summary: Get some account data for the user that is specific to a room.
description: |-
Get some account data for the client on a given room. This config is only
visible to the user that set the account data.
operationId: getAccountDataPerRoom
security:
- accessTokenQuery: []
- accessTokenBearer: []
parameters:
- in: path
name: userId
required: true
description: |-
The ID of the user to get account data for. The access token must be
authorized to make requests for this user ID.
example: "@alice:example.com"
schema:
type: string
- in: path
name: roomId
required: true
description: The ID of the room to get account data for.
example: "!726s6s6q:example.com"
schema:
type: string
- in: path
name: type
required: true
description: |-
The event type of the account data to get. Custom types should be
namespaced to avoid clashes.
example: org.example.custom.room.config
schema:
type: string
responses:
"200":
description: The account data content for the given type.
content:
application/json:
schema:
type: object
example: {
"custom_account_data_key": "custom_config_value"
}
"400":
description: "The given `roomID` is not a valid room ID. Errcode:
`M_INVALID_PARAM`."
content:
application/json:
schema:
$ref: ../client-server/definitions/errors/error.yaml
examples:
response:
value: {
"errcode": "M_INVALID_PARAM",
"error": "@notaroomid:example.org is not a valid room ID."
}
"403":
description: |-
The access token provided is not authorized to retrieve this user's account
data. Errcode: `M_FORBIDDEN`.
content:
application/json:
schema:
$ref: ../client-server/definitions/errors/error.yaml
examples:
response:
value: {
"errcode": "M_FORBIDDEN",
"error": "Cannot add account data for other users."
}
"404":
description: |-
No account data has been provided for this user and this room with the
given `type`. Errcode: `M_NOT_FOUND`.
content:
application/json:
schema:
$ref: ../client-server/definitions/errors/error.yaml
examples:
response:
value: {
"errcode": "M_NOT_FOUND",
"error": "Room account data not found."
}
tags:
- User data
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