Client Config
Clients can store custom config data for their account on their
homeserver. This account data will be synced between different devices
and can persist across installations on a particular device. Users may
only view the account data for their own account.
The account data may be either global or scoped to a particular room.
There is no inheritance mechanism here: a given type of data missing
from a room’s account data does not fall back to the global account
data with the same type.
Events
The client receives the account data as events in the account_data
sections of a /sync response.
These events can also be received in a /events response or in the
account_data section of a room in a /sync response. m.tag events appearing in
/events will have a room_id with the room the tags are for.
Client Behaviour
GET
/_matrix/client/v3/user/{userId}/account_data/{type}
Get some account data for the client. This config is only visible to the user
that set the account data.
| Rate-limited: |
No |
| Requires authentication: |
Yes |
Request
Request parameters
path parameters
| Name |
Type |
Description |
type |
string |
Required: The event type of the account data to get. Custom types should be
namespaced to avoid clashes. |
userId |
string |
Required: The ID of the user to get account data for. The access token must be
authorized to make requests for this user ID. |
Responses
| Status |
Description |
200 |
The account data content for the given type. |
403 |
The access token provided is not authorized to retrieve this user’s account
data. Errcode: M_FORBIDDEN. |
404 |
No account data has been provided for this user with the given type.
Errcode: M_NOT_FOUND. |
200 response
{
"custom_account_data_key": "custom_config_value"
}
403 response
Error
| Name |
Type |
Description |
errcode |
string |
Required: An error code. |
error |
string |
A human-readable error message. |
{
"errcode": "M_FORBIDDEN",
"error": "Cannot add account data for other users."
}
404 response
Error
| Name |
Type |
Description |
errcode |
string |
Required: An error code. |
error |
string |
A human-readable error message. |
{
"errcode": "M_NOT_FOUND",
"error": "Account data not found."
}
PUT
/_matrix/client/v3/user/{userId}/account_data/{type}
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.
| Rate-limited: |
No |
| Requires authentication: |
Yes |
Request
Request parameters
path parameters
| Name |
Type |
Description |
type |
string |
Required: The event type of the account data to set. Custom types should be
namespaced to avoid clashes. |
userId |
string |
Required: The ID of the user to set account data for. The access token must be
authorized to make requests for this user ID. |
Request body
Request body example
{
"custom_account_data_key": "custom_config_value"
}
Responses
| Status |
Description |
200 |
The account data was successfully added. |
400 |
The request body is not a JSON object. Errcode: M_BAD_JSON
or M_NOT_JSON. |
403 |
The access token provided is not authorized to modify this user’s account
data. Errcode: M_FORBIDDEN. |
405 |
This type of account data is controlled by the server; it cannot be
modified by clients. Errcode: M_BAD_JSON. |
200 response
400 response
Error
| Name |
Type |
Description |
errcode |
string |
Required: An error code. |
error |
string |
A human-readable error message. |
{
"errcode": "M_NOT_JSON",
"error": "Content must be a JSON object."
}
403 response
Error
| Name |
Type |
Description |
errcode |
string |
Required: An error code. |
error |
string |
A human-readable error message. |
{
"errcode": "M_FORBIDDEN",
"error": "Cannot add account data for other users."
}
405 response
Error
| Name |
Type |
Description |
errcode |
string |
Required: An error code. |
error |
string |
A human-readable error message. |
{
"errcode": "M_BAD_JSON",
"error": "Cannot set m.fully_read through this API."
}
GET
/_matrix/client/v3/user/{userId}/rooms/{roomId}/account_data/{type}
Get some account data for the client on a given room. This config is only
visible to the user that set the account data.
| Rate-limited: |
No |
| Requires authentication: |
Yes |
Request
Request parameters
path parameters
| Name |
Type |
Description |
roomId |
string |
Required: The ID of the room to get account data for. |
type |
string |
Required: The event type of the account data to get. Custom types should be
namespaced to avoid clashes. |
userId |
string |
Required: The ID of the user to get account data for. The access token must be
authorized to make requests for this user ID. |
Responses
| Status |
Description |
200 |
The account data content for the given type. |
400 |
The given roomID is not a valid room ID. Errcode: M_INVALID_PARAM. |
403 |
The access token provided is not authorized to retrieve this user’s account
data. Errcode: M_FORBIDDEN. |
404 |
No account data has been provided for this user and this room with the
given type. Errcode: M_NOT_FOUND. |
200 response
{
"custom_account_data_key": "custom_config_value"
}
403 response
Error
| Name |
Type |
Description |
errcode |
string |
Required: An error code. |
error |
string |
A human-readable error message. |
{
"errcode": "M_FORBIDDEN",
"error": "Cannot add account data for other users."
}
404 response
Error
| Name |
Type |
Description |
errcode |
string |
Required: An error code. |
error |
string |
A human-readable error message. |
{
"errcode": "M_NOT_FOUND",
"error": "Room account data not found."
}
PUT
/_matrix/client/v3/user/{userId}/rooms/{roomId}/account_data/{type}
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.
| Rate-limited: |
No |
| Requires authentication: |
Yes |
Request
Request parameters
path parameters
| Name |
Type |
Description |
roomId |
string |
Required: The ID of the room to set account data on. |
type |
string |
Required: The event type of the account data to set. Custom types should be
namespaced to avoid clashes. |
userId |
string |
Required: The ID of the user to set account data for. The access token must be
authorized to make requests for this user ID. |
Request body
Request body example
{
"custom_account_data_key": "custom_account_data_value"
}
Responses
| Status |
Description |
200 |
The account data was successfully added. |
400 |
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). |
403 |
The access token provided is not authorized to modify this user’s account
data. Errcode: M_FORBIDDEN. |
405 |
This type of account data is controlled by the server; it cannot be
modified by clients. Errcode: M_BAD_JSON. |
200 response
400 response
Error
| Name |
Type |
Description |
errcode |
string |
Required: An error code. |
error |
string |
A human-readable error message. |
{
"errcode": "M_NOT_JSON",
"error": "Content must be a JSON object."
}
403 response
Error
| Name |
Type |
Description |
errcode |
string |
Required: An error code. |
error |
string |
A human-readable error message. |
{
"errcode": "M_FORBIDDEN",
"error": "Cannot add account data for other users."
}
405 response
Error
| Name |
Type |
Description |
errcode |
string |
Required: An error code. |
error |
string |
A human-readable error message. |
{
"errcode": "M_BAD_JSON",
"error": "Cannot set m.fully_read through this API."
}
Server Behaviour
Servers MUST reject clients from setting account data for event types
that the server manages. Currently, this only includes
m.fully_read.