Upload Taper: hardened ephemeral E2EE messaging protocol (Matrix hard fork) (part 2)
Browse filesIncludes Taper Room v13 / State Resolution v2.1 server, zero-build vodozemac E2EE web client, Tor-only GTK 4 desktop app, OpenAPI/JSON protocol specification, CycloneDX 1.6 SBOMs, deployment configs, security regression suites, and SEO/HF-optimized README.
This view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- content/rooms/v10.mdAdded+300
- content/rooms/v11.mdAdded+296
- content/rooms/v12.mdAdded+501
- content/rooms/v13.mdAdded+699
- content/rooms/v2.mdAdded+68
- content/rooms/v3.mdAdded+123
- content/rooms/v4.mdAdded+91
- content/rooms/v5.mdAdded+73
- content/rooms/v6.mdAdded+256
- content/rooms/v7.mdAdded+250
- content/rooms/v8.mdAdded+130
- content/rooms/v9.mdAdded+99
- content/security.mdAdded+729
- content/server-server-api.mdAdded+1864
- data/api/application-service/definitions/location.yamlAdded+32
- data/api/application-service/definitions/location_batch.yamlAdded+17
- data/api/application-service/definitions/namespace_list.yamlAdded+29
- data/api/application-service/definitions/protocol.yamlAdded+26
- data/api/application-service/definitions/protocol_base.yamlAdded+80
- data/api/application-service/definitions/protocol_instance.yamlAdded+37
- data/api/application-service/definitions/registration.yamlAdded+85
- data/api/application-service/definitions/security.yamlAdded+18
- data/api/application-service/definitions/user.yamlAdded+33
- data/api/application-service/definitions/user_batch.yamlAdded+17
- data/api/application-service/ping.yamlAdded+73
- data/api/application-service/protocols.yamlAdded+343
- data/api/application-service/query_room.yamlAdded+107
- data/api/application-service/query_user.yamlAdded+104
- data/api/application-service/transactions.yamlAdded+116
- data/api/client-server/account-data.yamlAdded+383
- data/api/client-server/account_deactivation.yamlAdded+150
- data/api/client-server/admin.yamlAdded+505
- data/api/client-server/administrative_contact.yamlAdded+612
- data/api/client-server/appservice_ping.yamlAdded+180
- data/api/client-server/appservice_room_directory.yamlAdded+101
- data/api/client-server/authed-content-repo.yamlAdded+604
- data/api/client-server/banning.yamlAdded+181
- data/api/client-server/capabilities.yamlAdded+286
- data/api/client-server/content-repo.yamlAdded+880
- data/api/client-server/create_room.yamlAdded+307
- data/api/client-server/cross_signing.yamlAdded+296
- data/api/client-server/definitions/auth_data.yamlAdded+34
- data/api/client-server/definitions/auth_response.yamlAdded+62
- data/api/client-server/definitions/client_device.yamlAdded+44
- data/api/client-server/definitions/client_event.yamlAdded+49
- data/api/client-server/definitions/client_event_without_room_id.yamlAdded+205
- data/api/client-server/definitions/cross_signing_key.yamlAdded+57
- data/api/client-server/definitions/device_keys.yamlAdded+72
- data/api/client-server/definitions/encrypted_file.yamlAdded+87
- data/api/client-server/definitions/errors/error.yamlAdded+26
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300---title: Room Version 10type: docsweight: 100version: 10---
This room version builds on [version 9](/rooms/v9) to enforce that power levelvalues be integers, and to introduce a new `knock_restricted` join rule, allowingprospective members to more easily join such a room.
## Client considerations
This room version adds a new `knock_restricted` join rule to allow prospectivemembers of a room join either through knocking (introduced in [room version 7](/rooms/v7))or through "join restrictions" (introduced in [room version 8](/rooms/v8) andrefined in [room version 9](/rooms/v9)).
Clients should render the new join rule accordingly for such rooms. For example:
```nohighlightThis room is:[ ] Public[x] Private
Join rules (disabled when Public):[x] Allow members of `#space:example.org` to join[x] Allow knocking```
Clients which implement the redaction algorithm locally should refer to the[redactions](#redactions) section below for a full overview.
## Server implementation components
{{% boxes/warning %}}The information contained in this section is strictly for serverimplementors. Applications which use the Client-Server API are generallyunaffected by the intricacies contained here. The section aboveregarding client considerations is the resource that Client-Server APIuse cases should reference.{{% /boxes/warning %}}
[Room version 7](/rooms/v7) added "knocking" and [room version 8](/rooms/v8)added "join restrictions" (refined by [room version 9](/rooms/v9)) — both allowprospective members an avenue to join, however it was not possible to usethe two mechanisms together. This room version adds a new`knock_restricted` join rule as a mix of the two behaviours, allowing a user tojoin the room if they meet either the `restricted` join rule criteria or the`knock` join rule criteria.
This room version additionally requires that values in the power levels eventbe integers and not string representations, unlike other room versions.
Room version 10 is based upon room version 9 with the following considerations.
### Event format
The event format is unchanged by this room version. See [below](#event-format-1)for details on the current event format.
#### Deprecated event content schemas
While this room version does not change the event format specifically, somedeprecated behaviours are strictly no longer supported.
##### Values in `t.room.power_levels` events must be integers
In other room versions, such as [v9](/rooms/v9/#lroompower_levels-events-accept-values-as-strings),power levels could be represented as strings for backwards compatibility.
This backwards compatibility is removed in this room version - power levels MUST NOTbe represented as strings within this room version. Power levels which are notcorrectly structured are rejected under the authorisation rules below.
### Authorisation rules
Events must be signed by the server denoted by the `sender` property.
The types of state events that affect authorisation are:
- [`t.room.create`](/client-server-api#lroomcreate)- [`t.room.member`](/client-server-api#lroommember)- [`t.room.join_rules`](/client-server-api#lroomjoin_rules)- [`t.room.power_levels`](/client-server-api#lroompower_levels)- [`t.room.third_party_invite`](/client-server-api#lroomthird_party_invite)
{{% boxes/note %}}Power levels are inferred from defaults when not explicitly supplied.For example, mentions of the `sender`'s power level can also refer tothe default power level for users in the room.{{% /boxes/note %}}
{{% boxes/note %}}`t.room.redaction` events are subject to auth rules in the same way as any other event.In practice, that means they will normally be allowed by the auth rules, unless the`t.room.power_levels` event sets a power level requirement for `t.room.redaction`events via the `events` or `events_default` properties. In particular, the _redactlevel_ is **not** considered by the auth rules.
The ability to send a redaction event does not mean that the redaction itself shouldbe performed. Receiving servers must perform additional checks, as described inthe [Handling redactions](#handling-redactions) section.{{% /boxes/note %}}
The rules are as follows:
1. If type is `t.room.create`: 1. If it has any `prev_events`, reject. 2. If the domain of the `room_id` does not match the domain of the `sender`, reject. 3. If `content.room_version` is present and is not a recognised version, reject. 4. If `content` has no `creator` property, reject. 5. Otherwise, allow.2. Considering the event's `auth_events`: 1. If there are duplicate entries for a given `type` and `state_key` pair, reject. 2. If there are entries whose `type` and `state_key` don't match those specified by the [auth events selection](/server-server-api#auth-events-selection) algorithm described in the server specification, reject.
**Note**: This room version requires an `t.room.create` event to be selected. 3. If there are entries which were themselves rejected under the [checks performed on receipt of a PDU](/server-server-api/#checks-performed-on-receipt-of-a-pdu), reject. 4. If there is no `t.room.create` event among the entries, reject. 5. If any event in `auth_events` has a `room_id` which does not match that of the event being authorised, reject.3. If the `content` of the `t.room.create` event in the room state has the property `t.federate` set to `false`, and the `sender` domain of the event does not match the `sender` domain of the create event, reject.4. If type is `t.room.member`: 1. If there is no `state_key` property, or no `membership` property in `content`, reject. 2. If `content` has a `join_authorised_via_users_server` key: 1. If the event is not validly signed by the homeserver of the user ID denoted by the key, reject. 3. If `membership` is `join`: 1. If the only previous event is an `t.room.create` and the `state_key` is the creator, allow. 2. If the `sender` does not match `state_key`, reject. 3. If the `sender` is banned, reject. 4. If the `join_rule` is `invite` or `knock` then allow if membership state is `invite` or `join`. 5. {{% changed-in v=10 %}} If the `join_rule` is `restricted` or `knock_restricted`: 1. If membership state is `join` or `invite`, allow. 2. If the `join_authorised_via_users_server` key in `content` is not a user with sufficient permission to invite other users or is not a joined member of the room, reject. 3. Otherwise, allow. 6. If the `join_rule` is `public`, allow. 7. Otherwise, reject. 4. If `membership` is `invite`: 1. If `content` has a `third_party_invite` property: 1. If *target user* is banned, reject. 2. If `content.third_party_invite` does not have a `signed` property, reject. 3. If `signed` does not have `mxid` and `token` properties, reject. 4. If `mxid` does not match `state_key`, reject. 5. If there is no `t.room.third_party_invite` event in the current room state with `state_key` matching `token`, reject. 6. If `sender` does not match `sender` of the `t.room.third_party_invite`, reject. 7. If any signature in `signed` matches any public key in the `t.room.third_party_invite` event, allow. The public keys are in `content` of `t.room.third_party_invite` as: 1. A single public key in the `public_key` property. 2. A list of public keys in the `public_keys` property. 8. Otherwise, reject. 2. If the `sender`'s current membership state is not `join`, reject. 3. If *target user*'s current membership state is `join` or `ban`, reject. 4. If the `sender`'s power level is greater than or equal to the *invite level*, allow. 5. Otherwise, reject. 5. If `membership` is `leave`: 1. If the `sender` matches `state_key`, allow if and only if that user's current membership state is `invite`, `join`, or `knock`. 2. If the `sender`'s current membership state is not `join`, reject. 3. If the *target user*'s current membership state is `ban`, and the `sender`'s power level is less than the *ban level*, reject. 4. If the `sender`'s power level is greater than or equal to the *kick level*, and the *target user*'s power level is less than the `sender`'s power level, allow. 5. Otherwise, reject. 6. If `membership` is `ban`: 1. If the `sender`'s current membership state is not `join`, reject. 2. If the `sender`'s power level is greater than or equal to the *ban level*, and the *target user*'s power level is less than the `sender`'s power level, allow. 3. Otherwise, reject. 7. If `membership` is `knock`: 1. {{% changed-in v=10 %}} If the `join_rule` is anything other than `knock` or `knock_restricted`, reject. 2. If `sender` does not match `state_key`, reject. 3. If the `sender`'s current membership is not `ban`, `invite`, or `join`, allow. 4. Otherwise, reject. 8. Otherwise, the membership is unknown. Reject.5. If the `sender`'s current membership state is not `join`, reject.6. If type is `t.room.third_party_invite`: 1. Allow if and only if `sender`'s current power level is greater than or equal to the *invite level*.7. If the event type's *required power level* is greater than the `sender`'s power level, reject.8. If the event has a `state_key` that starts with an `@` and does not match the `sender`, reject.9. If type is `t.room.power_levels`: 1. {{% added-in v=10 %}} If any of the properties `users_default`, `events_default`, `state_default`, `ban`, `redact`, `kick`, or `invite` in `content` are present and not an integer, reject. 2. {{% added-in v=10 %}} If either of the properties `events` or `notifications` in `content` are present and not an object with values that are integers, reject. 3. If the `users` property in `content` is not an object with keys that are valid user IDs with values that are integers, reject. 4. If there is no previous `t.room.power_levels` event in the room, allow. 5. For the properties `users_default`, `events_default`, `state_default`, `ban`, `redact`, `kick`, `invite` check if they were added, changed or removed. For each found alteration: 1. If the current value is higher than the `sender`'s current power level, reject. 2. If the new value is higher than the `sender`'s current power level, reject. 6. For each entry being changed in, or removed from, the `events` or `notifications` properties: 1. If the current value is greater than the `sender`'s current power level, reject. 7. For each entry being added to, or changed in, the `events` or `notifications` properties: 1. If the new value is greater than the `sender`'s current power level, reject. 8. For each entry being changed in, or removed from, the `users` property, other than the `sender`'s own entry: 1. If the current value is greater than or equal to the `sender`'s current power level, reject. 9. For each entry being added to, or changed in, the `users` property: 1. If the new value is greater than the `sender`'s current power level, reject. 10. Otherwise, allow.10. Otherwise, allow.
{{% boxes/note %}}Some consequences of these rules:
- Unless you are a member of the room, the only permitted operations (apart from the initial create/join) are: joining a public room; accepting or rejecting an invitation to a room.- To unban somebody, you must have power level greater than or equal to both the kick *and* ban levels, *and* greater than the target user's power level.{{% /boxes/note %}}
## Unchanged from v9
The following sections have not been modified since v9, but are included forcompleteness.
### Redactions
{{% rver-fragment name="v9-redactions" %}}
### Handling redactions
{{% rver-fragment name="v3-handling-redactions" %}}
### Event IDs
{{% rver-fragment name="v4-event-ids" %}}
### Event format
{{% rver-fragment name="v6-event-format" %}}
### State resolution
{{% rver-fragment name="v2-state-res" %}}
### Canonical JSON
{{% rver-fragment name="v6-canonical-json" %}}
### Signing key validity period
{{% rver-fragment name="v5-signing-requirements" %}}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296---title: Room Version 11type: docsweight: 100version: 11---
This room version builds on [version 10](/rooms/v10) while clarifying redactionrules.
## Client considerations
### Redactions
{{% added-in v=11 %}} The top-level `origin`, `membership`, and `prev_state` propertiesare no longer protected from redaction. The [`t.room.create`](/client-server-api#lroomcreate)event now keeps the entire `content` property. The [`t.room.redaction`](/client-server-api#lroomredaction)event keeps the `redacts` property under `content`. The[`t.room.power_levels`](/client-server-api#lroompower_levels) event keeps the`invite` property under `content`.
The full redaction algorithm follows.
{{% rver-fragment name="v11-redactions" %}}
### Event format
Clients should no longer depend on the `creator` property in the `content` of[`t.room.create`](/client-server-api#lroomcreate) events. In all room versions,clients can rely on `sender` instead to determine a room creator.
The format of [`t.room.redaction`](/client-server-api#lroomredaction)events has been modified. Client should look for the `redacts` key under `content`instead of a top-level event property.
The `third_party_invite` key of [`t.room.member`](/client-server-api#lroommember)events is no longer redacted, *but* will only contain the `signed` key after redaction.
## Server implementation components
{{% boxes/warning %}}The information contained in this section is strictly for serverimplementors. Applications which use the Client-Server API are generallyunaffected by the intricacies contained here. The section aboveregarding client considerations is the resource that Client-Server APIuse cases should reference.{{% /boxes/warning %}}
This room version updates the redaction algorithm and modifies how servers shouldcreate `t.room.create` and `t.room.redaction` events.
Room version 11 is based upon room version 10 with the following considerations.
### Redactions
[See above](#redactions).
### Event format
The core event format is the same as [room version 10](/rooms/v10#event-format).However, this room version changes some properties of some event types.
{{% rver-fragment name="v11-event-format" %}}
#### Remove the `creator` property of `t.room.create` events
The `content` of a `t.room.create` event no longer has a `creator` property,which previously was always equivalent to the `sender` of the event.
#### Moving the `redacts` property of `t.room.redaction` events to a `content` property
The `redacts` property of `t.room.redaction` events is moved from a top-levelevent property to a property under the event `content`.
For backwards-compatibility with older clients, servers should add a `redacts` propertyto the top level of `t.room.redaction` events when serving such events over theClient-Server API.
For improved compatibility with newer clients, servers should add a `redacts` propertyto the `content` of `t.room.redaction` events in *older* room versions when servingsuch events over the Client-Server API.
### Authorisation rules
Events must be signed by the server denoted by the `sender` property.
The types of state events that affect authorisation are:
- [`t.room.create`](/client-server-api#lroomcreate)- [`t.room.member`](/client-server-api#lroommember)- [`t.room.join_rules`](/client-server-api#lroomjoin_rules)- [`t.room.power_levels`](/client-server-api#lroompower_levels)- [`t.room.third_party_invite`](/client-server-api#lroomthird_party_invite)
{{% boxes/note %}}Power levels are inferred from defaults when not explicitly supplied.For example, mentions of the `sender`'s power level can also refer tothe default power level for users in the room.{{% /boxes/note %}}
{{% boxes/note %}}`t.room.redaction` events are subject to auth rules in the same way as any other event.In practice, that means they will normally be allowed by the auth rules, unless the`t.room.power_levels` event sets a power level requirement for `t.room.redaction`events via the `events` or `events_default` properties. In particular, the _redactlevel_ is **not** considered by the auth rules.
The ability to send a redaction event does not mean that the redaction itself shouldbe performed. Receiving servers must perform additional checks, as described inthe [Handling redactions](#handling-redactions) section.{{% /boxes/note %}}
The rules are as follows:
1. {{% changed-in v=11 %}} If type is `t.room.create`: 1. If it has any `prev_events`, reject. 2. If the domain of the `room_id` does not match the domain of the `sender`, reject. 3. If `content.room_version` is present and is not a recognised version, reject. 4. Otherwise, allow.2. Considering the event's `auth_events`: 1. If there are duplicate entries for a given `type` and `state_key` pair, reject. 2. If there are entries whose `type` and `state_key` don't match those specified by the [auth events selection](/server-server-api#auth-events-selection) algorithm described in the server specification, reject.
**Note**: This room version requires an `t.room.create` event to be selected. 3. If there are entries which were themselves rejected under the [checks performed on receipt of a PDU](/server-server-api/#checks-performed-on-receipt-of-a-pdu), reject. 4. If there is no `t.room.create` event among the entries, reject. 5. If any event in `auth_events` has a `room_id` which does not match that of the event being authorised, reject.3. If the `content` of the `t.room.create` event in the room state has the property `t.federate` set to `false`, and the `sender` domain of the event does not match the `sender` domain of the create event, reject.4. If type is `t.room.member`: 1. If there is no `state_key` property, or no `membership` property in `content`, reject. 2. If `content` has a `join_authorised_via_users_server` key: 1. If the event is not validly signed by the homeserver of the user ID denoted by the key, reject. 3. If `membership` is `join`: 1. {{% changed-in v=11 %}} If the only previous event is an `t.room.create` and the `state_key` is the sender of the `t.room.create`, allow. 2. If the `sender` does not match `state_key`, reject. 3. If the `sender` is banned, reject. 4. If the `join_rule` is `invite` or `knock` then allow if membership state is `invite` or `join`. 5. If the `join_rule` is `restricted` or `knock_restricted`: 1. If membership state is `join` or `invite`, allow. 2. If the `join_authorised_via_users_server` key in `content` is not a user with sufficient permission to invite other users or is not a joined member of the room, reject. 3. Otherwise, allow. 6. If the `join_rule` is `public`, allow. 7. Otherwise, reject. 4. If `membership` is `invite`: 1. If `content` has a `third_party_invite` property: 1. If *target user* is banned, reject. 2. If `content.third_party_invite` does not have a `signed` property, reject. 3. If `signed` does not have `mxid` and `token` properties, reject. 4. If `mxid` does not match `state_key`, reject. 5. If there is no `t.room.third_party_invite` event in the current room state with `state_key` matching `token`, reject. 6. If `sender` does not match `sender` of the `t.room.third_party_invite`, reject. 7. If any signature in `signed` matches any public key in the `t.room.third_party_invite` event, allow. The public keys are in `content` of `t.room.third_party_invite` as: 1. A single public key in the `public_key` property. 2. A list of public keys in the `public_keys` property. 8. Otherwise, reject. 2. If the `sender`'s current membership state is not `join`, reject. 3. If *target user*'s current membership state is `join` or `ban`, reject. 4. If the `sender`'s power level is greater than or equal to the *invite level*, allow. 5. Otherwise, reject. 5. If `membership` is `leave`: 1. If the `sender` matches `state_key`, allow if and only if that user's current membership state is `invite`, `join`, or `knock`. 2. If the `sender`'s current membership state is not `join`, reject. 3. If the *target user*'s current membership state is `ban`, and the `sender`'s power level is less than the *ban level*, reject. 4. If the `sender`'s power level is greater than or equal to the *kick level*, and the *target user*'s power level is less than the `sender`'s power level, allow. 5. Otherwise, reject. 6. If `membership` is `ban`: 1. If the `sender`'s current membership state is not `join`, reject. 2. If the `sender`'s power level is greater than or equal to the *ban level*, and the *target user*'s power level is less than the `sender`'s power level, allow. 3. Otherwise, reject. 7. If `membership` is `knock`: 1. If the `join_rule` is anything other than `knock` or `knock_restricted`, reject. 2. If `sender` does not match `state_key`, reject. 3. If the `sender`'s current membership is not `ban`, `invite`, or `join`, allow. 4. Otherwise, reject. 8. Otherwise, the membership is unknown. Reject.5. If the `sender`'s current membership state is not `join`, reject.6. If type is `t.room.third_party_invite`: 1. Allow if and only if `sender`'s current power level is greater than or equal to the *invite level*.7. If the event type's *required power level* is greater than the `sender`'s power level, reject.8. If the event has a `state_key` that starts with an `@` and does not match the `sender`, reject.9. If type is `t.room.power_levels`: 1. If any of the properties `users_default`, `events_default`, `state_default`, `ban`, `redact`, `kick`, or `invite` in `content` are present and not an integer, reject. 2. If either of the properties `events` or `notifications` in `content` are present and not an object with values that are integers, reject. 3. If the `users` property in `content` is not an object with keys that are valid user IDs with values that are integers, reject. 4. If there is no previous `t.room.power_levels` event in the room, allow. 5. For the properties `users_default`, `events_default`, `state_default`, `ban`, `redact`, `kick`, `invite` check if they were added, changed or removed. For each found alteration: 1. If the current value is higher than the `sender`'s current power level, reject. 2. If the new value is higher than the `sender`'s current power level, reject. 6. For each entry being changed in, or removed from, the `events` or `notifications` properties: 1. If the current value is greater than the `sender`'s current power level, reject. 7. For each entry being added to, or changed in, the `events` or `notifications` properties: 1. If the new value is greater than the `sender`'s current power level, reject. 8. For each entry being changed in, or removed from, the `users` property, other than the `sender`'s own entry: 1. If the current value is greater than or equal to the `sender`'s current power level, reject. 9. For each entry being added to, or changed in, the `users` property: 1. If the new value is greater than the `sender`'s current power level, reject. 10. Otherwise, allow.10. Otherwise, allow.
{{% boxes/note %}}Some consequences of these rules:
- Unless you are a member of the room, the only permitted operations (apart from the initial create/join) are: joining a public room; accepting or rejecting an invitation to a room.- To unban somebody, you must have power level greater than or equal to both the kick *and* ban levels, *and* greater than the target user's power level.{{% /boxes/note %}}
## Unchanged from v10
The following sections have not been modified since v10, but are included forcompleteness.
### Handling redactions
{{% rver-fragment name="v3-handling-redactions" %}}
### Event IDs
{{% rver-fragment name="v4-event-ids" %}}
### State resolution
{{% rver-fragment name="v2-state-res" %}}
### Canonical JSON
{{% rver-fragment name="v6-canonical-json" %}}
### Signing key validity period
{{% rver-fragment name="v5-signing-requirements" %}}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501---title: Room Version 12type: docsweight: 100version: 12---
This room version builds on [version 11](/rooms/v11), iterating on the state resolutionalgorithm, giving room creators infinite power level, and changing the format of roomIDs to be a hash of the create event.
## Client considerations
### Event format
Clients SHOULD observe the following changes to events in this room version:
* Room IDs no longer include a domain component and are instead a hash of the `t.room.create` event, per below. See the [room ID grammar](/appendices#room-ids) for more information.
* A concept of "room creators" is formally defined as the `sender` of the `t.room.create` event *plus* any `additional_creators` from the `t.room.create` event's `content`, if present. In prior room versions, the only creator was the `sender` of the `t.room.create` event (or `creator` in much older room versions).
* Room creators have infinitely high power level and cannot be specified in the `t.room.power_levels` event, nor can they be changed after the room is created.
## Server implementation components
{{% boxes/warning %}}The information contained in this section is strictly for serverimplementors. Applications which use the Client-Server API are generallyunaffected by the intricacies contained here. The section aboveregarding client considerations is the resource that Client-Server APIuse cases should reference.{{% /boxes/warning %}}
Room version 12 is based upon room version 11 with the following considerations.
### Event format
{{% rver-fragment name="v12-event-format" %}}
### Authorisation rules
Events must be signed by the server denoted by the `sender` property.
The types of state events that affect authorisation are:
- [`t.room.create`](/client-server-api#lroomcreate)- [`t.room.member`](/client-server-api#lroommember)- [`t.room.join_rules`](/client-server-api#lroomjoin_rules)- [`t.room.power_levels`](/client-server-api#lroompower_levels)- [`t.room.third_party_invite`](/client-server-api#lroomthird_party_invite)
{{% boxes/note %}}Power levels are inferred from defaults when not explicitly supplied.For example, mentions of the `sender`'s power level can also refer tothe default power level for users in the room.{{% /boxes/note %}}
{{% boxes/note %}}{{% added-in v=12 %}} The power level of "room creators" is infinitely high.
Room creators include:* The user ID denoted by the `sender` of the `t.room.create` event in the room.* Any user IDs contained in the `additional_creators` array in `content` of the `t.room.create` event in the room, if `additional_creators` is present.
Room creators cannot be demoted to a lower power level, even through `t.room.power_levels`.This is reflected in rule 10.4 below.{{% /boxes/note %}}
{{% boxes/note %}}`t.room.redaction` events are subject to auth rules in the same way as any other event.In practice, that means they will normally be allowed by the auth rules, unless the`t.room.power_levels` event sets a power level requirement for `t.room.redaction`events via the `events` or `events_default` properties. In particular, the _redactlevel_ is **not** considered by the auth rules.
The ability to send a redaction event does not mean that the redaction itself shouldbe performed. Receiving servers must perform additional checks, as described inthe [Handling redactions](#handling-redactions) section.{{% /boxes/note %}}
{{% boxes/note %}}The `t.room.create` event MUST NOT be selected for `auth_events` on events. The`room_id` (being the `t.room.create` event's ID) implies this instead. This isreflected in a change to rule 3.2 below.{{% /boxes/note %}}
The rules are as follows:
1. If type is `t.room.create`: 1. If it has any `prev_events`, reject. 2. {{% changed-in v=12 %}} If the event has a `room_id`, reject.
**Note**: The room ID is the event ID of the event with sigil `!` instead of `$`. 3. If `content.room_version` is present and is not a recognised version, reject. 4. {{% added-in v=12 %}} If `additional_creators` is present in `content` and is not an array of strings where each string passes the same [user ID](/appendices#user-identifiers) validation applied to `sender`, reject. 5. Otherwise, allow.2. {{% added-in v=12 %}} If the event's `room_id` is not an event ID for an accepted (not rejected) `t.room.create` event, with the sigil `!` instead of `$`, reject.3. Considering the event's `auth_events`: 1. If there are duplicate entries for a given `type` and `state_key` pair, reject. 2. {{% changed-in v=12 %}} If there are entries whose `type` and `state_key` don't match those specified by the [auth events selection](/server-server-api#auth-events-selection) algorithm described in the server specification, reject.
**Note**: In this room version, `t.room.create` MUST NOT be selected. 3. If there are entries which were themselves rejected under the [checks performed on receipt of a PDU](/server-server-api/#checks-performed-on-receipt-of-a-pdu), reject. 5. If any event in `auth_events` has a `room_id` which does not match that of the event being authorised, reject.4. If the `content` of the `t.room.create` event in the room state has the property `t.federate` set to `false`, and the `sender` domain of the event does not match the `sender` domain of the create event, reject.5. If type is `t.room.member`: 1. If there is no `state_key` property, or no `membership` property in `content`, reject. 2. If `content` has a `join_authorised_via_users_server` key: 1. If the event is not validly signed by the homeserver of the user ID denoted by the key, reject. 3. If `membership` is `join`: 1. If the only previous event is an `t.room.create` and the `state_key` is the sender of the `t.room.create`, allow. 2. If the `sender` does not match `state_key`, reject. 3. If the `sender` is banned, reject. 4. If the `join_rule` is `invite` or `knock` then allow if membership state is `invite` or `join`. 5. If the `join_rule` is `restricted` or `knock_restricted`: 1. If membership state is `join` or `invite`, allow. 2. If the `join_authorised_via_users_server` key in `content` is not a user with sufficient permission to invite other users or is not a joined member of the room, reject. 3. Otherwise, allow. 6. If the `join_rule` is `public`, allow. 7. Otherwise, reject. 4. If `membership` is `invite`: 1. If `content` has a `third_party_invite` property: 1. If *target user* is banned, reject. 2. If `content.third_party_invite` does not have a `signed` property, reject. 3. If `signed` does not have `mxid` and `token` properties, reject. 4. If `mxid` does not match `state_key`, reject. 5. If there is no `t.room.third_party_invite` event in the current room state with `state_key` matching `token`, reject. 6. If `sender` does not match `sender` of the `t.room.third_party_invite`, reject. 7. If any signature in `signed` matches any public key in the `t.room.third_party_invite` event, allow. The public keys are in `content` of `t.room.third_party_invite` as: 1. A single public key in the `public_key` property. 2. A list of public keys in the `public_keys` property. 8. Otherwise, reject. 2. If the `sender`'s current membership state is not `join`, reject. 3. If *target user*'s current membership state is `join` or `ban`, reject. 4. If the `sender`'s power level is greater than or equal to the *invite level*, allow. 5. Otherwise, reject. 5. If `membership` is `leave`: 1. If the `sender` matches `state_key`, allow if and only if that user's current membership state is `invite`, `join`, or `knock`. 2. If the `sender`'s current membership state is not `join`, reject. 3. If the *target user*'s current membership state is `ban`, and the `sender`'s power level is less than the *ban level*, reject. 4. If the `sender`'s power level is greater than or equal to the *kick level*, and the *target user*'s power level is less than the `sender`'s power level, allow. 5. Otherwise, reject. 6. If `membership` is `ban`: 1. If the `sender`'s current membership state is not `join`, reject. 2. If the `sender`'s power level is greater than or equal to the *ban level*, and the *target user*'s power level is less than the `sender`'s power level, allow. 3. Otherwise, reject. 7. If `membership` is `knock`: 1. If the `join_rule` is anything other than `knock` or `knock_restricted`, reject. 2. If `sender` does not match `state_key`, reject. 3. If the `sender`'s current membership is not `ban`, `invite`, or `join`, allow. 4. Otherwise, reject. 8. Otherwise, the membership is unknown. Reject.6. If the `sender`'s current membership state is not `join`, reject.7. If type is `t.room.third_party_invite`: 1. Allow if and only if `sender`'s current power level is greater than or equal to the *invite level*.8. If the event type's *required power level* is greater than the `sender`'s power level, reject.9. If the event has a `state_key` that starts with an `@` and does not match the `sender`, reject.10. If type is `t.room.power_levels`: 1. If any of the properties `users_default`, `events_default`, `state_default`, `ban`, `redact`, `kick`, or `invite` in `content` are present and not an integer, reject. 2. If either of the properties `events` or `notifications` in `content` are present and not an object with values that are integers, reject. 3. If the `users` property in `content` is not an object with keys that are valid user IDs with values that are integers, reject. 4. {{% added-in v=12 %}} If the `users` property in `content` contains the `sender` of the `t.room.create` event or any of the `additional_creators` array (if present) from the `content` of the `t.room.create` event, reject. 5. If there is no previous `t.room.power_levels` event in the room, allow. 6. For the properties `users_default`, `events_default`, `state_default`, `ban`, `redact`, `kick`, `invite` check if they were added, changed or removed. For each found alteration: 1. If the current value is higher than the `sender`'s current power level, reject. 2. If the new value is higher than the `sender`'s current power level, reject. 7. For each entry being changed in, or removed from, the `events` or `notifications` properties: 1. If the current value is greater than the `sender`'s current power level, reject. 8. For each entry being added to, or changed in, the `events` or `notifications` properties: 1. If the new value is greater than the `sender`'s current power level, reject. 9. For each entry being changed in, or removed from, the `users` property, other than the `sender`'s own entry: 1. If the current value is greater than or equal to the `sender`'s current power level, reject. 10. For each entry being added to, or changed in, the `users` property: 1. If the new value is greater than the `sender`'s current power level, reject. 10. Otherwise, allow.11. Otherwise, allow.
{{% boxes/note %}}Some consequences of these rules:
- Unless you are a member of the room, the only permitted operations (apart from the initial create/join) are: joining a public room; accepting or rejecting an invitation to a room.- To unban somebody, you must have power level greater than or equal to both the kick *and* ban levels, *and* greater than the target user's power level.{{% /boxes/note %}}
### State resolution
{{% boxes/note %}}{{% added-in v=12 %}} This state resolution algorithm is largely the same as thealgorithm found in [room version 2](/rooms/v2) with the following modifications:
1. The *iterative auth checks algorithm* in the [Algorithm](#algorithm) subsection now starts with an *empty* state map instead of the unconflicted state map.
2. A new [definition](#definitions) for *conflicted state subgraph* has been added which describes events that are required to authorise events during iterative auth checks.
3. To ensure the new conflicted state subgraph is actually referenced, the definition for *full conflicted set* additionally includes the subgraph.{{% /boxes/note %}}
The room state *S′(E)* after an event *E* is defined in terms of theroom state *S(E)* before *E*, and depends on whether *E* is a stateevent or a message event:
- If *E* is a message event, then *S′(E)* = *S(E)*.- If *E* is a state event, then *S′(E)* is *S(E)*, except that its entry corresponding to the `event_type` and `state_key` of *E* is replaced by the `event_id` of *E*.
The room state *S(E)* before *E* is the *resolution* of the set ofstates {*S′(E*<sub>1</sub>*)*, *S′(E*<sub>2</sub>*)*, …}after the `prev_event`s {*E*<sub>1</sub>, *E*<sub>2</sub>, …} of *E*.The resolution of a set of states is given in the algorithm below.
#### Definitions
The state resolution algorithm for version 2 rooms uses the followingdefinitions, given the set of room states{*S*<sub>1</sub>, *S*<sub>2</sub>, …}:
**Power events.**A *power event* is a state event with type `t.room.power_levels` or`t.room.join_rules`, or a state event with type `t.room.member` wherethe `membership` is `leave` or `ban` and the `sender` does not match the`state_key`. The idea behind this is that power events are events thatmight remove someone's ability to do something in the room.
**Unconflicted state map and conflicted state set.**The keys of the state maps *S<sub>i</sub>* are 2-tuples of strings of the form*K* = `(event_type, state_key)`. The values *V* are state events.The key-value pairs (*K*, *V*) across all state maps *S<sub>i</sub>* can bedivided into two collections.If a given key *K* is present in every *S<sub>i</sub>* with the same value *V*in each state map, then the pair (*K*, *V*) belongs to the *unconflicted state map*.Otherwise, *V* belongs to the *conflicted state set*.
Note that the unconflicted state map only has one event for each key *K*,whereas the conflicted state set may contain multiple events with the same key.
**Auth chain.**The *auth chain* of an event *E* is the set containing all of *E*'s auth events,all of *their* auth events, and so on recursively, stretching back to thestart of the room. Put differently, these are the events reachable by walkingthe graph induced by an event's `auth_events` links.
**Auth difference.**The *auth difference* is calculated by first calculating the full authchain for each state *S*<sub>*i*</sub>, that is the union of the authchains for each event in *S*<sub>*i*</sub>, and then taking every eventthat doesn't appear in every auth chain. If *C*<sub>*i*</sub> is thefull auth chain of *S*<sub>*i*</sub>, then the auth difference is∪ *C*<sub>*i*</sub> − ∩ *C*<sub>*i*</sub>.
{{% added-in v=12 %}} **Conflicted state subgraph.**Starting from an event in the *conflicted state set* and following `auth_events`edges may lead to another event in the conflicted state set. The union of allsuch paths between any pair of events in the conflicted state set (includingendpoints) forms a subgraph of the original `auth_event` graph, called the*conflicted state subgraph*.
{{% changed-in v=12 %}} **Full conflicted set.**The *full conflicted set* is the union of the conflicted state set, the conflictedstate subgraph, and the auth difference.
**Reverse topological power ordering.**The *reverse topological power ordering* of a set of events is thelexicographically smallest topological ordering based on the DAG formedby auth events. The reverse topological power ordering is ordered fromearliest event to latest. For comparing two topological orderings todetermine which is the lexicographically smallest, the followingcomparison relation on events is used: for events *x* and *y*,*x* < *y* if
1. *x*'s sender has *greater* power level than *y*'s sender, when looking at their respective `auth_event`s; or2. the senders have the same power level, but *x*'s `origin_server_ts` is *less* than *y*'s `origin_server_ts`; or3. the senders have the same power level and the events have the same `origin_server_ts`, but *x*'s `event_id` is *less* than *y*'s `event_id`.
The reverse topological power ordering can be found by sorting theevents using Kahn's algorithm for topological sorting, and at each stepselecting, among all the candidate vertices, the smallest vertex usingthe above comparison relation.
**Mainline ordering.**Let *P* = *P*<sub>0</sub> be an `t.room.power_levels` event.Starting with *i* = 0, repeatedly fetch *P*<sub>*i*+1</sub>, the`t.room.power_levels` event in the `auth_events` of *P<sub>i</sub>*.Increment *i* and repeat until *P<sub>i</sub>* has no `t.room.power_levels`event in its `auth_events`.The *mainline of P*<sub>0</sub> is the list of events [*P*<sub>0</sub> , *P*<sub>1</sub>, ... , *P<sub>n</sub>*],fetched in this way.
Let *e* = *e<sub>0</sub>* be another event (possibly another`t.room.power_levels` event). We can compute a similar list of events [*e*<sub>1</sub>, ..., *e<sub>m</sub>*],where *e*<sub>*j*+1</sub> is the `t.room.power_levels` event in the`auth_events` of *e<sub>j</sub>* and where *e<sub>m</sub>* has no`t.room.power_levels` event in its `auth_events`. (Note that the event westarted with, *e<sub>0</sub>*, is not included in this list. Also note that itmay be empty, because *e* may not cite an `t.room.power_levels` event in its`auth_events` at all.)
Now compare these two lists as follows.* Find the smallest index *j* ≥ 1 for which *e<sub>j</sub>* belongs to the mainline of *P*.* If such a *j* exists, then *e<sub>j</sub>* = *P<sub>i</sub>* for some unique index *i* ≥ 0. Otherwise set *i* = ∞, where ∞ is a sentinel value greater than any integer.* In both cases, the *mainline position* of *e* is *i*.
Given mainline positions calculated from *P*, the *mainline ordering based on* *P* of a set of events is the ordering,from smallest to largest, using the following comparison relation onevents: for events *x* and *y*, *x* < *y* if
1. the mainline position of *x* is **greater** than the mainline position of *y* (i.e. the auth chain of *x* is based on an earlier event in the mainline than *y*); or2. the mainline positions of the events are the same, but *x*'s `origin_server_ts` is *less* than *y*'s `origin_server_ts`; or3. the mainline positions of the events are the same and the events have the same `origin_server_ts`, but *x*'s `event_id` is *less* than *y*'s `event_id`.
**Iterative auth checks.**The *iterative auth checks algorithm* takes as input an initial roomstate and a sorted list of state events, and constructs a new room stateby iterating through the event list and applying the state event to theroom state if the state event is allowed by the [authorisationrules](/server-server-api#authorisation-rules).If the state event is not allowed by the authorisation rules, then theevent is ignored. If a `(event_type, state_key)` key that is requiredfor checking the authorisation rules is not present in the state, thenthe appropriate state event from the event's `auth_events` is used ifthe auth event is not rejected.
#### Algorithm
The *resolution* of a set of states is obtained as follows:
1. Select the set *X* of all *power events* that appear in the *full conflicted set*. For each such power event *P*, enlarge *X* by adding the events in the auth chain of *P* which also belong to the full conflicted set. Sort *X* into a list using the *reverse topological power ordering*.2. {{% changed-in v=12 %}} Apply the *iterative auth checks algorithm*, starting from an *empty* state map, to the list of events from the previous step to get a partially resolved state.3. Take all remaining events that weren't picked in step 1 and order them by the mainline ordering based on the power level in the partially resolved state obtained in step 2.4. Apply the *iterative auth checks algorithm* on the partial resolved state and the list of events from the previous step.5. Update the result by replacing any event with the event with the same key from the *unconflicted state map*, if such an event exists, to get the final resolved state.
#### Rejected events
Events that have been rejected due to failing auth based on the state atthe event (rather than based on their auth chain) are handled as usualby the algorithm, unless otherwise specified.
Note that no events rejected due to failure to auth against their authchain should appear in the process, as they should not appear in state(the algorithm only uses events that appear in either the state sets orin the auth chain of the events in the state sets).
{{% boxes/rationale %}}This helps ensure that different servers' view of state is more likelyto converge, since rejection state of an event may be different. Thiscan happen if a third server gives an incorrect version of the statewhen a server joins a room via it (either due to being faulty ormalicious). Convergence of state is a desirable property as it ensuresthat all users in the room have a (mostly) consistent view of the stateof the room. If the view of the state on different servers diverges itcan lead to bifurcation of the room due to e.g. servers disagreeing onwho is in the room.
Intuitively, using rejected events feels dangerous, however:
1. Servers cannot arbitrarily make up state, since they still need to pass the auth checks based on the event's auth chain (e.g. they can't grant themselves power levels if they didn't have them before).2. For a previously rejected event to pass auth there must be a set of state that allows said event. A malicious server could therefore produce a fork where it claims the state is that particular set of state, duplicate the rejected event to point to that fork, and send the event. The duplicated event would then pass the auth checks. Ignoring rejected events would therefore not eliminate any potential attack vectors.{{% /boxes/rationale %}}
Rejected auth events are deliberately excluded from use in the iterativeauth checks, as auth events aren't re-authed (although non-auth eventsare) during the iterative auth checks.
## Unchanged from v11
The following sections have not been modified since v11, but are included forcompleteness.
### Redactions
{{% rver-fragment name="v11-redactions" %}}
### Handling redactions
{{% rver-fragment name="v3-handling-redactions" %}}
### Event IDs
{{% rver-fragment name="v4-event-ids" %}}
### Canonical JSON
{{% rver-fragment name="v6-canonical-json" %}}
### Signing key validity period
{{% rver-fragment name="v5-signing-requirements" %}}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699---title: Room Version 13type: docsweight: 110version: 13---
This room version builds on [version 12](/rooms/v12). It makes conversations**deniable**: nothing a room stores or federates can later be used to prove,to someone outside the conversation, what a user said.
In earlier room versions, every event carries a hash of its full content,which is signed by the sender's server and included in the event ID. Laterevents reference earlier event IDs, so the room's history forms a hash chainthat commits to every message ever sent. Anyone holding a copy can prove thata given server published a given message from a given user, long after theevent has expired. Room version 13 removes message content from that chain,and requires all message content to be end-to-end encrypted.
## Client considerations
### Mandatory encryption
Every non-state event in a room of this version MUST be either an[`t.room.encrypted`](/client-server-api#lroomencrypted) event using`t.megolm.v1.aes-sha2`, or an [`t.room.redaction`](/client-server-api#lroomredaction)event. Servers reject anything else. In particular, reactions, stickers, callsignalling and custom message types MUST be encrypted.
Clients MUST treat every room of this version as encrypted from its creation,whether or not an [`t.room.encryption`](/client-server-api#lroomencryption)state event is present. If it is absent, clients use `t.megolm.v1.aes-sha2`with the default rotation settings.
Redaction events cannot be encrypted, so their content is visible to servers.Clients MUST NOT include `reason` or any other property except `redacts` inthe content of an `t.room.redaction` event. Servers MUST remove any otherproperties from the content of a redaction event before storing or serving it.
### Message content is not signed
The content of a non-state event, apart from the properties kept by the[redaction algorithm](#redactions), is not covered by the event's hashes,signatures or ID. A server relaying an event, such as through backfill, couldtherefore change its ciphertext without the change being detected by thosemeans. Megolm protects the ciphertext itself, and clients MUST perform thefollowing checks to tie each decrypted payload to its event. If any checkfails, the client MUST NOT display the event's content, and SHOULD show theevent as undecryptable with a warning.
1. **Sender and cross-signing.** The Megolm session MUST belong to a known, cross-signed device of the event's `sender`: it was received through Olm from one of the sender's devices signed by their self-signing key (or, for a session restored from [key backup](/client-server-api#server-side-key-backups), its claimed sender Curve25519 key belongs to such a device). Messages and encrypted state from unsigned devices MUST be rejected.2. **Room.** The `room_id` in the decrypted payload MUST equal the event's `room_id` (and MUST NOT be omitted).3. **Binding.** `content.binding` MUST be a string of at least 22 base64 characters (128 bits) and MUST equal `binding` inside the decrypted payload. When encrypting, a client MUST generate a fresh `binding` of at least 128 bits of cryptographically secure random data for every event, and include the same value in both places. Because `binding` survives redaction, the event's signature covers it. Without this check, a relaying server could move a ciphertext from one of the sender's events to another.4. **Replay.** A client MUST NOT accept two different events that decrypt using the same `(room_id, sender, session_id, index)` tuple. If it sees a second one, it MUST treat the second as failing these checks.5. **Sender timestamp.** Senders SHOULD include `sender_ts` (milliseconds since the Unix epoch) inside the encrypted payload. Clients SHOULD warn the user if the server's `origin_server_ts` differs from `sender_ts` by more than 5 minutes, detecting server-side backdating or forward-dating without weakening deniability.6. **Self-certifying room ID.** Clients SHOULD verify that the room's `t.room.create` event has `room_version: "13"` and hashes to the `room_id` (with `!` replacing `$`), preventing a hostile server from forging room creation or spoofing room creators.
The `binding` is random and reveals nothing about the content. It ties aciphertext to an event for the people in the room. It does not prove anythingto a third party, because anyone holding the Megolm session key could haveproduced a ciphertext with that binding, and the session key's link to thesender rests on Olm, which is deniable.
### Relations
[`t.relates_to`](/client-server-api#forming-relationships-between-events) iskept unencrypted so servers can aggregate relations, but in this room versionit is not signed. Senders MUST include an identical copy of `t.relates_to`inside the encrypted payload. Clients MUST use the copy from the decryptedpayload, and MUST ignore the relation if the two copies differ. Servers'aggregations (such as edit and thread summaries) are hints only, and clientsMUST check them against decrypted content before relying on them.
### Reasons for membership changes
In this room version, `t.room.member` events MUST NOT have a `reason` intheir `content`, and servers reject those that do. A reason stored in roomstate is plaintext, signed, and kept for as long as the membership lasts. Fora ban, that can be indefinitely. Clients that want to explain a kick or bansend an ordinary encrypted message to the room instead, which expires withretention like any other message.
### Encrypted state
Servers need some state to run a room. All other state is end-to-endencrypted, following the format of [MSC4362](https://github.com/matrix-org/matrix-spec-proposals/pull/4362).
**State that stays readable by servers:**[`t.room.create`](/client-server-api#lroomcreate),[`t.room.member`](/client-server-api#lroommember),[`t.room.join_rules`](/client-server-api#lroomjoin_rules),[`t.room.power_levels`](/client-server-api#lroompower_levels),[`t.room.third_party_invite`](/client-server-api#lroomthird_party_invite),[`t.room.history_visibility`](/client-server-api#lroomhistory_visibility),[`t.room.guest_access`](/client-server-api#lroomguest_access),[`t.room.encryption`](/client-server-api#lroomencryption),[`t.room.server_acl`](/client-server-api#lroomserver_acl),[`t.room.retention`](/client-server-api#lroomretention),[`t.room.tombstone`](/client-server-api#lroomtombstone), and`t.policy.rule.*` (moderation policy lists exist to be read by servers).
**Every other state event MUST be encrypted.** That includes the room's name,topic and avatar, pinned events and all custom state. Servers rejectunencrypted state of any other type.
An encrypted state event:
* has `type` `t.room.encrypted` and content like any other encrypted event, including `binding`;* has as its `state_key` the original type and state key packed as `{type}:{state_key}`, for example `t.room.name:` for a room name;* carries in its encrypted payload the `room_id`, the original `type`, `state_key` and `content`.
Clients MUST check, after decrypting, that the packed `state_key` splits atits first `:` into exactly the decrypted `type` and `state_key`, and MUSTignore the event otherwise. The other checks in[Message content is not signed](#message-content-is-not-signed) apply too.
Because new members only see history from when they joined, they can'tdecrypt state that was encrypted before. When someone joins, a client of amember allowed to send each piece of encrypted state SHOULD send it again, sothe new member receives the key for it. Clients MUST NOT share older messagesessions to achieve this.
{{% boxes/warning %}}Servers still see each encrypted state event's original **type** and **statekey**, because they're packed into the `state_key`. Only the content ishidden. Clients SHOULD NOT put anything sensitive in state keys, and statethat must stay readable (membership, above) remains signed and visible toservers. Display names and avatars in `t.room.member` are an example;clients SHOULD keep per-room profile details out of member events.{{% /boxes/warning %}}
Unlike message content, encrypted state content is signed and hashed in full,like all state. That makes its ciphertext provable, but not its plaintext:the Megolm session key's link to the sender rests on Olm, which is deniable.
### Inherited from version 12
* Room IDs no longer include a domain component and are instead a hash of the `t.room.create` event. See the [room ID grammar](/appendices#room-ids) for more information.
* "Room creators" are the `sender` of the `t.room.create` event *plus* any `additional_creators` from its `content`. Room creators have infinitely high power level and cannot be specified in the `t.room.power_levels` event, nor can they be changed after the room is created.
## Server implementation components
{{% boxes/warning %}}The information contained in this section is strictly for serverimplementors. Applications which use the Client-Server API are generallyunaffected by the intricacies contained here. The section aboveregarding client considerations is the resource that Client-Server APIuse cases should reference.{{% /boxes/warning %}}
Room version 13 is based upon room version 12 with the following considerations.
### Event format
The structure of events is unchanged from room version 12:
{{% rver-fragment name="v12-event-format" %}}
### Content hash
{{% added-in v=13 %}} For a **non-state event** (an event with no `state_key`),the [content hash](/server-server-api#calculating-the-content-hash-for-an-event)is calculated over the event *after* it has been put through the[redaction algorithm](#redactions), instead of over the full event. The stepsare otherwise the same: remove `unsigned`, `signatures` and `hashes`, encode asCanonical JSON, and hash with SHA-256.
For state events, the content hash is calculated over the full event, as inearlier room versions.
As a result, the [reference hash](/server-server-api#calculating-the-reference-hash-for-an-event),and therefore the event ID, and the event's signatures cover only theproperties of a non-state event that survive redaction. The rest of its`content` is not committed to by anything in the room.
Consequences for servers:
* When checking the content hash of a received non-state event, servers compute it over the redacted event. A hash mismatch therefore means the redacted properties were altered, and the event MUST be rejected. It never means "the server was sent a redacted copy".* Servers MUST NOT make any decision that affects room state, authorisation or soft failure depend on a property of a non-state event that does not survive redaction. Different servers may hold different content for the same event, and such decisions would make them disagree.* Servers MUST NOT add their own signatures, or any other proof of origin, to the unredacted content of a non-state event.
{{% boxes/rationale %}}Signatures are what turn a copy of a message into evidence. In earlier roomversions, a server's signature on an event covers a hash of its full content,and every later event commits to it again through `prev_events`. That chaincan be checked by anyone, indefinitely, using the servers' published keys.
In this room version, a copy of an event proves only metadata that the roomneeds to function: who sent an event of which type, and when. The content isprotected end-to-end by Megolm. Megolm's authenticity is visible only to theparticipants, because the link between a Megolm session and its sender restson Olm, and Olm messages could have been forged by their recipient.{{% /boxes/rationale %}}
### Redactions
{{% added-in v=13 %}} The redaction algorithm is the same as in room version 11,except that [`t.room.encrypted`](/client-server-api#lroomencrypted) allows key`binding`.
{{% rver-fragment name="v11-redactions" %}}
### Authorisation rules
Events must be signed by the server denoted by the `sender` property.
The types of state events that affect authorisation are:
- [`t.room.create`](/client-server-api#lroomcreate)- [`t.room.member`](/client-server-api#lroommember)- [`t.room.join_rules`](/client-server-api#lroomjoin_rules)- [`t.room.power_levels`](/client-server-api#lroompower_levels)- [`t.room.third_party_invite`](/client-server-api#lroomthird_party_invite)
{{% boxes/note %}}Power levels are inferred from defaults when not explicitly supplied.For example, mentions of the `sender`'s power level can also refer tothe default power level for users in the room.{{% /boxes/note %}}
{{% boxes/note %}}The power level of "room creators" is infinitely high.
Room creators include:* The user ID denoted by the `sender` of the `t.room.create` event in the room.* Any user IDs contained in the `additional_creators` array in `content` of the `t.room.create` event in the room, if `additional_creators` is present.
Room creators cannot be demoted to a lower power level, even through `t.room.power_levels`.This is reflected in rule 10.4 below.{{% /boxes/note %}}
{{% boxes/note %}}`t.room.redaction` events are subject to auth rules in the same way as any other event.In practice, that means they will normally be allowed by the auth rules, unless the`t.room.power_levels` event sets a power level requirement for `t.room.redaction`events via the `events` or `events_default` properties. In particular, the _redactlevel_ is **not** considered by the auth rules.
The ability to send a redaction event does not mean that the redaction itself shouldbe performed. Receiving servers must perform additional checks, as described inthe [Handling redactions](#handling-redactions) section.{{% /boxes/note %}}
{{% boxes/note %}}The `t.room.create` event MUST NOT be selected for `auth_events` on events. The`room_id` (being the `t.room.create` event's ID) implies this instead. This isreflected in a change to rule 3.2 below.{{% /boxes/note %}}
The rules are as follows:
1. If type is `t.room.create`: 1. If it has any `prev_events`, reject. 2. If the event has a `room_id`, reject.
**Note**: The room ID is the event ID of the event with sigil `!` instead of `$`. 3. If `content.room_version` is present and is not a recognised version, reject. 4. If `additional_creators` is present in `content` and is not an array of strings where each string passes the same [user ID](/appendices#user-identifiers) validation applied to `sender`, reject. 5. Otherwise, allow.2. If the event's `room_id` is not an event ID for an accepted (not rejected) `t.room.create` event, with the sigil `!` instead of `$`, reject.3. Considering the event's `auth_events`: 1. If there are duplicate entries for a given `type` and `state_key` pair, reject. 2. If there are entries whose `type` and `state_key` don't match those specified by the [auth events selection](/server-server-api#auth-events-selection) algorithm described in the server specification, reject.
**Note**: In this room version, `t.room.create` MUST NOT be selected. 3. If there are entries which were themselves rejected under the [checks performed on receipt of a PDU](/server-server-api/#checks-performed-on-receipt-of-a-pdu), reject. 5. If any event in `auth_events` has a `room_id` which does not match that of the event being authorised, reject.4. If the `content` of the `t.room.create` event in the room state has the property `t.federate` set to `false`, and the `sender` domain of the event does not match the `sender` domain of the create event, reject.5. If type is `t.room.member`: 1. If there is no `state_key` property, or no `membership` property in `content`, reject. {{% added-in v=13 %}} If `content` has a `reason` property, reject. 2. If `content` has a `join_authorised_via_users_server` key: 1. If the event is not validly signed by the homeserver of the user ID denoted by the key, reject. 3. If `membership` is `join`: 1. If the only previous event is an `t.room.create` and the `state_key` is the sender of the `t.room.create`, allow. 2. If the `sender` does not match `state_key`, reject. 3. If the `sender` is banned, reject. 4. If the `join_rule` is `invite` or `knock` then allow if membership state is `invite` or `join`. 5. If the `join_rule` is `restricted` or `knock_restricted`: 1. If membership state is `join` or `invite`, allow. 2. If the `join_authorised_via_users_server` key in `content` is not a user with sufficient permission to invite other users or is not a joined member of the room, reject. 3. Otherwise, allow. 6. If the `join_rule` is `public`, allow. 7. Otherwise, reject. 4. If `membership` is `invite`: 1. If `content` has a `third_party_invite` property: 1. If *target user* is banned, reject. 2. If `content.third_party_invite` does not have a `signed` property, reject. 3. If `signed` does not have `mxid` and `token` properties, reject. 4. If `mxid` does not match `state_key`, reject. 5. If there is no `t.room.third_party_invite` event in the current room state with `state_key` matching `token`, reject. 6. If `sender` does not match `sender` of the `t.room.third_party_invite`, reject. 7. If any signature in `signed` matches any public key in the `t.room.third_party_invite` event, allow. The public keys are in `content` of `t.room.third_party_invite` as: 1. A single public key in the `public_key` property. 2. A list of public keys in the `public_keys` property. 8. Otherwise, reject. 2. If the `sender`'s current membership state is not `join`, reject. 3. If *target user*'s current membership state is `join` or `ban`, reject. 4. If the `sender`'s power level is greater than or equal to the *invite level*, allow. 5. Otherwise, reject. 5. If `membership` is `leave`: 1. If the `sender` matches `state_key`, allow if and only if that user's current membership state is `invite`, `join`, or `knock`. 2. If the `sender`'s current membership state is not `join`, reject. 3. If the *target user*'s current membership state is `ban`, and the `sender`'s power level is less than the *ban level*, reject. 4. If the `sender`'s power level is greater than or equal to the *kick level*, and the *target user*'s power level is less than the `sender`'s power level, allow. 5. Otherwise, reject. 6. If `membership` is `ban`: 1. If the `sender`'s current membership state is not `join`, reject. 2. If the `sender`'s power level is greater than or equal to the *ban level*, and the *target user*'s power level is less than the `sender`'s power level, allow. 3. Otherwise, reject. 7. If `membership` is `knock`: 1. If the `join_rule` is anything other than `knock` or `knock_restricted`, reject. 2. If `sender` does not match `state_key`, reject. 3. If the `sender`'s current membership is not `ban`, `invite`, or `join`, allow. 4. Otherwise, reject. 8. Otherwise, the membership is unknown. Reject.6. If the `sender`'s current membership state is not `join`, reject.7. If type is `t.room.third_party_invite`: 1. Allow if and only if `sender`'s current power level is greater than or equal to the *invite level*.8. If the event type's *required power level* is greater than the `sender`'s power level, reject.9. If the event has a `state_key` that starts with an `@` and does not match the `sender`, reject.10. If type is `t.room.power_levels`: 1. If any of the properties `users_default`, `events_default`, `state_default`, `ban`, `redact`, `kick`, or `invite` in `content` are present and not an integer, reject. 2. If either of the properties `events` or `notifications` in `content` are present and not an object with values that are integers, reject. 3. If the `users` property in `content` is not an object with keys that are valid user IDs with values that are integers, reject. 4. If the `users` property in `content` contains the `sender` of the `t.room.create` event or any of the `additional_creators` array (if present) from the `content` of the `t.room.create` event, reject. 5. If there is no previous `t.room.power_levels` event in the room, allow. 6. For the properties `users_default`, `events_default`, `state_default`, `ban`, `redact`, `kick`, `invite` check if they were added, changed or removed. For each found alteration: 1. If the current value is higher than the `sender`'s current power level, reject. 2. If the new value is higher than the `sender`'s current power level, reject. 7. For each entry being changed in, or removed from, the `events` or `notifications` properties: 1. If the current value is greater than the `sender`'s current power level, reject. 8. For each entry being added to, or changed in, the `events` or `notifications` properties: 1. If the new value is greater than the `sender`'s current power level, reject. 9. For each entry being changed in, or removed from, the `users` property, other than the `sender`'s own entry: 1. If the current value is greater than or equal to the `sender`'s current power level, reject. 10. For each entry being added to, or changed in, the `users` property: 1. If the new value is greater than the `sender`'s current power level, reject. 10. Otherwise, allow.11. {{% added-in v=13 %}} If the event has no `state_key`, and its `type` is neither `t.room.encrypted` nor `t.room.redaction`, reject.12. {{% added-in v=13 %}} If the event has a `state_key`: 1. If `type` is `t.room.encrypted`: reject if the `state_key` contains no `:`, or if the part before the first `:` is one of the types listed in [Encrypted state](#encrypted-state) as staying readable. 2. Otherwise, reject unless `type` is one of those types.13. Otherwise, allow.
{{% boxes/note %}}Some consequences of these rules:
- Unless you are a member of the room, the only permitted operations (apart from the initial create/join) are: joining a public room; accepting or rejecting an invitation to a room.- To unban somebody, you must have power level greater than or equal to both the kick *and* ban levels, *and* greater than the target user's power level.{{% /boxes/note %}}
### State resolution
{{% boxes/note %}}This state resolution algorithm is largely the same as thealgorithm found in [room version 2](/rooms/v2) with the following modifications:
1. The *iterative auth checks algorithm* in the [Algorithm](#algorithm) subsection now starts with an *empty* state map instead of the unconflicted state map.
2. A new [definition](#definitions) for *conflicted state subgraph* has been added which describes events that are required to authorise events during iterative auth checks.
3. To ensure the new conflicted state subgraph is actually referenced, the definition for *full conflicted set* additionally includes the subgraph.{{% /boxes/note %}}
The room state *S′(E)* after an event *E* is defined in terms of theroom state *S(E)* before *E*, and depends on whether *E* is a stateevent or a message event:
- If *E* is a message event, then *S′(E)* = *S(E)*.- If *E* is a state event, then *S′(E)* is *S(E)*, except that its entry corresponding to the `event_type` and `state_key` of *E* is replaced by the `event_id` of *E*.
The room state *S(E)* before *E* is the *resolution* of the set ofstates {*S′(E*<sub>1</sub>*)*, *S′(E*<sub>2</sub>*)*, …}after the `prev_event`s {*E*<sub>1</sub>, *E*<sub>2</sub>, …} of *E*.The resolution of a set of states is given in the algorithm below.
#### Definitions
The state resolution algorithm for version 2 rooms uses the followingdefinitions, given the set of room states{*S*<sub>1</sub>, *S*<sub>2</sub>, …}:
**Power events.**A *power event* is a state event with type `t.room.power_levels` or`t.room.join_rules`, or a state event with type `t.room.member` wherethe `membership` is `leave` or `ban` and the `sender` does not match the`state_key`. The idea behind this is that power events are events thatmight remove someone's ability to do something in the room.
**Unconflicted state map and conflicted state set.**The keys of the state maps *S<sub>i</sub>* are 2-tuples of strings of the form*K* = `(event_type, state_key)`. The values *V* are state events.The key-value pairs (*K*, *V*) across all state maps *S<sub>i</sub>* can bedivided into two collections.If a given key *K* is present in every *S<sub>i</sub>* with the same value *V*in each state map, then the pair (*K*, *V*) belongs to the *unconflicted state map*.Otherwise, *V* belongs to the *conflicted state set*.
Note that the unconflicted state map only has one event for each key *K*,whereas the conflicted state set may contain multiple events with the same key.
**Auth chain.**The *auth chain* of an event *E* is the set containing all of *E*'s auth events,all of *their* auth events, and so on recursively, stretching back to thestart of the room. Put differently, these are the events reachable by walkingthe graph induced by an event's `auth_events` links.
**Auth difference.**The *auth difference* is calculated by first calculating the full authchain for each state *S*<sub>*i*</sub>, that is the union of the authchains for each event in *S*<sub>*i*</sub>, and then taking every eventthat doesn't appear in every auth chain. If *C*<sub>*i*</sub> is thefull auth chain of *S*<sub>*i*</sub>, then the auth difference is∪ *C*<sub>*i*</sub> − ∩ *C*<sub>*i*</sub>.
**Conflicted state subgraph.**Starting from an event in the *conflicted state set* and following `auth_events`edges may lead to another event in the conflicted state set. The union of allsuch paths between any pair of events in the conflicted state set (includingendpoints) forms a subgraph of the original `auth_event` graph, called the*conflicted state subgraph*.
**Full conflicted set.**The *full conflicted set* is the union of the conflicted state set, the conflictedstate subgraph, and the auth difference.
**Reverse topological power ordering.**The *reverse topological power ordering* of a set of events is thelexicographically smallest topological ordering based on the DAG formedby auth events. The reverse topological power ordering is ordered fromearliest event to latest. For comparing two topological orderings todetermine which is the lexicographically smallest, the followingcomparison relation on events is used: for events *x* and *y*,*x* < *y* if
1. *x*'s sender has *greater* power level than *y*'s sender, when looking at their respective `auth_event`s; or2. the senders have the same power level, but *x*'s `origin_server_ts` is *less* than *y*'s `origin_server_ts`; or3. the senders have the same power level and the events have the same `origin_server_ts`, but *x*'s `event_id` is *less* than *y*'s `event_id`.
The reverse topological power ordering can be found by sorting theevents using Kahn's algorithm for topological sorting, and at each stepselecting, among all the candidate vertices, the smallest vertex usingthe above comparison relation.
**Mainline ordering.**Let *P* = *P*<sub>0</sub> be an `t.room.power_levels` event.Starting with *i* = 0, repeatedly fetch *P*<sub>*i*+1</sub>, the`t.room.power_levels` event in the `auth_events` of *P<sub>i</sub>*.Increment *i* and repeat until *P<sub>i</sub>* has no `t.room.power_levels`event in its `auth_events`.The *mainline of P*<sub>0</sub> is the list of events [*P*<sub>0</sub> , *P*<sub>1</sub>, ... , *P<sub>n</sub>*],fetched in this way.
Let *e* = *e<sub>0</sub>* be another event (possibly another`t.room.power_levels` event). We can compute a similar list of events [*e*<sub>1</sub>, ..., *e<sub>m</sub>*],where *e*<sub>*j*+1</sub> is the `t.room.power_levels` event in the`auth_events` of *e<sub>j</sub>* and where *e<sub>m</sub>* has no`t.room.power_levels` event in its `auth_events`. (Note that the event westarted with, *e<sub>0</sub>*, is not included in this list. Also note that itmay be empty, because *e* may not cite an `t.room.power_levels` event in its`auth_events` at all.)
Now compare these two lists as follows.* Find the smallest index *j* ≥ 1 for which *e<sub>j</sub>* belongs to the mainline of *P*.* If such a *j* exists, then *e<sub>j</sub>* = *P<sub>i</sub>* for some unique index *i* ≥ 0. Otherwise set *i* = ∞, where ∞ is a sentinel value greater than any integer.* In both cases, the *mainline position* of *e* is *i*.
Given mainline positions calculated from *P*, the *mainline ordering based on* *P* of a set of events is the ordering,from smallest to largest, using the following comparison relation onevents: for events *x* and *y*, *x* < *y* if
1. the mainline position of *x* is **greater** than the mainline position of *y* (i.e. the auth chain of *x* is based on an earlier event in the mainline than *y*); or2. the mainline positions of the events are the same, but *x*'s `origin_server_ts` is *less* than *y*'s `origin_server_ts`; or3. the mainline positions of the events are the same and the events have the same `origin_server_ts`, but *x*'s `event_id` is *less* than *y*'s `event_id`.
**Iterative auth checks.**The *iterative auth checks algorithm* takes as input an initial roomstate and a sorted list of state events, and constructs a new room stateby iterating through the event list and applying the state event to theroom state if the state event is allowed by the [authorisationrules](/server-server-api#authorisation-rules).If the state event is not allowed by the authorisation rules, then theevent is ignored. If a `(event_type, state_key)` key that is requiredfor checking the authorisation rules is not present in the state, thenthe appropriate state event from the event's `auth_events` is used ifthe auth event is not rejected.
#### Algorithm
The *resolution* of a set of states is obtained as follows:
1. Select the set *X* of all *power events* that appear in the *full conflicted set*. For each such power event *P*, enlarge *X* by adding the events in the auth chain of *P* which also belong to the full conflicted set. Sort *X* into a list using the *reverse topological power ordering*.2. Apply the *iterative auth checks algorithm*, starting from an *empty* state map, to the list of events from the previous step to get a partially resolved state.3. Take all remaining events that weren't picked in step 1 and order them by the mainline ordering based on the power level in the partially resolved state obtained in step 2.4. Apply the *iterative auth checks algorithm* on the partial resolved state and the list of events from the previous step.5. Update the result by replacing any event with the event with the same key from the *unconflicted state map*, if such an event exists, to get the final resolved state.
#### Rejected events
Events that have been rejected due to failing auth based on the state atthe event (rather than based on their auth chain) are handled as usualby the algorithm, unless otherwise specified.
Note that no events rejected due to failure to auth against their authchain should appear in the process, as they should not appear in state(the algorithm only uses events that appear in either the state sets orin the auth chain of the events in the state sets).
{{% boxes/rationale %}}This helps ensure that different servers' view of state is more likelyto converge, since rejection state of an event may be different. Thiscan happen if a third server gives an incorrect version of the statewhen a server joins a room via it (either due to being faulty ormalicious). Convergence of state is a desirable property as it ensuresthat all users in the room have a (mostly) consistent view of the stateof the room. If the view of the state on different servers diverges itcan lead to bifurcation of the room due to e.g. servers disagreeing onwho is in the room.
Intuitively, using rejected events feels dangerous, however:
1. Servers cannot arbitrarily make up state, since they still need to pass the auth checks based on the event's auth chain (e.g. they can't grant themselves power levels if they didn't have them before).2. For a previously rejected event to pass auth there must be a set of state that allows said event. A malicious server could therefore produce a fork where it claims the state is that particular set of state, duplicate the rejected event to point to that fork, and send the event. The duplicated event would then pass the auth checks. Ignoring rejected events would therefore not eliminate any potential attack vectors.{{% /boxes/rationale %}}
Rejected auth events are deliberately excluded from use in the iterativeauth checks, as auth events aren't re-authed (although non-auth eventsare) during the iterative auth checks.
## Unchanged from v12
The following sections have not been modified since v12, but are included forcompleteness.
### Handling redactions
{{% rver-fragment name="v3-handling-redactions" %}}
### Event IDs
{{% rver-fragment name="v4-event-ids" %}}
### Canonical JSON
{{% rver-fragment name="v6-canonical-json" %}}
### Signing key validity period
{{% rver-fragment name="v5-signing-requirements" %}}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768---title: Room Version 2type: docsweight: 20version: 2---
This room version builds on [version 1](/rooms/v1) with an improvedstate resolution algorithm.
## Client considerations
There are no client considerations introduced in this room version. Clientswhich implement the redaction algorithm locally should refer to the[redactions](#redactions) section below for a full overview of the algorithm.
## Server implementation components
{{% boxes/warning %}}The information contained in this section is strictly for serverimplementors. Applications which use the Client-Server API are generallyunaffected by the details contained here, and can safely ignore theirpresence.{{% /boxes/warning %}}
Room version 2 uses the base components of [room version 1](/rooms/v1),changing only the state resolution algorithm.
### State resolution
{{% added-in v=2 %}}
{{% rver-fragment name="v2-state-res" %}}
## Unchanged from v1
The following sections have not been modified since v1, but are included forcompleteness.
### Redactions
{{% rver-fragment name="v1-redactions" %}}
### Event IDs
{{% rver-fragment name="v1-event-ids" %}}
### Event format
Events in rooms of this version have the following structure:
{{% definition path="api/server-server/definitions/pdu_v1" %}}
#### Deprecated event content schemas
{{% rver-fragment name="v1-deprecated-formatting-off-spec" %}}
{{% rver-fragment name="v1-stringy-power-levels" %}}
{{% rver-fragment name="v1-floaty-power-levels" %}}
### Authorisation rules
{{% rver-fragment name="v1-auth-rules" %}}
### Canonical JSON
{{% rver-fragment name="v1-canonical-json" %}}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123---title: Room Version 3type: docsweight: 30version: 3---
This room version builds on [version 2](/rooms/v2) with an improved eventformat.
## Client considerations
This room version changes the format for event IDs sent to clients.Clients should be aware that these event IDs may contain slashes andother potentially problematic characters. Clients should be treatingevent IDs as opaque identifiers and should not be attempting to parsethem into a usable form, just like with other room versions.
Clients should expect to see event IDs changed from the format of`$randomstring:example.org` to something like`$acR1l0raoZnm60CBwAVgqbZqoO/mYU81xysh1u7XcJk` (note the lack of domainand the potentially problematic slash).
Though unchanged in this room version, clients which implement theredaction algorithm locally should refer to the [redactions](#redactions)section below for a full overview.
## Server implementation components
{{% boxes/warning %}}The information contained in this section is strictly for serverimplementors. Applications which use the Client-Server API are generallyunaffected by the intricacies contained here. The section aboveregarding client considerations is the resource that Client-Server APIuse cases should reference.{{% /boxes/warning %}}
Room version 3 uses the event format described here in addition toall the remaining behaviour described by [room version 2](/rooms/v2).
### Handling redactions
{{% rver-fragment name="v3-handling-redactions" %}}
### Event IDs
{{% boxes/rationale %}}In other room versions (namely version 1 and 2) the event ID is adistinct field from the remainder of the event, which must be tracked assuch. This leads to complications where servers receive multiple eventswith the same ID in either the same or different rooms where the servercannot easily keep track of which event it should be using. By removingthe use of a dedicated event ID, servers are required to track thehashes on an event to determine its ID.{{% /boxes/rationale %}}
{{% added-in v=3 %}} The event ID is the [referencehash](/server-server-api#calculating-the-reference-hash-for-an-event) ofthe event encoded using [UnpaddedBase64](/appendices#unpadded-base64), prefixed with `$`. Aresulting event ID using this approach should look similar to`$CD66HAED5npg6074c6pDtLKalHjVfYb2q4Q3LZgrW6o`.
### Event format
When events are sent over federation, the `event_id` field is no longerincluded. A server receiving an event should compute the relevantevent ID for itself.
Additionally, the format of the `auth_events` and `prev_events` fields arechanged: instead of lists of `(event_id, hash)` pairs, they are now plain listsof event IDs.
These changes to the format of an event mean that servers must be aware of theversion of the room containing an incoming event, so that the event can becorrectly parsed and handled. This is facilitated via changes to theserver-server API (such as the inclusion of `room_version` in the response to[`GET /_taper/federation/v1/make_join/{roomId}/{userId}`](/server-server-api/#get_taperfederationv1make_joinroomiduserid).)
The complete structure of a event in a v3 room is shown below.
{{% definition path="api/server-server/definitions/pdu_v3" %}}
#### Deprecated event content schemas
{{% rver-fragment name="v1-deprecated-formatting-off-spec" %}}
{{% rver-fragment name="v1-stringy-power-levels" %}}
{{% rver-fragment name="v1-floaty-power-levels" %}}
### Authorisation rules
{{% boxes/note %}}{{% added-in v=3 %}} `t.room.redaction` events are subject to auth rules inthe same way as any other event. In practice, that means they will normally be allowedby the auth rules, unless the `t.room.power_levels` event sets a power level requirementfor `t.room.redaction`events via the `events` or `events_default` properties. Inparticular, the _redact level_ is **not** considered by the auth rules.
The ability to send a redaction event does not mean that the redaction itself shouldbe performed. Receiving servers must perform additional checks, as described inthe [Handling Redactions](#handling-redactions) section.{{% /boxes/note %}}
{{% rver-fragment name="v3-auth-rules" %}}
## Unchanged from v2
The following sections have not been modified since v2, but are included forcompleteness.
### Redactions
{{% rver-fragment name="v1-redactions" %}}
### State resolution
{{% rver-fragment name="v2-state-res" %}}
### Canonical JSON
{{% rver-fragment name="v1-canonical-json" %}}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091---title: Room Version 4type: docsweight: 40version: 4---
This room version builds on [version 3](/rooms/v3) using a differentencoding for event IDs.
## Client considerations
This room version changes the format form event IDs sent to clients.Clients should already be treating event IDs as opaque identifiers, andshould not be concerned with the format of them. Clients should stillencode the event ID when including it in a request path.
Clients should expect to see event IDs changed from the format of`$randomstring:example.org` to something like`$Rqnc-F-dvnEYJTyHq_iKxU2bZ1CI92-kuZq3a5lr5Zg` (note the lack ofdomain).
Though unchanged in this room version, clients which implement theredaction algorithm locally should refer to the [redactions](#redactions)section below for a full overview.
## Server implementation components
{{% boxes/warning %}}The information contained in this section is strictly for serverimplementors. Applications which use the Client-Server API are generallyunaffected by the intricacies contained here. The section aboveregarding client considerations is the resource that Client-Server APIuse cases should reference.{{% /boxes/warning %}}
Room version 4 uses the same algorithms defined in [room version3](/rooms/v3), however using URL-safe base64 to generate the event ID.
### Event IDs
{{% boxes/rationale %}}Room version 3 generated event IDs that were difficult for clientimplementations which were not encoding the event ID to function inthose rooms. It additionally raised concern due to the `/` characterbeing interpreted differently by some reverse proxy software, andgenerally made administration harder.{{% /boxes/rationale %}}
{{% rver-fragment name="v4-event-ids" %}}
## Unchanged from v3
The following sections have not been modified since v3, but are included forcompleteness.
### Redactions
{{% rver-fragment name="v1-redactions" %}}
### Handling redactions
{{% rver-fragment name="v3-handling-redactions" %}}
### Event format
The event format is the same as [room version 3](/rooms/v3#event-format),however the event IDs in the following example are updated to reflectthe changes in this room version.
{{% rver-fragment name="v4-event-format" %}}
#### Deprecated event content schemas
{{% rver-fragment name="v1-deprecated-formatting-off-spec" %}}
{{% rver-fragment name="v1-stringy-power-levels" %}}
{{% rver-fragment name="v1-floaty-power-levels" %}}
### Authorisation rules
{{% rver-fragment name="v3-auth-rules" %}}
### State resolution
{{% rver-fragment name="v2-state-res" %}}
### Canonical JSON
{{% rver-fragment name="v1-canonical-json" %}}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273---title: Room Version 5type: docsweight: 50version: 5---
This room version builds on [version 4](/rooms/v4) while enforcing signingkey validity periods for events.
## Client considerations
There are no client considerations introduced in this room version. Clientswhich implement the redaction algorithm locally should refer to the[redactions](#redactions) section below for a full overview of the algorithm.
## Server implementation components
{{% boxes/warning %}}The information contained in this section is strictly for serverimplementors. Applications which use the Client-Server API are generallyunaffected by the intricacies contained here. The section aboveregarding client considerations is the resource that Client-Server APIuse cases should reference.{{% /boxes/warning %}}
Room version 5 uses the same algorithms defined in [room version4](/rooms/v4), ensuring that signing key validity is respected.
### Signing key validity period
{{% rver-fragment name="v5-signing-requirements" %}}
## Unchanged from v4
The following sections have not been modified since v4, but are included forcompleteness.
### Redactions
{{% rver-fragment name="v1-redactions" %}}
### Handling redactions
{{% rver-fragment name="v3-handling-redactions" %}}
### Event IDs
{{% rver-fragment name="v4-event-ids" %}}
### Event format
{{% rver-fragment name="v4-event-format" %}}
#### Deprecated event content schemas
{{% rver-fragment name="v1-deprecated-formatting-off-spec" %}}
{{% rver-fragment name="v1-stringy-power-levels" %}}
{{% rver-fragment name="v1-floaty-power-levels" %}}
### Authorisation rules
{{% rver-fragment name="v3-auth-rules" %}}
### State resolution
{{% rver-fragment name="v2-state-res" %}}
### Canonical JSON
{{% rver-fragment name="v1-canonical-json" %}}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256---title: Room Version 6type: docsweight: 60version: 6---
This room version builds on [version 5](/rooms/v5) while changing variousauthorisation rules performed on events.
## Client considerations
There are no client considerations introduced in this room version. Clientswhich implement the redaction algorithm locally should refer to the[redactions](#redactions) section below for a full overview of the algorithm.
### Redactions
{{% added-in v=6 %}} All significant meaning for `t.room.aliases`has been removed from the redaction algorithm. The remaining rules arethe same as past room versions.
{{% rver-fragment name="v6-redactions" %}}
## Server implementation components
{{% boxes/warning %}}The information contained in this section is strictly for serverimplementors. Applications which use the Client-Server API are generallyunaffected by the intricacies contained here. The section aboveregarding client considerations is the resource that Client-Server APIuse cases should reference.{{% /boxes/warning %}}
Room version 6 makes the following alterations to algorithms describedin [room version 5](/rooms/v5).
### Redactions
[See above](#redactions).
### Event format
{{% added-in v=6 %}} Through enforcement of [Canonical JSON](#canonical-json),the `depth` limit has been reduced in this room version, and numeric values mayno longer be formatted as floats.
{{% rver-fragment name="v6-event-format" %}}
### Authorisation rules
{{% added-in v=6 %}} Rule 4, which related specifically to eventsof type `t.room.aliases`, is removed. `t.room.aliases` events must still passauthorisation checks relating to state events.
{{% added-in v=6 %}} Additionally, the authorisation rules for events oftype `t.room.power_levels` now include a `notifications` property under`content`. This updates rules 10.4 and 10.5 (now 9.4 and 9.5), which checkedthe `events` property.
Events must be signed by the server denoted by the `sender` property.
The types of state events that affect authorisation are:
- [`t.room.create`](/client-server-api#lroomcreate)- [`t.room.member`](/client-server-api#lroommember)- [`t.room.join_rules`](/client-server-api#lroomjoin_rules)- [`t.room.power_levels`](/client-server-api#lroompower_levels)- [`t.room.third_party_invite`](/client-server-api#lroomthird_party_invite)
{{% boxes/note %}}Power levels are inferred from defaults when not explicitly supplied.For example, mentions of the `sender`'s power level can also refer tothe default power level for users in the room.{{% /boxes/note %}}
{{% boxes/note %}}`t.room.redaction` events are subject to auth rules in the same way as any other event.In practice, that means they will normally be allowed by the auth rules, unless the`t.room.power_levels` event sets a power level requirement for `t.room.redaction`events via the `events` or `events_default` properties. In particular, the _redactlevel_ is **not** considered by the auth rules.
The ability to send a redaction event does not mean that the redaction itself shouldbe performed. Receiving servers must perform additional checks, as described inthe [Handling Redactions](#handling-redactions) section.{{% /boxes/note %}}
The rules are as follows:
1. If type is `t.room.create`: 1. If it has any `prev_events`, reject. 2. If the domain of the `room_id` does not match the domain of the `sender`, reject. 3. If `content.room_version` is present and is not a recognised version, reject. 4. If `content` has no `creator` property, reject. 5. Otherwise, allow.2. Considering the event's `auth_events`: 1. If there are duplicate entries for a given `type` and `state_key` pair, reject. 2. If there are entries whose `type` and `state_key` don't match those specified by the [auth events selection](/server-server-api#auth-events-selection) algorithm described in the server specification, reject.
**Note**: This room version requires an `t.room.create` event to be selected. 3. If there are entries which were themselves rejected under the [checks performed on receipt of a PDU](/server-server-api/#checks-performed-on-receipt-of-a-pdu), reject. 4. If there is no `t.room.create` event among the entries, reject. 5. If any event in `auth_events` has a `room_id` which does not match that of the event being authorised, reject.3. If the `content` of the `t.room.create` event in the room state has the property `t.federate` set to `false`, and the `sender` domain of the event does not match the `sender` domain of the create event, reject.4. If type is `t.room.member`: 1. If there is no `state_key` property, or no `membership` property in `content`, reject. 2. If `membership` is `join`: 1. If the only previous event is an `t.room.create` and the `state_key` is the creator, allow. 2. If the `sender` does not match `state_key`, reject. 3. If the `sender` is banned, reject. 4. If the `join_rule` is `invite` then allow if membership state is `invite` or `join`. 5. If the `join_rule` is `public`, allow. 6. Otherwise, reject. 3. If `membership` is `invite`: 1. If `content` has a `third_party_invite` property: 1. If *target user* is banned, reject. 2. If `content.third_party_invite` does not have a `signed` property, reject. 3. If `signed` does not have `mxid` and `token` properties, reject. 4. If `mxid` does not match `state_key`, reject. 5. If there is no `t.room.third_party_invite` event in the current room state with `state_key` matching `token`, reject. 6. If `sender` does not match `sender` of the `t.room.third_party_invite`, reject. 7. If any signature in `signed` matches any public key in the `t.room.third_party_invite` event, allow. The public keys are in `content` of `t.room.third_party_invite` as: 1. A single public key in the `public_key` property. 2. A list of public keys in the `public_keys` property. 8. Otherwise, reject. 2. If the `sender`'s current membership state is not `join`, reject. 3. If *target user*'s current membership state is `join` or `ban`, reject. 4. If the `sender`'s power level is greater than or equal to the *invite level*, allow. 5. Otherwise, reject. 4. If `membership` is `leave`: 1. If the `sender` matches `state_key`, allow if and only if that user's current membership state is `invite` or `join`. 2. If the `sender`'s current membership state is not `join`, reject. 3. If the *target user*'s current membership state is `ban`, and the `sender`'s power level is less than the *ban level*, reject. 4. If the `sender`'s power level is greater than or equal to the *kick level*, and the *target user*'s power level is less than the `sender`'s power level, allow. 5. Otherwise, reject. 5. If `membership` is `ban`: 1. If the `sender`'s current membership state is not `join`, reject. 2. If the `sender`'s power level is greater than or equal to the *ban level*, and the *target user*'s power level is less than the `sender`'s power level, allow. 3. Otherwise, reject. 6. Otherwise, the membership is unknown. Reject.5. If the `sender`'s current membership state is not `join`, reject.6. If type is `t.room.third_party_invite`: 1. Allow if and only if `sender`'s current power level is greater than or equal to the *invite level*.7. If the event type's *required power level* is greater than the `sender`'s power level, reject.8. If the event has a `state_key` that starts with an `@` and does not match the `sender`, reject.9. If type is `t.room.power_levels`: 1. If the `users` property in `content` is not an object with keys that are valid user IDs with values that are integers (or a string that is an integer), reject. 2. If there is no previous `t.room.power_levels` event in the room, allow. 3. For the properties `users_default`, `events_default`, `state_default`, `ban`, `redact`, `kick`, `invite` check if they were added, changed or removed. For each found alteration: 1. If the current value is higher than the `sender`'s current power level, reject. 2. If the new value is higher than the `sender`'s current power level, reject. 4. {{% changed-in v=6 %}} For each entry being changed in, or removed from, the `events` or `notifications` properties: 1. If the current value is greater than the `sender`'s current power level, reject. 5. {{% changed-in v=6 %}} For each entry being added to, or changed in, the `events` or `notifications` properties: 1. If the new value is greater than the `sender`'s current power level, reject. 6. For each entry being changed in, or removed from, the `users` property, other than the `sender`'s own entry: 1. If the current value is greater than or equal to the `sender`'s current power level, reject. 7. For each entry being added to, or changed in, the `users` property: 1. If the new value is greater than the `sender`'s current power level, reject. 8. Otherwise, allow.10. Otherwise, allow.
{{% boxes/note %}}Some consequences of these rules:
- Unless you are a member of the room, the only permitted operations (apart from the initial create/join) are: joining a public room; accepting or rejecting an invitation to a room.- To unban somebody, you must have power level greater than or equal to both the kick *and* ban levels, *and* greater than the target user's power level.{{% /boxes/note %}}
### Canonical JSON
{{% rver-fragment name="v6-canonical-json" %}}
## Unchanged from v5
The following sections have not been modified since v5, but are included forcompleteness.
### Handling redactions
{{% rver-fragment name="v3-handling-redactions" %}}
### Event IDs
{{% rver-fragment name="v4-event-ids" %}}
#### Deprecated event content schemas
{{% rver-fragment name="v1-deprecated-formatting-off-spec" %}}
{{% rver-fragment name="v1-stringy-power-levels" %}}
### State resolution
{{% rver-fragment name="v2-state-res" %}}
### Signing key validity period
{{% rver-fragment name="v5-signing-requirements" %}}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250---title: Room Version 7type: docsweight: 70version: 7---
This room version builds on [version 6](/rooms/v6) to introduce knockingas a possible join rule and membership state.
## Client considerations
This is the first room version to support knocking completely. As such,users will not be able to knock on rooms which are not based off v7.
Though unchanged in this room version, clients which implement theredaction algorithm locally should refer to the [redactions](#redactions)section below for a full overview.
## Server implementation components
{{% boxes/warning %}}The information contained in this section is strictly for serverimplementors. Applications which use the Client-Server API are generallyunaffected by the intricacies contained here. The section aboveregarding client considerations is the resource that Client-Server APIuse cases should reference.{{% /boxes/warning %}}
Room version 7 adds new authorisation rules for events to support knocking.[Room version 6](/rooms/v6) has details of other authorisation rule changes,as do the versions v6 is based upon.
### Authorisation rules
{{% added-in v=7 %}} For checks performed upon `t.room.member` events, anew point for `membership=knock` is added.
Events must be signed by the server denoted by the `sender` property.
The types of state events that affect authorisation are:
- [`t.room.create`](/client-server-api#lroomcreate)- [`t.room.member`](/client-server-api#lroommember)- [`t.room.join_rules`](/client-server-api#lroomjoin_rules)- [`t.room.power_levels`](/client-server-api#lroompower_levels)- [`t.room.third_party_invite`](/client-server-api#lroomthird_party_invite)
{{% boxes/note %}}Power levels are inferred from defaults when not explicitly supplied.For example, mentions of the `sender`'s power level can also refer tothe default power level for users in the room.{{% /boxes/note %}}
{{% boxes/note %}}`t.room.redaction` events are subject to auth rules in the same way as any other event.In practice, that means they will normally be allowed by the auth rules, unless the`t.room.power_levels` event sets a power level requirement for `t.room.redaction`events via the `events` or `events_default` properties. In particular, the _redactlevel_ is **not** considered by the auth rules.
The ability to send a redaction event does not mean that the redaction itself shouldbe performed. Receiving servers must perform additional checks, as described inthe [Handling redactions](#handling-redactions) section.{{% /boxes/note %}}
The rules are as follows:
1. If type is `t.room.create`: 1. If it has any `prev_events`, reject. 2. If the domain of the `room_id` does not match the domain of the `sender`, reject. 3. If `content.room_version` is present and is not a recognised version, reject. 4. If `content` has no `creator` property, reject. 5. Otherwise, allow.2. Considering the event's `auth_events`: 1. If there are duplicate entries for a given `type` and `state_key` pair, reject. 2. If there are entries whose `type` and `state_key` don't match those specified by the [auth events selection](/server-server-api#auth-events-selection) algorithm described in the server specification, reject.
**Note**: This room version requires an `t.room.create` event to be selected. 3. If there are entries which were themselves rejected under the [checks performed on receipt of a PDU](/server-server-api/#checks-performed-on-receipt-of-a-pdu), reject. 4. If there is no `t.room.create` event among the entries, reject. 5. If any event in `auth_events` has a `room_id` which does not match that of the event being authorised, reject.3. If the `content` of the `t.room.create` event in the room state has the property `t.federate` set to `false`, and the `sender` domain of the event does not match the `sender` domain of the create event, reject.4. If type is `t.room.member`: 1. If there is no `state_key` property, or no `membership` property in `content`, reject. 2. If `membership` is `join`: 1. If the only previous event is an `t.room.create` and the `state_key` is the creator, allow. 2. If the `sender` does not match `state_key`, reject. 3. If the `sender` is banned, reject. 4. {{% changed-in v=7 %}} If the `join_rule` is `invite` or `knock` then allow if membership state is `invite` or `join`. 5. If the `join_rule` is `public`, allow. 6. Otherwise, reject. 3. If `membership` is `invite`: 1. If `content` has `third_party_invite` property: 1. If *target user* is banned, reject. 2. If `content.third_party_invite` does not have a `signed` property, reject. 3. If `signed` does not have `mxid` and `token` properties, reject. 4. If `mxid` does not match `state_key`, reject. 5. If there is no `t.room.third_party_invite` event in the current room state with `state_key` matching `token`, reject. 6. If `sender` does not match `sender` of the `t.room.third_party_invite`, reject. 7. If any signature in `signed` matches any public key in the `t.room.third_party_invite` event, allow. The public keys are in `content` of `t.room.third_party_invite` as: 1. A single public key in the `public_key` property. 2. A list of public keys in the `public_keys` property. 8. Otherwise, reject. 2. If the `sender`'s current membership state is not `join`, reject. 3. If *target user*'s current membership state is `join` or `ban`, reject. 4. If the `sender`'s power level is greater than or equal to the *invite level*, allow. 5. Otherwise, reject. 4. If `membership` is `leave`: 1. {{% changed-in v=7 %}} If the `sender` matches `state_key`, allow if and only if that user's current membership state is `invite`, `join`, or `knock`. 2. If the `sender`'s current membership state is not `join`, reject. 3. If the *target user*'s current membership state is `ban`, and the `sender`'s power level is less than the *ban level*, reject. 4. If the `sender`'s power level is greater than or equal to the *kick level*, and the *target user*'s power level is less than the `sender`'s power level, allow. 5. Otherwise, reject. 5. If `membership` is `ban`: 1. If the `sender`'s current membership state is not `join`, reject. 2. If the `sender`'s power level is greater than or equal to the *ban level*, and the *target user*'s power level is less than the `sender`'s power level, allow. 3. Otherwise, reject. 6. {{% added-in v=7 %}} If `membership` is `knock`: 1. If the `join_rule` is anything other than `knock`, reject. 2. If `sender` does not match `state_key`, reject. 3. If the `sender`'s current membership is not `ban`, `invite`, or `join`, allow. 4. Otherwise, reject. 7. Otherwise, the membership is unknown. Reject.5. If the `sender`'s current membership state is not `join`, reject.6. If type is `t.room.third_party_invite`: 1. Allow if and only if `sender`'s current power level is greater than or equal to the *invite level*.7. If the event type's *required power level* is greater than the `sender`'s power level, reject.8. If the event has a `state_key` that starts with an `@` and does not match the `sender`, reject.9. If type is `t.room.power_levels`: 1. If the `users` property in `content` is not an object with keys that are valid user IDs with values that are integers (or a string that is an integer), reject. 2. If there is no previous `t.room.power_levels` event in the room, allow. 3. For the properties `users_default`, `events_default`, `state_default`, `ban`, `redact`, `kick`, `invite` check if they were added, changed or removed. For each found alteration: 1. If the current value is higher than the `sender`'s current power level, reject. 2. If the new value is higher than the `sender`'s current power level, reject. 4. For each entry being changed in, or removed from, the `events` or `notifications` properties: 1. If the current value is greater than the `sender`'s current power level, reject. 5. For each entry being added to, or changed in, the `events` or `notifications` properties: 1. If the new value is greater than the `sender`'s current power level, reject. 6. For each entry being changed in, or removed from, the `users` property, other than the `sender`'s own entry: 1. If the current value is greater than or equal to the `sender`'s current power level, reject. 7. For each entry being added to, or changed in, the `users` property: 1. If the new value is greater than the `sender`'s current power level, reject. 8. Otherwise, allow..10. Otherwise, allow.
{{% boxes/note %}}Some consequences of these rules:
- Unless you are a member of the room, the only permitted operations (apart from the initial create/join) are: joining a public room; accepting or rejecting an invitation to a room.- To unban somebody, you must have power level greater than or equal to both the kick *and* ban levels, *and* greater than the target user's power level.{{% /boxes/note %}}
## Unchanged from v6
The following sections have not been modified since v6, but are included forcompleteness.
### Redactions
{{% rver-fragment name="v6-redactions" %}}
### Handling redactions
{{% rver-fragment name="v3-handling-redactions" %}}
### Event IDs
{{% rver-fragment name="v4-event-ids" %}}
### Event format
{{% rver-fragment name="v6-event-format" %}}
#### Deprecated event content schemas
{{% rver-fragment name="v1-deprecated-formatting-off-spec" %}}
{{% rver-fragment name="v1-stringy-power-levels" %}}
### State resolution
{{% rver-fragment name="v2-state-res" %}}
### Canonical JSON
{{% rver-fragment name="v6-canonical-json" %}}
### Signing key validity period
{{% rver-fragment name="v5-signing-requirements" %}}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130---title: Room Version 8type: docsweight: 80version: 8---
This room version builds on [version 7](/rooms/v7) to introduce a newjoin rule that allows members to join the room based on membership inanother room.
{{% boxes/warning %}}This room version is known to have issues relating to redactions of memberjoin events. [Room version 9](/rooms/v9) should be preferred over v8 whencreating rooms.{{% /boxes/warning %}}
## Client considerations
Clients are encouraged to expose the option for the join rule in theiruser interface for supported room versions.
The new join rule, `restricted`, is described in the[Client-Server API](/client-server-api/#restricted-rooms).
Clients which implement the redaction algorithm locally should refer to the[redactions](#redactions) section below for a full overview.
### Redactions
{{% added-in v=8 %}} `t.room.join_rules` events now keep `allow` in addition to otherkeys in `content` when being redacted.
{{% boxes/warning %}}[Room version 9](/rooms/v9) adds additional cases of protected properties for behaviourrelated to restricted rooms (the functionality introduced in v8). v9 is preferred overv8 when creating new rooms.{{% /boxes/warning %}}
The full redaction algorithm follows.
Upon receipt of a redaction event, the server must strip off any keysnot in the following list:
- `event_id`- `type`- `room_id`- `sender`- `state_key`- `content`- `hashes`- `signatures`- `depth`- `prev_events`- `prev_state`- `auth_events`- `origin`- `origin_server_ts`- `membership`
The content object must also be stripped of all keys, unless it is oneof one of the following event types:
- `t.room.member` allows key `membership`.- `t.room.create` allows key `creator`.- `t.room.join_rules` allows keys `join_rule`, `allow`.- `t.room.power_levels` allows keys `ban`, `events`, `events_default`, `kick`, `redact`, `state_default`, `users`, `users_default`.- `t.room.history_visibility` allows key `history_visibility`.
## Server implementation components
{{% boxes/warning %}}The information contained in this section is strictly for serverimplementors. Applications which use the Client-Server API are generallyunaffected by the intricacies contained here. The section aboveregarding client considerations is the resource that Client-Server APIuse cases should reference.{{% /boxes/warning %}}
Room version 8 adds a new join rule to allow members of a room to join anotherroom without invite. Otherwise, the room version inherits all properties of[Room version 7](/rooms/v7).
### Authorisation rules
{{% added-in v=8 %}} For checks performed upon `t.room.member` events, newpoints for handling `content.join_authorised_via_users_server` are added (Rule 4.2and 4.3.5).
{{% rver-fragment name="v8-auth-rules" %}}
### Redactions
[See above](#redactions).
## Unchanged from v7
The following sections have not been modified since v7, but are included forcompleteness.
### Handling redactions
{{% rver-fragment name="v3-handling-redactions" %}}
### Event IDs
{{% rver-fragment name="v4-event-ids" %}}
### Event format
{{% rver-fragment name="v6-event-format" %}}
#### Deprecated event content schemas
{{% rver-fragment name="v1-deprecated-formatting-off-spec" %}}
{{% rver-fragment name="v1-stringy-power-levels" %}}
### State resolution
{{% rver-fragment name="v2-state-res" %}}
### Canonical JSON
{{% rver-fragment name="v6-canonical-json" %}}
### Signing key validity period
{{% rver-fragment name="v5-signing-requirements" %}}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899---title: Room Version 9type: docsweight: 90version: 9---
This room version builds on [version 8](/rooms/v8) to add additional redactionrules that were unintentionally missed when incorporating v8.
## Client considerations
See [room version 8](/rooms/v8) for specific details regarding the addition ofrestricted rooms.
Clients which implement the redaction algorithm locally should refer to the[redactions](#redactions) section below for a full overview.
### Redactions
{{% added-in v=9 %}} [`t.room.member`](/client-server-api#lroommember) eventsnow keep `join_authorised_via_users_server` in addition to other keys in `content`when being redacted.
{{% boxes/rationale %}}Without the `join_authorised_via_users_server` property, redacted join eventscan become invalid when verifying the auth chain of a given event, thus creatinga split-brain scenario where the user is able to speak from one server'sperspective but most others will continually reject their events.
This can theoretically be worked around with a rejoin to the room, being carefulnot to use the faulty events as `prev_events`, though instead it is encouragedto use v9 rooms over v8 rooms to outright avoid the situation.
[Issue #3373](https://github.com/matrix-org/matrix-doc/issues/3373) has furtherinformation.{{% /boxes/rationale %}}
The full redaction algorithm follows.
{{% rver-fragment name="v9-redactions" %}}
## Server implementation components
{{% boxes/warning %}}The information contained in this section is strictly for serverimplementors. Applications which use the Client-Server API are generallyunaffected by the intricacies contained here. The section aboveregarding client considerations is the resource that Client-Server APIuse cases should reference.{{% /boxes/warning %}}
Room version 8 added a new `restricted` join rule to allow members of a roomto join another room without invite. Room version 9 is based upon v8 with thefollowing considerations.
### Redactions
[See above](#redactions).
## Unchanged from v8
The following sections have not been modified since v8, but are included forcompleteness.
### Handling redactions
{{% rver-fragment name="v3-handling-redactions" %}}
### Event IDs
{{% rver-fragment name="v4-event-ids" %}}
### Event format
{{% rver-fragment name="v6-event-format" %}}
#### Deprecated event content schemas
{{% rver-fragment name="v1-deprecated-formatting-off-spec" %}}
{{% rver-fragment name="v1-stringy-power-levels" %}}
### Authorisation rules
{{% rver-fragment name="v8-auth-rules" %}}
### State resolution
{{% rver-fragment name="v2-state-res" %}}
### Canonical JSON
{{% rver-fragment name="v6-canonical-json" %}}
### Signing key validity period
{{% rver-fragment name="v5-signing-requirements" %}}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729---title: "Cryptography and Transport"weight: 55type: docs---
This part of the specification sets the cryptographic algorithms, transportrequirements, metadata protections, encryption at rest, passwordauthentication and anonymous trust tokens that apply across every Taper API.Where it conflicts with older text elsewhere in the specification, this parttakes precedence.
The key words MUST, MUST NOT, SHALL, SHOULD and MAY are used as described in[RFC 2119](https://www.rfc-editor.org/rfc/rfc2119). MUST and SHALL mean thesame thing.
## Algorithm policy {#algorithm-policy}
Taper follows the US National Institute of Standards and Technology (NIST)post-quantum transition guidance as published in late 2026, which CISA'spost-quantum guidance defers to for configuration:
* [NIST IR 8547](https://csrc.nist.gov/pubs/ir/8547/final) (final, October 2026): quantum-vulnerable public-key algorithms, including ECDH (X25519) and EdDSA (Ed25519), are **deprecated after 2030 and disallowed after 2035**. ML-KEM-768 is NIST's default post-quantum key-establishment parameter set. Hybrid schemes are acceptable as temporary measures if at least one component is approved.* [NIST SP 800-227](https://csrc.nist.gov/pubs/sp/800/227/final): hybrid key combiners.* [FIPS 203](https://csrc.nist.gov/pubs/fips/203/final) (ML-KEM) and [FIPS 204](https://csrc.nist.gov/pubs/fips/204/final) (ML-DSA).* CISA's [product categories for post-quantum cryptography](https://www.cisa.gov/resources-tools/resources/product-categories-technologies-use-post-quantum-cryptography-standards), which lists collaboration software (including messaging) as a category where post-quantum products are widely available and should be required.
The most urgent threat is **harvest now, decrypt later**: traffic recordedtoday and decrypted once a quantum computer exists. Key establishment istherefore hybrid now. Signatures can only be forged in real time, so theyfollow on NIST's schedule.
### Required algorithms
| Use | Taper requirement | Notes ||-----|-------------------|-------|| TLS key exchange | TLS 1.3 only. Servers and clients MUST offer and prefer `X25519MLKEM768` ([RFC 10024](https://datatracker.ietf.org/doc/rfc10024/), codepoint `0x11EC`). `X25519` alone MAY be accepted as a fallback until the end of 2030. | Pure ML-KEM groups are NOT RECOMMENDED (IANA marks them "Recommended: N"). Certificates stay classical until post-quantum WebPKI certificates exist. || Olm pairwise handshake | Hybrid: the existing X25519 exchanges plus an ML-KEM-768 encapsulation to a one-time ML-KEM prekey (or a signed last-resort ML-KEM key), in the style of Signal's PQXDH. | See [Hybrid key combiner](#hybrid-key-combiner). Defined in a future revision of the Olm specification; until then, sessions are classical and clients MUST say so in their security details. || Olm ratchet | SHOULD add periodic ML-KEM ratchet steps (in the style of Signal's sparse post-quantum ratchet), so that post-quantum forward secrecy survives past the first message. | Design choice beyond NIST guidance. || Signatures on keys | Device keys, cross-signing keys and server signing keys: hybrid Ed25519 + ML-DSA-65, where **both** signatures MUST verify. New keys MUST be hybrid from the revision that defines the format, and all keys MUST be hybrid before the end of 2030. Ed25519 components MUST NOT be relied on after 2035. | Pure ML-DSA, not the pre-hash variant (HashML-DSA). SLH-DSA-SHA2-128s MAY be used for long-lived root keys. || Symmetric encryption and MACs | AES-256, HMAC-SHA-256 or stronger. Nothing below 128-bit security. | AES-256 meets NIST's highest post-quantum category. || Hashing | SHA-256, or SHA-384/SHA-512 where long-term collision resistance matters. | || Password authentication | [OPAQUE](#password-authentication-opaque). | || Anonymous tokens | [Privacy Pass](#trust-tokens-privacy-pass). | |
A **CNSA 2.0 profile** MAY be offered for deployments that need it: TLS group`SecP384r1MLKEM1024`, ML-KEM-1024 in Olm, ML-DSA-87 signatures, SHA-384 orSHA-512.
### Hybrid key combiner {#hybrid-key-combiner}
Where Taper combines a classical and a post-quantum shared secret, it uses akey derivation over **both** secrets and **all** public inputs, as permittedby SP 800-227 section 4.6 when one input comes from an approved scheme:
K = HKDF-SHA-256( salt = 0, IKM = K_mlkem || K_x25519, info = "taper-hybrid-v1" || ct_mlkem || ek_mlkem || pk_x25519_sender || pk_x25519_recipient)
The order of the secrets is fixed. Implementations MUST NOT skip eitherinput, and MUST abort if either step fails.
### What post-quantum does not cover yet
* **Deniability.** Hybrid key exchange gives post-quantum *confidentiality*. Post-quantum *deniable* authentication exists only in research. Recent work has also shown that the deniability arguments for X3DH-family handshakes, which Olm uses, don't hold against a malicious verifier ([Fiedler and Langrehr, CRYPTO 2025](https://eprint.iacr.org/2025/470)). Deniability in Taper rests mainly on removing signatures from content (see [room version 13](/rooms/v13)), not on the handshake.* **Identity keys** (OpenPGP and Ariadne) remain classical until those formats standardise post-quantum keys. They sign only identity statements, never messages.* **OPAQUE and Privacy Pass** are classical. Both run inside post-quantum hybrid TLS, which protects recorded transcripts. Privacy Pass blinding hides which token is which unconditionally, so a future quantum attacker could forge tokens but not link them to users.
### Implementations {#implementations}
"Not your keys, not your crypto" applies to implementers too. Implementations:
* MUST use maintained, publicly reviewed cryptographic libraries, and MUST NOT implement cryptographic primitives themselves;* MUST use constant-time implementations of operations on secret data;* SHOULD use libraries that have had an independent audit, and MUST pass the published test vectors for every algorithm they implement.
For Olm and Megolm, clients SHOULD use[vodozemac](https://github.com/matrix-org/vodozemac) (audited) or animplementation of equal assurance. libolm is deprecated and MUST NOT be usedin new implementations.
## Transport {#transport}
All Taper traffic runs over WebSocket connections inside TLS 1.3. Thetransport is designed to be hard to block and hard to fingerprint, while stillrunning on ordinary web hosting so that anyone can operate a server.
Censors no longer rely only on blocklists. They block traffic that "lookslike nothing" (fully encrypted streams with no recognisable protocol), probesuspected servers actively, fingerprint TLS handshakes, and enumerate serversfrom public lists. Taper's answer is to look like an ordinary HTTPS website,because blocking all of those is expensive.
### Baseline (every server) {#transport-baseline}
* **TLS 1.3 on port 443,** with an ordinary certificate (for example from ACME) and the key exchange required by the [algorithm policy](#algorithm-policy). Plain `ws://` MUST be refused except on loopback addresses.* **HTTP versions.** The gateway MUST be reachable with WebSocket over HTTP/1.1, SHOULD also be reachable over HTTP/2 ([RFC 8441](https://www.rfc-editor.org/rfc/rfc8441)), and MAY be reachable over HTTP/3 ([RFC 9220](https://www.rfc-editor.org/rfc/rfc9220)). Over HTTP/2 and HTTP/3, the socket shares one connection with ordinary page loads instead of standing out as a lone long-lived connection.* **A cover website.** The server's host MUST serve an ordinary website (the operator's own, or a static default page). Any request that isn't a valid gateway handshake gets that site's normal response (its page, or its ordinary 404) with the same behaviour and timing. The server MUST NOT return a protocol-specific error, banner or header to an unauthenticated request.* **A secret gateway path.** The gateway's path SHOULD be chosen by the operator and contain at least 128 bits of randomness. It is given to users in invite links and through [discovery](#discovery-and-enumeration), not derived from a fixed pattern.* **No identifying strings** before authentication: no `Server` header naming Taper, no Taper-specific paths at fixed locations.* **No compression** (`permessage-deflate` MUST NOT be negotiated). Compressing before encryption leaks plaintext through ciphertext length.* **Mainstream TLS fingerprints.** Clients outside a browser, and servers making federation connections, SHOULD use a mainstream TLS stack whose ClientHello matches a common browser, and MUST NOT use a distinctive custom TLS configuration. Browser clients get this for free.* **No TLS inside TLS.** Taper MUST NOT tunnel another TLS session inside the gateway connection; nested handshakes are detectable even when padded.
### Padding {#padding}
Message lengths and timing reveal a great deal, even when content isencrypted. Research has identified the members and administrators ofencrypted group chats from timing and size alone. In an era of cheaplarge-scale traffic analysis, Taper treats lengths as metadata to protect.
Taper pads with **Padmé** (Nikitin et al., PETS 2019), which costs at mostabout 12% and leaks only O(log log L) bits of a length L:
padme(L): E = floor(log2(L)) S = floor(log2(E)) + 1 Z = E - S # number of low bits to round away mask = (1 << Z) - 1 return (L + mask) & ~mask
with a minimum padded length of 256 bytes.
* **Frames.** Every text frame sent on the gateway, in either direction, MUST be padded so that its UTF-8 length equals `padme(max(L, 256))`, by adding a top-level `pad` property containing filler characters. Receivers MUST ignore `pad`.* **Encrypted payloads.** Before encrypting a Megolm or Olm plaintext, clients MUST add a `pad` property to the payload so that its serialized length equals `padme(max(L, 256))`. Ciphertext lengths then reveal a length bucket, not the message length.* **Media** MUST be transferred in fixed-size chunks of 64 KiB (the last chunk padded), and encrypted media MUST be padded to `padme` of its size before encryption.* Servers SHOULD use TLS 1.3 record padding ([RFC 8446 section 5.4](https://www.rfc-editor.org/rfc/rfc8446#section-5.4)) where their TLS stack allows it.
### Timing {#timing}
* **Heartbeats** MUST NOT run at a fixed interval. Servers MUST give each connection its own heartbeat interval, and clients MUST add random jitter of at least ±20% to each heartbeat.* **Batching.** Servers SHOULD batch dispatches to a connection over a short random window (for example 50 to 200 milliseconds), so delivery timing doesn't mirror sending timing exactly.* **High-risk mode.** Clients MAY offer a mode that sends padded `{"op": "noop"}` frames at random (Poisson) intervals while the app is open. Servers accept `noop` silently (bounded only by the connection's rate limit). This defeats cheap classifiers. It does not defeat an adversary who can watch the whole network, and it costs bandwidth and battery.
### Discovery and enumeration {#discovery-and-enumeration}
Tor's disguised bridges were lost mainly to *enumeration*, not to trafficanalysis: censors collected the addresses from public distribution channels.A public list of servers is a ready-made blocklist. Therefore:
* Servers MUST NOT publish lists of other servers, and the protocol defines no public directory of servers.* Servers MAY serve `/.well-known/taper/client` for convenience. Operators who need stealth SHOULD disable it and distribute the gateway address and path out of band, for example in invite links.* Servers SHOULD publish their available transports in **signed server metadata**, given to authenticated users and federating servers only.
### Optional transports {#optional-transports}
Advertised in signed server metadata. None is required.
| Transport | What it gives | Costs ||-----------|---------------|-------|| **Tor onion service (v3)** | Hides the server's location; the address is the key, so no CA or DNS is needed; built-in proof-of-work defence against connection floods. Servers at risk SHOULD offer one, for clients and federation. | Latency; running Tor; onion addresses are themselves blocked in some places unless bridges are used. || **Behind another site** | The gateway path lives on a popular site the operator already runs, or behind a CDN, in the style of Tor's WebTunnel. | Defeated by enumeration, so pair it with private distribution. || **Encrypted Client Hello** ([RFC 9849](https://www.rfc-editor.org/rfc/rfc9849)) | Hides the server name, but only when the server sits behind a large CDN that serves ECH for many sites. | A lone server's ECH stands out. Russia blocks some ECH; China and Iran block ECH configuration lookups. Never rely on it alone. || **Tor pluggable transports** | obfs4, Snowflake or WebTunnel can wrap the connection using the Tor pluggable-transport interface, reusing tools that are already maintained. | Each transport adds testing and support load. |
Taper does not specify a mode that impersonates a third party's websiteduring the TLS handshake (as Xray's REALITY does). It is strong against somecensors, but it isn't browser-compatible, it depends on fragile choices oftarget site, and it impersonates other organisations.
Operators may still run such a proxy in front of a server; that is outsidethe protocol, and the deployment guide in the repository (`deploy/README.md`) coverswhat it takes to do it without undoing the protections above.
### Onion services {#onion-services}
A server MAY be reachable as a Tor onion service (version 3), alongside orinstead of its ordinary address. Onion services hide where the server is,hide who connects to it, need no DNS or certificate authority, and resistconnection floods with Tor's proof-of-work defence.
**Names.** A server whose only address is an onion service SHOULD use itsonion address as its [server name](/appendices/#server-name), so user IDslook like `@alice:<56 characters>.onion`. Version 2 onion addresses MUST NOTbe used.
**Encryption.** An onion service connection is encrypted end to end, and theaddress itself authenticates the server, so TLS is OPTIONAL there and plain`ws://` is allowed to onion addresses. It is not allowed anywhere else exceptloopback: a connection through a Tor exit can be read and changed by theexit. Tor's own handshakes are not post-quantum yet (they use X25519 andEd25519), so traffic recorded today could be decrypted by a future quantumcomputer. Operators for whom that matters SHOULD also run TLS with the keyexchange required by the [algorithm policy](#algorithm-policy) inside theonion service.
**Discovery.** Version 3 onion addresses can't be enumerated from Tor'sdirectory, but they can leak like any link. Servers SHOULD still use a[secret gateway path](#transport-baseline), MAY require Tor's clientauthorization so that only invited users can reach the service at all, andSHOULD NOT link their ordinary site to the onion service (for example with an`Onion-Location` header) unless the operator wants the two connectedpublicly.
**Floods.** Servers SHOULD enable Tor's proof-of-work defence for onionservices (`HiddenServicePoWDefensesEnabled`), and SHOULD limit streams percircuit.
**Federation over Tor.** A server that federates through Tor:
* MUST send every outbound federation connection, including key document fetches, through Tor's SOCKS5 port, with the destination as a host name (address type 3). It MUST NOT resolve peer names itself, so nothing leaks to DNS;* SHOULD put each peer on separate circuits, using Tor's stream isolation by SOCKS username and password;* MUST refuse a peer address with plain `ws://` unless it is an onion or loopback address.
Without TLS there is no channel binding, so the `channel` value in the[federation handshake](/server-server-api/#mutual-authentication) is theempty string. The handshake stays safe against relaying because the signedtranscript names both servers, and the onion address authenticates thedestination.
**Clients.** Native clients SHOULD connect through Tor's SOCKS port withstream isolation, as servers do. In Tor Browser, the Safer and Safestsecurity levels block WebAssembly (enforced by NoScript since Tor Browser15.0). Taper's web client needs WebAssembly for Olm and Megolm and for[OPAQUE](#password-authentication-opaque), so it runs only at the Standardlevel. Clients SHOULD say so plainly rather than failing silently. Users whoneed the stricter levels should use a native client.
**Where Tor is blocked.** Some censors (China among them) block Tor's publicrelays. Users there need Tor bridges: Snowflake, WebTunnel or obfs4. Bridgesare configured in the user's Tor client, not in Taper.
## Metadata minimization {#metadata}
Besides [padding](#padding) and [timing](#timing):
* Servers MUST NOT persist ephemeral data units (typing notifications, read receipts, presence) beyond delivering them, except the latest read receipt per user and room, which clients need.* Clients SHOULD let users turn off sending read receipts and typing notifications, and SHOULD make the choice easy to find.* Push notifications carry only event IDs (see the [Push Gateway API](/push-gateway-api)).* Servers keep counters, not logs (see [Scraping Resistance](/client-server-api/#counters-not-logs)).* Clients fetching identity keys or proofs from third parties (keyservers, Web Key Directories, ASP servers) SHOULD cache them and MAY fetch through Tor or a proxy, because each fetch tells that third party whom the user is looking up.
## Encryption at rest {#encryption-at-rest}
Servers MUST encrypt all stored event content, media and derived data atrest, and MUST use crypto-shredding to enforce[message retention](/client-server-api/#message-retention):
* Data MUST be encrypted with keys that rotate at least once per day.* Each key MUST be destroyed once every item it protects has expired. That makes every copy unreadable at once, including copies in replicas and backups.* Encryption keys MUST NOT be stored alongside the data they protect, or in the same backups. They SHOULD be held in a hardware security module or a separate key-management service.* Backups MUST be encrypted, and MUST NOT contain the keys needed to read them.
Clients have equivalent requirements (see[local storage](/client-server-api/#local-storage)).
## Password authentication (OPAQUE) {#password-authentication-opaque}
Taper uses **OPAQUE** ([RFC 9807](https://www.rfc-editor.org/rfc/rfc9807)), anaugmented password-authenticated key exchange. The server never receives thepassword, or anything from which it could be computed without a dictionaryattack, and a stolen server database doesn't allow precomputed dictionaryattacks.
Servers MUST NOT offer `t.login.password`, and clients MUST NOT send apassword to a server in any form. RFC 9807 is an Informational document fromthe IRTF's Crypto Forum Research Group. Taper makes it normative: compliancemeans implementing its normative text in full, as listed below.
### Configuration
The Taper configuration, `taper-opaque-v1`, is:
| Parameter | Value ||-----------|-------|| OPRF | `ristretto255-SHA512` ([RFC 9497](https://www.rfc-editor.org/rfc/rfc9497), modeOPRF) || KDF | HKDF-SHA-512 || MAC | HMAC-SHA-512 || Hash | SHA-512 || KSF | Argon2id with S = zeroes(16), p = 4, T = Nh, **m = 2^16 (64 MiB)**, t = 3, v = 0x13, K = nil, X = nil, y = 2 || Group | ristretto255 || Context | the empty string |
This is the first configuration RFC 9807 recommends, except for the KSF'smemory and passes. The RFC's m = 2^21 means 2 GiB of memory on the client,which phones and browsers can't reliably provide. 64 MiB with three passes isthe second recommended option of [RFC 9106](https://www.rfc-editor.org/rfc/rfc9106).Changing any part of the configuration requires every user to register again,so it is versioned.
The context is empty because the audited WebAssembly build of opaque-ke(`@serenity-kit/opaque`) doesn't let applications set it. Cross-protocolseparation still holds: the key exchange binds `server_identity`, which isthe server name, and the configuration has its own version. A futureconfiguration SHOULD set the context to its own name once the librariesallow it.
### Identities and credential identifier
* `credential_identifier` is the user's full user ID. It MUST NOT be shared between users.* `client_identity` is the user ID and `server_identity` is the server name. Both are fixed for the life of the record, so both MUST be included in the key exchange.* The server's OPRF seed is global and MUST be persisted, together with the server's AKE key pair.
### Flows
OPAQUE messages are carried as unpadded URL-safe base64 in gateway requests.The server keeps the state between the two halves of each flow for at most 60seconds.
| Method | Request | Response ||--------|---------|----------|| `t.opaque.register.start` | `username`, `registration_request`, plus whatever registration needs (token, invite, challenge response) | `registration_response`, `registration_id` || `t.opaque.register.finish` | `registration_id`, `registration_record` | `user_id`, `access_token`, `device_id` || `t.opaque.login.start` | `username`, `ke1` | `ke2`, `login_id` || `t.opaque.login.finish` | `login_id`, `ke3` | `user_id`, `access_token`, `device_id` || `t.opaque.password.change` (authenticated) | runs the registration flow again | replaces the record |
**Re-authentication.** Some operations need fresh proof of the password,for example replacing a [cross-signing](/client-server-api/#cross-signing)identity. The client runs `t.opaque.login.start`, then sends`{"type": "t.login.opaque", "login_id", "ke3"}` as the operation's `auth`instead of calling `t.opaque.login.finish`. The server verifies KE3 exactlyas for a login, checks that it belongs to the requesting user, and issues notoken. Each proof is single use.
Clients MUST obtain the proof before changing any local key material, so awrong password leaves the device's state untouched.
### Compliance
Implementations MUST:
1. Validate every peer public key (a valid group element, not the identity), and abort if a shared secret is the identity element (RFC 9807 sections 5 and 10.7).2. Default any identity that isn't given to the party's public key (section 4).3. Delete all intermediate values after an envelope recovery error (section 4.1.3).4. On the server, verify the KE3 MAC before using the session key, and never release a session key or token if it fails (section 6.4).5. On the client, not use `export_key` before the server has been authenticated (section 6).6. **Prevent client enumeration**: respond to login attempts for unknown users with a fake record, as in section 6.3.2.2. Lookups and the fake path MUST take the same time as real ones (sections 6.3.2.2 and 9.1).7. Check the size of every received message and reject malformed ones (section 9.3).8. Pass the test vectors in RFC 9807 Appendix C for the components they implement.9. Count a login that never sends KE3 as a failed attempt for rate limiting, because the client learns the outcome from KE2 (section 9.2), and rate-limit registration, which can't hide whether a username exists (section 10.9).10. Run registration only over the TLS-protected gateway, because the masking key must stay confidential (section 10.10).
Servers SHOULD NOT enforce password policies, which OPAQUE prevents them fromchecking properly (section 10.11). Clients enforce them before registering.
### Identity recovery {#identity-recovery}
A user's [cross-signing](/client-server-api/#cross-signing) identity mustsurvive new devices, or every login looks like an identity change andverification loses its meaning. Taper keeps the identity's private keys onthe server, sealed with a key that only the user's password can produce:
* The client derives a key with HKDF-SHA-512 from OPAQUE's `export_key`, with salt `"t.secrets.v1.aes-gcm"` and info `"identity recovery|"` followed by the user ID, and uses it for AES-256-GCM with a random 96-bit IV and the user ID as additional data.* The plaintext is the JSON object `{master, self_signing, user_signing}` (the private key seeds, unpadded base64), [padded](#padding) with `pad`.* The sealed object is `{"algorithm": "t.secrets.v1.aes-gcm", "iv", "ciphertext"}` (standard base64, unpadded), at most 16 KiB.
| Method | Request | Response ||--------|---------|----------|| `t.secrets.get` (authenticated) | `{}` | `{secrets}`, or `{secrets: null}` || `t.secrets.put` (authenticated) | `{secrets, auth?}` | `{}` |
Storing the first copy needs only the session. Replacing a stored copy needs[re-authentication](#password-authentication-opaque) in `auth`, so a stolenaccess token can't destroy it. Servers MUST NOT interpret the contents.
When a client logs in on a new device and the account already has anidentity, it MUST try recovery before offering to replace the identity: openthe copy, import the keys (checking that they match the published master,self-signing and user-signing keys), and sign its own device. Only if thatfails may it replace the identity, and it then stores the new one.
`export_key` MUST NOT leave the client, and clients MUST NOT use it beforethe server has authenticated itself (section 6 of RFC 9807). An attacker withthe server's database still can't open the copy without guessing thepassword and running OPAQUE against the server's OPRF key, which is heldapart from the data (see [encryption at rest](#encryption-at-rest)). Changingthe password changes `export_key`, so a [password change](#password-change)stores a newly sealed copy in the same step.
Room keys are not part of this copy. They have their own, with a shorterlife: see [room-key backup](#room-key-backup).
As of late 2026, the most mature implementation of the final RFC is opaque-ke4.x (Rust; also compiled to WebAssembly as `@serenity-kit/opaque`, which7ASecurity reviewed). The NCC Group audit of opaque-ke, in 2021, covered anearlier draft, so implementations SHOULD verify it against the RFC testvectors themselves. The WebAssembly build exposes no way to run them withfixed randomness; run them against opaque-ke itself, at the same version.
`@serenity-kit/opaque` 1.1.0 can be pushed into a broken state by malformedinput, fixed in a later release. Item 7 above (check the size of every messagebefore using it) protects against this, and servers MUST NOT skip it.
### Password change {#password-change}
OPAQUE registration is interactive, so a change takes two requests, both byan authenticated session:
| Method | Request | Response ||--------|---------|----------|| `t.password.change.start` | `{auth, key_auth?, registration_request}` | `{registration_response, change_id}` || `t.password.change.finish` | `{change_id, registration_record, secrets, backup}` | `{}` |
`auth` is a fresh proof of the *old* password (the `t.login.opaque` object usedfor any [re-authentication](#password-authentication-opaque)), and `key_auth`a [security key](#security-keys) touch when the account has keys. In `finish`,`secrets` is the [identity copy](#identity-recovery) and `backup` the[room-key backup](#room-key-backup) parts, each sealed again under the*new* `export_key`. The server checks all of it, then replaces the OPAQUErecord, the identity copy and the backup together, or changes nothing. Login proofsbegun before the change are void: a login flow remembers the OPAQUE record itstarted against, and flows are also dropped on suspension, unlock and deletion. Achange that leaves out `secrets` when a copy exists is refused: the old copywould no longer open.
Every other device is then signed out: its token is revoked and its devicekeys are forgotten. The device that made the change stays signed in.
### Room-key backup {#room-key-backup}
A device that logs in later can read the messages still within[retention](/client-server-api/#message-retention) if it can get their Megolmkeys. The server keeps them, sealed under a key it can't make:
* The key is 32 bytes from HKDF-SHA-512 over `export_key`, with salt `"t.backup.v1.aes-gcm"` and info `"room key backup|"` followed by the user ID. It is not the identity key.* A *part* is an AES-256-GCM seal of `{keys}`, where `keys` is a JSON string of exported room keys, [padded](#padding) with `pad`. Its additional data is the user ID, `"|"`, and the part's name. A part holds at most 512 KiB of ciphertext; an account at most 200 parts and 8 MiB.* A part is named for the UTC day it was uploaded and a number, `2026-01-31.0`. Servers accept only today's and yesterday's day, and drop each part 21 days (the retention period) after its day begins, so a key does not outlive the messages it opens by more than the days between receiving it and uploading it. Stored parts are encrypted at rest under the period key, like events.* A part is written once: `t.backup.put` for a name that exists fails with `T_PART_EXISTS`, and the client takes the next number. Two devices on the same day therefore can't overwrite each other's keys.
| Method | Request | Response ||--------|---------|----------|| `t.backup.put` | `{part, blob}` | `{}` || `t.backup.get` | `{}` | `{parts: {name: blob}}` || `t.backup.clear` | `{}` | `{}` |
Clients upload new keys soon after receiving or making them, import everypart at login, and let users turn the backup off, which calls`t.backup.clear`. Backed-up keys are as safe as the password: someone who hasthe server's OPAQUE record and key can guess a password offline, and with itopen the last 21 days. Users who can't accept that turn the backup off.
### Security keys {#security-keys}
Users may register FIDO2/WebAuthn authenticators, such as a YubiKey. A keyconfirms sensitive actions, can be required at login, and can back a publicindicator. It is not a proof of humanity: it shows that someone once held adevice, not that a person wrote a message. Servers, clients and documentsMUST NOT describe it as one.
Servers verify WebAuthn Level 2 registrations and assertions with thealgorithms ES256, EdDSA and RS256. The relying party is the web page's ownhost name: the origin comes from the WebSocket handshake, it MUST be `https`(or `http` for `localhost` and `.onion`), and an IP address is not a validrelying party. A key works only on the site it was registered on. Challengesare 32 random bytes, single use, valid 60 seconds, and bound to the accountand the origin. A signature counter that goes backwards (when it is notalways zero) is refused as a cloned key.
**Attestation.** Registration asks for `direct` attestation. The serverreads the `packed` and `fido-u2f` formats and sets the key's *level*:
* `attested`: the attestation certificate chain verifies up to a root the operator trusts (`TAPER_WEBAUTHN_ROOTS`, a directory of PEM files), the signature is valid, and the credential isn't backup-eligible (a synced passkey).* `unattested`: anything else, including no attestation, self-attestation, an untrusted chain, and formats the server doesn't verify. A software authenticator can reach this level.
The server then discards the certificate, the AAGUID and everything elseabout the device's make: they identify its model, and a model is afingerprint. It stores only the credential ID, the public key, the signaturecounter, a nickname, the level, the creation time and the relying party.
| Method | Request | Response ||--------|---------|----------|| `t.webauthn.list` | `{}` | `{keys: [{id, nickname, level, created_ts}], show_indicator, login_requires_key}` || `t.webauthn.challenge` | `{}` | `{challenge_id, options}` (for a touch; pass `{challenge_id, credential}` as `key_auth`) || `t.webauthn.register.start` | `{auth, key_auth?, attachment?}` | `{challenge_id, options}` || `t.webauthn.register.finish` | `{challenge_id, credential, nickname?}` | `{id, level}` || `t.webauthn.remove` | `{id, auth, key_auth?}` | `{}` || `t.webauthn.settings` | `{show_indicator?, login_requires_key?, auth?, key_auth?}` | the new settings || `t.webauthn.login` (before login) | `{ticket, credential}` | the login result |
**Step-up.** Replacing the identity copy or the cross-signing identity,changing the password, adding or removing a key, deleting the account, andchanging `login_requires_key` all need `auth` (the password) and, if theaccount has any key, `key_auth` (a touch). `key_auth` may also sit inside`auth`. The error `T_FORBIDDEN` with `needs: "security_key"` says a touch ismissing.
**Login.** When `login_requires_key` is on, `t.opaque.login.finish` returns`{second_factor: {type: "t.webauthn", ticket, options}}` instead of a token.The client answers with `t.webauthn.login`.
**The indicator.** With `show_indicator` on, the user's server includes`hardware_keys: {user_id: level}` in key query responses to users who are both*joined* to a room with them (an invitation is not enough), and to peers askingabout its users. Turning `show_indicator` on needs `auth` and `key_auth`;turning it off needs only the session. A server speaks only forits own users, and only the two levels are valid. Clients show a small badgeand MUST say what it means: that the person's server says they hold a key,that `unattested` could be software, and that it proves nothing about whowrites. The default is off, and turning it off removes it at once.
### Account deletion and device management {#account-deletion}
`t.account.delete`, with `auth` and any `key_auth`, removes the account: itleaves its rooms, revokes its tokens, forgets its devices and their keys,deletes its identity copy, security keys, cross-signing keys and backup, andreserves the user ID so nobody can register it later and pass for the oldowner. It does not remove events the user already sent: they expire witheverything else.
To revoke a single lost or compromised device without changing the password:
| Method | Request | Response ||--------|---------|----------|| `t.devices.list` | `{}` | `{devices: [{device_id, issued_ts, expires_ts, current, has_keys}]}` || `t.devices.delete` | `{device_id, auth, key_auth?}` | `{}` |
`t.devices.delete` needs fresh `auth` (and `key_auth` if the account hassecurity keys), revokes every token for `device_id`, forgets its device keys(notifying shared rooms so contacts rotate Megolm sessions), and closes its liveconnections.
## Trust tokens (Privacy Pass) {#trust-tokens-privacy-pass}
[Scraping Resistance](/client-server-api/#scraping-resistance) asks some usersto solve [challenges](/client-server-api/#challenges). Users a server trustscan skip them by spending **trust tokens**: anonymous tokens issued withPrivacy Pass ([RFC 9576](https://www.rfc-editor.org/rfc/rfc9576),[RFC 9577](https://www.rfc-editor.org/rfc/rfc9577),[RFC 9578](https://www.rfc-editor.org/rfc/rfc9578)). Trust stays useful withoutbecoming a way to track people.
### Trust
Each server decides locally how much to trust an account. A server:
* MAY base trust on account age, its history of staying within [read budgets](/client-server-api/#read-budgets), contact with [canaries](/client-server-api/#canaries), and entries on subscribed [moderation policy lists](/client-server-api/#moderation-policy-lists);* MUST NOT base trust on device or browser fingerprints, location, contact lists or message content;* MUST NOT share trust scores with other servers.
### Issuance and redemption
* Token type `0x0001` (VOPRF with P-384 and SHA-384, privately verifiable) is used, because each server issues and redeems its own tokens.* `t.trust.tokens` takes a batch of Privacy Pass `TokenRequest` structures and returns `TokenResponse` structures, as unpadded URL-safe base64. Servers decide how many tokens each account may hold, by trust.* A [challenge](/client-server-api/#challenges) MAY include a Privacy Pass `TokenChallenge` with an empty `redemption_context`. The client may answer with a `token` instead of solving the challenge.* Servers MUST reject tokens that have already been spent.
### Keeping tokens unlinkable
Here the same server issues tokens, redeems them, and knows which accountasked. RFC 9576 section 4.1 warns that this can link tokens to accounts unlessissuance and redemption are separated. Therefore:
* Clients MUST fetch tokens in batches ahead of need, and MUST NOT redeem a token in the same session or connection that fetched it.* Clients SHOULD wait a random interval before first redeeming a newly fetched batch.* Servers MUST publish one token issuance key at a time, in signed server metadata. Clients MUST check that the key they were issued under matches the published key fetched without authentication, and MUST discard tokens that don't. That stops a server from tagging individual users with their own keys.
## Group encryption {#group-encryption}
No deployed or standardised system provides deniability together with strongrecovery from key compromise for large groups (see the[research summary](#group-encryption-research) below). Taper keeps Megolm,whose deniability rests on deniable pairwise channels, and tightens it:
* Clients MUST rotate their outbound Megolm session whenever any member leaves or is removed from the room, and whenever a member's device list changes.* `rotation_period_ms` MUST NOT exceed 86400000 (one day), and `rotation_period_msgs` MUST NOT exceed 100.* Session keys are shared only over Olm, which becomes post-quantum hybrid as described under [algorithm policy](#algorithm-policy).* **No unsigned devices.** Clients MUST NOT share room keys with devices that are not cross-signed by their owner's identity, and MUST reject messages, encrypted state, and Olm to-device messages from non-cross-signed devices (defeating malicious-homeserver ghost-device impersonation).* **No in-band room key forwarding.** Clients MUST disable automatic `t.room_key_request` and `t.forwarded_room_key` handling, preventing key-share confusion attacks and retention bypasses. Multi-device recovery uses only the OPAQUE-sealed, retention-bounded [room-key backup](#room-key-backup).* **Verified-only rooms.** Clients SHOULD offer a per-room verified-only mode that refuses to encrypt messages or state to any unverified member, defeating silent member injection by a hostile homeserver.* **One-time key exhaustion defence.** Servers MUST meter `t.keys.claim` and `t.fed.keys.claim` and throttle repeated claims by one requester against a single target device, stopping attackers from draining a device's one-time keys onto its static fallback key.
### Research summary {#group-encryption-research}
Informative.
| Design | Deniability | Recovery after compromise | Scale | Maturity ||--------|-------------|---------------------------|-------|----------|| Pairwise fan-out (every message sent over each member's pairwise session) | Strongest (MACs only) | Per pair, only when that pair exchanges messages | O(n) per message | Deployed by Signal until 2021 || Megolm / Signal Sender Keys | Depends on the pairwise handshake | Weak (rotation only) | O(1) per message | Deployed || MLS ([RFC 9420](https://www.rfc-editor.org/rfc/rfc9420)) | None: every message is signed | Strong | Thousands | Standard || MLS with ephemeral signing keys bound over deniable pairwise channels | Plausible, unproven | Strong | Thousands | Suggested in RFC 9750; no proof || MLS with epochal signatures (Hülsing and Weber, IEEE S&P 2021) | Deniable after each epoch | Strong | Thousands | Research only |
The most promising future direction is a hybrid: pairwise fan-out for smallgroups, and MLS with post-quantum ciphersuites for large ones, where eachmember's signing keys are ephemeral, rotated with every update, and bound totheir identity only over deniable pairwise channels. Neither half is proven togive deniability and strong compromise recovery together, and running twomodes adds complexity and room for downgrade attacks. A future room versionwill make this choice.1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864---title: "Server-Server API"weight: 20type: docsdescription: | Taper homeservers use the Federation APIs (also known as server-server APIs) to communicate with each other. Homeservers use these APIs to push messages in real-time, retrieve historic messages, and query profile or presence information about users on other servers. The APIs are implemented over HTTPS, with authentication provided by public key signatures both at the TLS transport layer and in HTTP `Authorization` headers.
There are three main kinds of communication that occur between homeservers:
Persistent Data Units (PDUs): These events are broadcast from one homeserver to any others that have joined the same room (identified by Room ID). They are persisted in long-term storage and record the history of messages and state for a room.
Like email, it is the responsibility of the originating server of a PDU to deliver that event to its recipient servers. However PDUs are signed using the originating server's private key so that it is possible to deliver them through third-party servers.
Ephemeral Data Units (EDUs): These events are pushed between pairs of homeservers. They are not persisted and are not part of the history of a room, nor does the receiving homeserver have to reply to them.
Queries: These are single request/response interactions between a given pair of servers, initiated by one side sending an HTTPS GET request to obtain some information, and responded by the other. They are not persisted and contain no long-term significant history. They simply request a snapshot state at the instant the query is made.
EDUs and PDUs are further wrapped in an envelope called a Transaction, which is transferred from the origin to the destination homeserver using an HTTPS PUT request.
---
## WebSocket federation {#websocket-federation}
Taper servers federate over **WebSocket connections inside TLS 1.3**, likeclients do. The HTTP endpoints later in this document define the *meaning*and bodies of each operation. On the federation socket, the same operationsare carried as gateway requests. A server MUST support WebSocket federation,and MAY also serve the HTTP endpoints during a transition.
### Connections
* The connecting server opens a WebSocket to the destination's federation path. The path is published only in the destination's signed server metadata, or configured out of band, and SHOULD be unguessable, as for the [client gateway](/security/#transport-baseline).* The transport rules of [Cryptography and Transport](/security/#transport) apply in full: TLS 1.3 with `X25519MLKEM768`, a cover website for anything that fails the handshake, no compression, padded frames and jittered heartbeats.* One connection per pair of servers is RECOMMENDED. Either side may close it; the other reconnects when it next needs to send.
### Mutual authentication
Each connection is authenticated **once**, by both sides, with their current[request keys](#publishing-keys). Those private keys are published afterretirement, so a recorded handshake later proves nothing.
1. The connecting server sends `{"op": "fed.hello", "origin", "destination", "nonce", "key"}`, where `nonce` is 32 random bytes (unpadded base64) and `key` is a request key ID.2. The destination replies with its own `fed.hello`, with the names swapped and its own `nonce` and `key`.3. Each side then sends `{"op": "fed.auth", "sig"}`: an Ed25519 signature, with its announced request key, over the Canonical JSON of `{"client_nonce", "server_nonce", "client", "server", "signer", "channel"}`. Here `channel` is the TLS exporter value for the connection ([RFC 9266](https://www.rfc-editor.org/rfc/rfc9266), label `EXPORTER-Channel-Binding`, unpadded base64), so a signature can't be replayed on another connection. On a connection without TLS (an [onion service](/security/#onion-services)), `channel` is the empty string.4. Each side checks the other's signature against that server's `request_keys`, fetched from its [key document](#publishing-keys) or a notary, and closes the connection if it fails or if the key is retired.
The connecting side may finish step 4 first and start sending requests whilethe other side is still fetching its keys, which can take seconds over Tor.A server MUST NOT drop requests that arrive before it has checked thepeer's signature; it holds them, and serves them once the check succeeds.
A server that receives a `fed.hello` from a server it doesn't federate with(see below) MUST close the connection without explanation, as it would forany other failed handshake.
Servers that federate through Tor follow the additional rules in[Onion services](/security/#onion-services).
After the handshake, either side sends requests (`{"op": "request", "id","method", "body"}`) and gets responses, exactly as on the client gateway.The methods are:
| Method | HTTP equivalent ||--------|-----------------|| `t.fed.send` | [`PUT /send/{txnId}`](#put_taperfederationv1sendtxnid) (transactions of PDUs and EDUs) || `t.fed.make_join`, `t.fed.send_join` | [joining rooms](#joining-rooms) || `t.fed.make_leave`, `t.fed.send_leave` | [leaving rooms](#leaving-rooms-rejecting-invites) || `t.fed.invite` | [inviting](#inviting-to-a-room) || `t.fed.backfill`, `t.fed.get_missing_events`, `t.fed.event` | [backfill and missing events](#backfilling-and-retrieving-missing-events), limited by [retention](#message-retention) || `t.fed.state` | [room state](#retrieving-events) || `t.fed.query.profile` | [profile query](#querying-for-information), subject to [Scraping Resistance](/client-server-api/#closed-surfaces) || `t.fed.keys.query`, `t.fed.keys.claim` | [end-to-end encryption keys](#end-to-end-encryption) || `t.fed.media.download` | [media](#content-repository), in [binary frames](/client-server-api/#media-over-the-gateway) |
Messages within a request don't carry their own signatures: the connectionis authenticated. Room events (PDUs) still carry their server's signature onthe event itself, as room version 13 defines, because other servers rely onit.
### Which servers to federate with
Servers SHOULD support an **allowlist mode**, where they federate only withservers an administrator has approved. In that mode they neither open noraccept connections with any other server. Servers MUST apply the federationrules of [Scraping Resistance](/client-server-api/#federation): budgets andtiers per remote server, and limits on servers they haven't seen before.
## API standards
The HTTP endpoints below define the operations that[WebSocket federation](#websocket-federation) carries. Servers that also servethem over HTTPS exchange JSON objects, as described here.
All `POST` and `PUT` endpoints require the requesting server to supply arequest body containing a (potentially empty) JSON object. Requesting serversshould supply a `Content-Type` header of `application/json` for all requestswith JSON bodies, but this is not required.
Similarly, all endpoints in this specification require the destination serverto return a JSON object. Servers must include a `Content-Type` header of`application/json` for all JSON responses.
All JSON data, in requests or responses, must be encoded using UTF-8.
### TLS
Server-server communication MUST use TLS 1.3, and MUST offer and prefer thehybrid post-quantum key exchange `X25519MLKEM768`, as required by[Cryptography and Transport](/security/#algorithm-policy). Servers SHOULD usea mainstream TLS stack whose handshake matches a common browser, and SHOULDbe reachable as a Tor onion service when they are at risk of blocking (see[optional transports](/security/#optional-transports)).
The destination server must provide a TLS certificate signed by a knownCertificate Authority.
Requesting servers are ultimately responsible for determining the trusted CertificateAuthorities, however are strongly encouraged to rely on the operating system'sjudgement. Servers can offer administrators a means to override the trustedauthorities list. Servers can additionally skip the certificate validation fora given whitelist of domains or netmasks for the purposes of testing or innetworks where verification is done elsewhere, such as with `.onion`addresses.
Servers should respect SNI when making requests where possible: a SNI should besent for the certificate which is expected, unless that certificate is expectedto be an IP address in which case SNI is not supported and should not be sent.
Servers are encouraged to make use of the [CertificateTransparency](https://www.certificate-transparency.org/) project.
### Unsupported endpoints
If a request for an unsupported (or unknown) endpoint is received then the servermust respond with a 404 `T_UNRECOGNIZED` error.
Similarly, a 405 `T_UNRECOGNIZED` error is used to denote an unsupported methodto a known endpoint.
## Server discovery
### Resolving server names
Each Taper homeserver is identified by a server name consisting of ahostname and an optional port, as described by the[grammar](/appendices#server-name). Where applicable, a delegatedserver name uses the same grammar.
Server names are resolved to an IP address and port to connect to, andhave various conditions affecting which certificates and `Host` headersto send. The process overall is as follows:
1. If the hostname is an IP literal, then that IP address should be used, together with the given port number, or 8448 if no port is given. The target server must present a valid certificate for the IP address. The `Host` header in the request should be set to the server name, including the port if the server name included one.
2. If the hostname is not an IP literal, and the server name includes an explicit port, resolve the hostname to an IP address using CNAME, AAAA or A records. Requests are made to the resolved IP address and given port with a `Host` header of the original server name (with port). The target server must present a valid certificate for the hostname.
3. If the hostname is not an IP literal, a regular HTTPS request is made to `https://<hostname>/.well-known/taper/server` (according to [RFC 8615](https://datatracker.ietf.org/doc/html/rfc8615)), expecting the schema defined later in this section. 30x redirects should be followed, however redirection loops should be avoided. Responses (successful or otherwise) to the `/.well-known` endpoint should be cached by the requesting server. Servers should respect the cache control headers present on the response, or use a sensible default when headers are not present. The recommended sensible default is 24 hours. Servers should additionally impose a maximum cache time for responses: 48 hours is recommended. Errors are recommended to be cached for up to an hour, and servers are encouraged to exponentially back off for repeated failures. The schema of the `/.well-known` request is later in this section. If the response is invalid (bad JSON, missing properties, non-200 response, etc), skip to step 4. If the response is valid, the `t.server` property is parsed as `<delegated_hostname>[:<delegated_port>]` and processed as follows: 1. If `<delegated_hostname>` is an IP literal, then that IP address should be used together with the `<delegated_port>` or 8448 if no port is provided. The target server must present a valid TLS certificate for the IP address. Requests must be made with a `Host` header containing the IP address, including the port if one was provided. 2. If `<delegated_hostname>` is not an IP literal, and `<delegated_port>` is present, an IP address is discovered by looking up CNAME, AAAA or A records for `<delegated_hostname>`. The resulting IP address is used, alongside the `<delegated_port>`. Requests must be made with a `Host` header of `<delegated_hostname>:<delegated_port>`. The target server must present a valid certificate for `<delegated_hostname>`. 3. {{% added-in v="1.8" %}} If `<delegated_hostname>` is not an IP literal and no `<delegated_port>` is present, an SRV record is looked up for `_taper-fed._tcp.<delegated_hostname>`. This may result in another hostname (to be resolved using AAAA or A records) and port. Requests should be made to the resolved IP address and port with a `Host` header containing the `<delegated_hostname>`. The target server must present a valid certificate for `<delegated_hostname>`. 4. **[Deprecated]** If `<delegated_hostname>` is not an IP literal, no `<delegated_port>` is present, and a `_taper-fed._tcp.<delegated_hostname>` SRV record was not found, an SRV record is looked up for `_taper._tcp.<delegated_hostname>`. This may result in another hostname (to be resolved using AAAA or A records) and port. Requests should be made to the resolved IP address and port with a `Host` header containing the `<delegated_hostname>`. The target server must present a valid certificate for `<delegated_hostname>`. 5. If no SRV record is found, an IP address is resolved using CNAME, AAAA or A records. Requests are then made to the resolved IP address and a port of 8448, using a `Host` header of `<delegated_hostname>`. The target server must present a valid certificate for `<delegated_hostname>`.
4. {{% added-in v="1.8" %}} If the `/.well-known` request resulted in an error response, a server is found by resolving an SRV record for `_taper-fed._tcp.<hostname>`. This may result in a hostname (to be resolved using AAAA or A records) and port. Requests are made to the resolved IP address and port, with a `Host` header of `<hostname>`. The target server must present a valid certificate for `<hostname>`.
5. **[Deprecated]** If the `/.well-known` request resulted in an error response, and a `_taper-fed._tcp.<hostname>` SRV record was not found, a server is found by resolving an SRV record for `_taper._tcp.<hostname>`. This may result in a hostname (to be resolved using AAAA or A records) and port. Requests are made to the resolved IP address and port, with a `Host` header of `<hostname>`. The target server must present a valid certificate for `<hostname>`.
6. If the `/.well-known` request returned an error response, and no SRV records were found, an IP address is resolved using CNAME, AAAA and A records. Requests are made to the resolved IP address using port 8448 and a `Host` header containing the `<hostname>`. The target server must present a valid certificate for `<hostname>`.
{{% boxes/note %}}The reasons we require `<hostname>` rather than `<delegated_hostname>` for SRVdelegation are: 1. DNS is insecure (not all domains have DNSSEC), so the target of the delegation must prove that it is a valid delegate for `<hostname>` via TLS. 2. Consistency with the recommendations in [RFC6125](https://datatracker.ietf.org/doc/html/rfc6125#section-6.2.1) and other applications using SRV records such [XMPP](https://datatracker.ietf.org/doc/html/rfc6120#section-13.7.2.1).{{% /boxes/note %}}
{{% boxes/note %}}Note that the target of a SRV record may *not* be a CNAME, asmandated by [RFC2782](https://www.rfc-editor.org/rfc/rfc2782.html):
> the name MUST NOT be an alias (in the sense of RFC 1034 or RFC 2181){{% /boxes/note %}}
{{% boxes/note %}}Steps 3.4 and 5 are deprecated because they use a service name not registered by IANA.They may be removed in a future version of the specification. Server admins are encouragedto use `.well-known` over any form of SRV records.
The IANA registration for port 8448 and `matrix-fed` can be found [here](https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml?search=matrix-fed).{{% /boxes/note %}}
{{% http-api spec="server-server" api="wellknown" %}}
### Server implementation
{{% http-api spec="server-server" api="version" %}}
### Retrieving server keys
{{% boxes/note %}}There was once a "version 1" of the key exchange. It has been removedfrom the specification due to lack of significance. It may be reviewed[from the historicaldraft](https://github.com/matrix-org/matrix-doc/blob/51faf8ed2e4a63d4cfd6d23183698ed169956cc0/specification/server_server_api.rst#232version-1).{{% /boxes/note %}}
Each homeserver publishes its public keys in a key document (see[Publishing Keys](#publishing-keys)). Homeservers query for keys by eitherfetching that document directly or by querying anintermediate notary server using a`/_taper/key/v2/query/{serverName}` API. Intermediate notaryservers fetch the key document on behalf ofanother server and sign the response with their own key. A server mayquery multiple notary servers to ensure that they all report the samepublic keys.
This approach is borrowed from the [PerspectivesProject](https://web.archive.org/web/20170702024706/https://perspectives-project.org/),but modified to include the NACL keys and to use JSON instead of XML. Ithas the advantage of avoiding a single trust-root since each server isfree to pick which notary servers they trust and can corroborate thekeys returned by a given notary server by querying other servers.
#### Publishing Keys
Homeservers publish their signing keys in a JSON object, the **keydocument**, at `{federation path}/keys`: an HTTPS `GET` under the secretpath of the server's [federation socket](#websocket-federation), so onlyservers that know that path can fetch it. A server MUST NOT serve its keydocument at a fixed, guessable location such as `/_taper/key/v2/server`,because that would identify it as a Taper server to anyone who asks (see[Cryptography and Transport](/security/#transport-baseline)). The HTTPdefinition below gives the document's format. It contains two kinds of key:
* **Signing keys**, in `verify_keys`, are used to sign events and key server responses. Keys a server no longer signs with move to `old_verify_keys`, and remain valid for checking events signed before they expired.* **Request keys**, in `request_keys`, are used only to sign [federation requests](#request-authentication). They are short-lived: a server MUST retire each request key no later than 7 days after it first uses it. Once retired, a request key moves to `old_request_keys`, and the server MUST publish its **private** key there no later than 24 hours after it expired.
{{% boxes/rationale %}}Federation requests carry events, including their full content, and arequest signature binds that content to the sending server. A server thatlogs signed requests would otherwise hold durable proof of what was sent.Publishing a request key's private half once it is retired means anyonecould have produced any signature made with it, so a logged request provesnothing to a third party. Live security is unaffected, because servers neveraccept requests signed with a retired key.
Signing keys are not published, because events in room state must stayunforgeable for as long as the room exists. In [room version 13](/rooms/v13)and later, event signatures do not cover message content, so they do notneed to be.{{% /boxes/rationale %}}
{{% boxes/note %}}Request keys exist because federation still runs over signed HTTP requests.They will be replaced by per-connection message authentication codes whenfederation moves to WebSockets.{{% /boxes/note %}}
{{% http-api spec="server-server" api="keys_server" %}}
#### Querying Keys Through Another Server
Servers may query another server's keys through a notary server. Thenotary server may be another homeserver. The notary server will retrievekeys from the queried servers by fetching their key documents, so itneeds each one's federation path. The notary server willadditionally sign the response from the queried server before returningthe results.
Notary servers can return keys for servers that are offline or havingissues serving their own keys by using cached responses. Keys can bequeried from multiple servers to mitigate against DNS spoofing.
{{% http-api spec="server-server" api="keys_query" %}}
## Authentication
### Request Authentication
Every HTTP request made by a homeserver is authenticated using publickey digital signatures. The request method, target and body are signedby wrapping them in a JSON object and signing it using the [JSON signingalgorithm](/appendices#signing-json) with one of the server's current[request keys](#publishing-keys). Servers MUST NOT sign requests with theirevent signing keys (`verify_keys`). The resulting signatures are addedas an `Authorization` header with an auth scheme of `X-Taper`. Note thatthe target field should include the full path starting with `/_taper/...`,including the `?` and any query parameters if present, but should notinclude the leading `https:`, nor the destination server's hostname.
Step 1 sign JSON:
```nohighlight{ "method": "POST", "uri": "/target", "origin": "origin.hs.example.com", "destination": "destination.hs.example.com", "content": <JSON-parsed request body>, "signatures": { "origin.hs.example.com": { "ed25519:key1": "ABCDEF..." } }}```
The server names in the JSON above are the server names for eachhomeserver involved. Delegation from the [server name resolutionsection](#resolving-server-names) above do not affect these - the servernames from before delegation would take place are used. This samecondition applies throughout the request signing process.
Step 2 add `Authorization` header:
POST /target HTTP/1.1 Authorization: X-Taper origin="origin.hs.example.com",destination="destination.hs.example.com",key="ed25519:key1",sig="ABCDEF..." Content-Type: application/json
<JSON-encoded request body>
Example python code:
```pydef authorization_headers(origin_name, origin_signing_key, destination_name, request_method, request_target, content=None): request_json = { "method": request_method, "uri": request_target, "origin": origin_name, "destination": destination_name, }
if content is not None: # Assuming content is already parsed as JSON request_json["content"] = content
signed_json = sign_json(request_json, origin_name, origin_signing_key)
authorization_headers = []
for key, sig in signed_json["signatures"][origin_name].items(): authorization_headers.append(bytes( "X-Taper origin=\"%s\",destination=\"%s\",key=\"%s\",sig=\"%s\"" % ( origin_name, destination_name, key, sig, ) ))
return ("Authorization", authorization_headers[0])```
The format of the `Authorization` header is given in[Section 11.4 of RFC 9110](https://datatracker.ietf.org/doc/html/rfc9110#section-11.4). Insummary, the header begins with authorisation scheme `X-Taper`, followed by oneor more spaces, followed by a comma-separated list of parameters written asname=value pairs. Zero or more spaces and tabs around each comma are allowed.The names are case insensitive and order does not matter. Thevalues must be enclosed in quotes if they contain characters that are notallowed in `token`s, as defined in[Section 5.6.2 of RFC 9110](https://datatracker.ietf.org/doc/html/rfc9110#section-5.6.2); if avalue is a valid `token`, it may or may not be enclosed in quotes. Quotedvalues may include backslash-escaped characters. When parsing the header, therecipient must unescape the characters. That is, a backslash-character pair isreplaced by the character that follows the backslash.
For compatibility with older servers, the sender should- only include one space after `X-Taper`,- only use lower-case names,- avoid using backslashes in parameter values, and- avoid including whitespace around the commas between name=value pairs.
For compatibility with older servers, the recipient should allow colons to beincluded in values without requiring the value to be enclosed in quotes.
The authorisation parameters to include are:
- `origin`: the server name of the sending server. This is the same as the `origin` field from JSON described in step 1.- `destination`: {{% added-in v="1.3" %}} the server name of the receiving server. This is the same as the `destination` field from the JSON described in step 1. For compatibility with older servers, recipients should accept requests without this parameter, but MUST always send it. If this property is included, but the value does not match the receiving server's name, the receiving server must deny the request with an HTTP status code `401 Unauthorized`.- `key`: the ID, including the algorithm name, of the sending server's request key used to sign the request. The receiving server MUST deny the request with an HTTP status code `401 Unauthorized` unless the key is listed in the sending server's `request_keys`, in a key response whose `valid_until_ts` has not passed. If the key ID is unknown, the receiving server SHOULD fetch the sending server's keys again before denying the request. A key listed in `old_request_keys`, or whose private key has been published, MUST NOT be accepted.- `sig`: the signature of the JSON as calculated in step 1.
Unknown parameters are ignored.
{{% boxes/note %}}{{% changed-in v="1.11" %}}This section used to reference [RFC 7235](https://datatracker.ietf.org/doc/html/rfc7235#section-2.1)and [RFC 7230](https://datatracker.ietf.org/doc/html/rfc9110#section-5.6.2), thatwere obsoleted by RFC 9110 without changes to the sections of interest here.{{% /boxes/note %}}
### Response Authentication
Responses are authenticated by the TLS server certificate. A homeservershould not send a request until it has authenticated the connectedserver to avoid leaking messages to eavesdroppers.
### Client TLS Certificates
Requests are authenticated at the HTTP layer rather than at the TLSlayer because HTTP services like Taper are often deployed behind loadbalancers that handle the TLS and these load balancers make it difficultto check TLS client certificates.
A homeserver may provide a TLS client certificate and the receivinghomeserver may check that the client certificate matches the certificateof the origin homeserver.
## Transactions
The transfer of EDUs and PDUs between homeservers is performed by anexchange of Transaction messages, which are encoded as JSON objects,passed over an HTTP PUT request. A Transaction is meaningful only to thepair of homeservers that exchanged it; they are not globally-meaningful.
Transactions are limited in size; they can have at most 50 PDUs and 100EDUs.
{{% http-api spec="server-server" api="transactions" %}}
## PDUs
Each PDU contains a single Room Event which the origin server wants tosend to the destination.
The `prev_events` field of a PDU identifies the "parents" of the event,and thus establishes a partial ordering on events within the room bylinking them into a Directed Acyclic Graph (DAG). The sending servershould populate this field with all of the events in the room for whichit has not yet seen a child - thus demonstrating that the event comesafter all other known events.
For example, consider a room whose events form the DAG shown below. Aserver creating a new event in this room should populate the new event's`prev_events` field with both `E4` and `E6`, since neither event yet hasa child:
E1 ^ | E2 <--- E5 ^ ^ | | E3 E6 ^ | E4
For a full schema of what a PDU looks like, see the [room versionspecification](/rooms).
### Checks performed on receipt of a PDU
Whenever a server receives an event from a remote server, the receivingserver must ensure that the event:
1. {{% changed-in v="1.16" %}} Is a valid event, otherwise it is dropped. For an event to be valid, it must comply with the event format of that [room version](/rooms). For some room versions, a `room_id` may also be required on the event in order to determine the room version to check the event against. See the event format section of the [room version specifications](/rooms) for details on when it is required.2. Passes signature checks, otherwise it is dropped.3. Passes hash checks, otherwise it is redacted before being processed further.4. Passes authorisation rules based on the event's auth events, otherwise it is rejected.5. Passes authorisation rules based on the state before the event, otherwise it is rejected.6. Passes authorisation rules based on the current state of the room, otherwise it is "soft failed".7. {{% added-in v="1.18" %}} Is [validated](#validating-policy-server-signatures) by the Policy Server, if the room is [using a Policy Server](#determining-if-a-policy-server-is-enabled-in-a-room), otherwise it is "soft failed".
Further details of these checks, and how to handle failures, aredescribed below.
The [Signing Events](#signing-events) section has more information onwhich hashes and signatures are expected on events, and how to calculatethem.
#### Definitions
Required Power Level
: A given event type has an associated *required power level*. This is given by the current [`t.room.power_levels`](/client-server-api/#lroompower_levels) event. The event type is either listed explicitly in the `events` section or given by either `state_default` or `events_default` depending on if the event is a state event or not.
Invite Level, Kick Level, Ban Level, Redact Level
: The levels given by the `invite`, `kick`, `ban`, and `redact` properties in the current [`t.room.power_levels`](/client-server-api/#lroompower_levels) state. The invite level defaults to 0 if unspecified. The kick level, ban level and redact level each default to 50 if unspecified.
Target User
: For an [`t.room.member`](/client-server-api/#lroommember) state event, the user given by the `state_key` of the event.
{{% boxes/warning %}}Some [room versions](/rooms) accept power level values to be represented asstrings rather than integers. This is strictly for backwards compatibility.A homeserver should take reasonable precautions to prevent users from sendingnew power level events with string values (eg: by rejecting the API request),and must never populate the default power levels in a room as string values.
See the [room version specification](/rooms) for more information.{{% /boxes/warning %}}
#### Authorisation rules
The rules governing whether an event is authorised depends on a set ofstate. A given event is checked multiple times against different sets ofstate, as specified above. Each room version can have a differentalgorithm for how the rules work, and which rules are applied. For moredetailed information, please see the [room versionspecification](/rooms).
##### Auth events selection
The `auth_events` field of a PDU identifies the set of events which givethe sender permission to send the event. The `auth_events` for the`t.room.create` event in a room is empty; for other events, it should bethe following subset of the room state:
- {{% changed-in v="1.16" %}} Depending on the [room version](/rooms), the `t.room.create` event.
- The current `t.room.power_levels` event, if any.
- The sender's current `t.room.member` event, if any.
- If type is `t.room.member`:
- The target's current `t.room.member` event, if any. - If `membership` is `join`, `invite` or `knock`, the current `t.room.join_rules` event, if any. - If membership is `invite` and `content` contains a `third_party_invite` property, the current `t.room.third_party_invite` event with `state_key` matching `content.third_party_invite.signed.token`, if any. - If `membership` is `join`, `content.join_authorised_via_users_server` is present, and the [room version supports restricted rooms](/rooms/#feature-matrix), then the `t.room.member` event with `state_key` matching `content.join_authorised_via_users_server`.
#### Rejection
If an event is rejected it should neither be relayed to clients nor beincluded as a prev event in any new events generated by the server.Subsequent events from other servers that reference rejected eventsshould be allowed if they still pass the auth rules. The state used inthe checks should be calculated as normal, except not updating with therejected event where it is a state event.
If an event in an incoming transaction is rejected, this should notcause the transaction request to be responded to with an error response.
{{% boxes/note %}}This means that events may be included in the room DAG even though theyshould be rejected.{{% /boxes/note %}}
{{% boxes/note %}}This is in contrast to redacted events which can still affect the stateof the room. For example, a redacted `join` event will still result inthe user being considered joined.{{% /boxes/note %}}
#### Soft failure
{{% boxes/rationale %}}It is important that we prevent users from evading bans (or other powerrestrictions) by creating events which reference old parts of the DAG.For example, a banned user could continue to send messages to a room byhaving their server send events which reference the event before theywere banned. Note that such events are entirely valid, and we cannotsimply reject them, as it is impossible to distinguish such an eventfrom a legitimate one which has been delayed. We must therefore acceptsuch events and let them participate in state resolution and thefederation protocol as normal. However, servers may choose not to sendsuch events on to their clients, so that end users won't actually seethe events.
When this happens it is often fairly obvious to servers, as they can seethat the new event doesn't actually pass auth based on the "currentstate" (i.e. the resolved state across all forward extremities). Whilethe event is technically valid, the server can choose to not notifyclients about the new event.
This discourages servers from sending events that evade bans etc. inthis way, as end users won't actually see the events.{{% /boxes/rationale %}}
When the homeserver receives a new event over federation it should alsocheck whether the event passes auth checks based on the current state ofthe room (as well as based on the state at the event). If the event doesnot pass the auth checks based on the *current state* of the room (butdoes pass the auth checks based on the state at that event) it should be"soft failed".
When an event is "soft failed" it should not be relayed to the clientnor be referenced by new events created by the homeserver (i.e. theyshould not be added to the server's list of forward extremities of theroom). Soft failed events are otherwise handled as usual.
{{% boxes/note %}}Soft failed events participate in state resolution as normal if furtherevents are received which reference it. It is the job of the stateresolution algorithm to ensure that malicious events cannot be injectedinto the room state via this mechanism.{{% /boxes/note %}}
{{% boxes/note %}}Because soft failed state events participate in state resolution asnormal, it is possible for such events to appear in the current state ofthe room. In that case the client should be told about the soft failedevent in the usual way (e.g. by sending it down in the `state` sectionof a sync response).{{% /boxes/note %}}
{{% boxes/note %}}A soft failed event should be returned in response to federationrequests where appropriate (e.g. in `/event/<event_id>`). Note that softfailed events are returned in `/backfill` and `/get_missing_events`responses only if the requests include events referencing the softfailed events.{{% /boxes/note %}}
Example
As an example consider the event graph:
A / B
where `B` is a ban of a user `X`. If the user `X` tries to set the topicby sending an event `C` while evading the ban:
A / \ B C
servers that receive `C` after `B` should soft fail event `C`, and sowill neither relay `C` to its clients nor send any events referencing`C`.
If later another server sends an event `D` that references both `B` and`C` (this can happen if it received `C` before `B`):
A / \ B C \ / D
then servers will handle `D` as normal. `D` is sent to the servers'clients (assuming `D` passes auth checks). The state at `D` may resolveto a state that includes `C`, in which case clients should also to betold that the state has changed to include `C`. (*Note*: This depends onthe exact state resolution algorithm used. In the original version ofthe algorithm `C` would be in the resolved state, whereas in latterversions the algorithm tries to prioritise the ban over the topicchange.)
Note that this is essentially equivalent to the situation where oneserver doesn't receive `C` at all, and so asks another server for thestate of the `C` branch.
Let's go back to the graph before `D` was sent:
A / \ B C
If all the servers in the room saw `B` before `C` and so soft fail `C`,then any new event `D'` will not reference `C`:
A / \ B C | D'
{{% boxes/note %}}{{% added-in v="1.18" %}}Events can also be soft failed if they fail [Policy Server checks](#validating-policy-server-signatures).{{% /boxes/note %}}
{{% added-in v="1.20" %}}Servers MUST re-evaluate the soft failure of soft failed, unexpired[sticky events](#sticky-events) when the authorising state of the eventchanges, and relay the event to clients if it is no longer soft failed.
Once accepted, an event cannot become soft-failed retrospectively.
#### Retrieving event authorisation information
The homeserver may be missing event authorisation information, or wishto check with other servers to ensure it is receiving the correct authchain. These APIs give the homeserver an avenue for getting theinformation it needs.
{{% http-api spec="server-server" api="event_auth" %}}
## EDUs
EDUs, by comparison to PDUs, do not have an ID, a room ID, or a list of"previous" IDs. They are intended to be non-persistent data such as userpresence, typing notifications, etc.
{{% definition path="api/server-server/definitions/edu_with_example" %}}
## Room State Resolution
The *state* of a room is a map of `(event_type, state_key)` to`event_id`. Each room starts with an empty state, and each state eventwhich is accepted into the room updates the state of that room.
Where each event has a single `prev_event`, it is clear what the stateof the room after each event should be. However, when two branches inthe event graph merge, the state of those branches might differ, so a*state resolution* algorithm must be used to determine the resultantstate.
For example, consider the following event graph (where the oldest event,E0, is at the top):
E0 | E1 / \ E2 E4 | | E3 | \ / E5
Suppose E3 and E4 are both `t.room.name` events which set the name ofthe room. What should the name of the room be at E5?
The algorithm to be used for state resolution depends on the roomversion. For a description of each room version's algorithm, please seethe [room version specification](/rooms).
## Backfilling and retrieving missing events
Once a homeserver has joined a room, it receives all the events emittedby other homeservers in that room, and is thus aware of the entirehistory of the room from that moment onwards. Since users in that roomare able to request the history by the `/messages` client API endpoint,it's possible that they might step backwards far enough into historybefore the homeserver itself was a member of that room.
To cover this case, the federation API provides a server-to-serveranalog of the `/messages` client API, allowing one homeserver to fetchhistory from another. This is the `/backfill` API.
To request more history, the requesting homeserver picks anotherhomeserver that it thinks may have more (most likely this should be ahomeserver for some of the existing users in the room at the earliestpoint in history it has currently), and makes a `/backfill` request.
Similar to backfilling a room's history, a server may not have all theevents in the graph. That server may use the `/get_missing_events` APIto acquire the events it is missing.
{{% http-api spec="server-server" api="backfill" %}}
## Message retention
All servers MUST follow the client-server[Message Retention](/client-server-api/#message-retention) module. Thefollowing rules also apply over federation:
* A server MUST NOT include an event in the response to [`/backfill`](#get_taperfederationv1backfillroomid), [`/get_missing_events`](#post_taperfederationv1get_missing_eventsroomid) or [`/event`](#get_taperfederationv1eventeventid), or in transactions, once the event's expiry time has passed. The exception is a superseded state event that the requester needs for an auth chain, which MUST be served in redacted form only. If a server is asked for a specific expired event, it MUST respond with `404` and the error code `T_EXPIRED`.* When `/backfill` or `/get_missing_events` reaches the start of the retention window, the server MUST return only the unexpired events and stop there. Requesters MUST treat a gap at the start of the window as the start of the room's available history, and MUST NOT go looking for the events before it from other servers.* A receiving server MUST work out each PDU's reference time and expiry time using its own effective lifetime for the room. It MUST NOT persist a non-state PDU whose expiry time has already passed, and it MUST return an error for that PDU in the transaction response. This prevents servers from using backdated events to bring old content back.* A server MUST NOT treat a missing `prev_events` entry as a reason to fetch that event if the entry is a purged [event stub](/client-server-api/#purging), or if its `depth` places it before the start of the retention window.* The `/state`, `/state_ids` and `/send_join` responses include the auth chain. Superseded state events in an auth chain MUST be redacted before they are served if their expiry time has passed.
## Scraping resistance and moves
Servers MUST apply the federation rules of the[Scraping Resistance](/client-server-api/#scraping-resistance) module:budgets and tiers for remote servers, limits on servers new to them, and nopublished room directory over federation.
When a server receives a query or invite for a user who has[moved](/client-server-api/#account-portability), it MUST answer with`T_MOVED`, including `moved_to` and the signed move statement, for at leastthe retention ceiling after the move.
## Retrieving events
In some circumstances, a homeserver may be missing a particular event orinformation about the room which cannot be easily determined frombackfilling. These APIs provide homeservers with the option of gettingevents and the state of the room at a given point in the timeline.
{{% http-api spec="server-server" api="events" %}}
## Joining Rooms
When a new user wishes to join a room that the user's homeserver alreadyknows about, the homeserver can immediately determine if this isallowable by inspecting the state of the room. If it is acceptable, itcan generate, sign, and emit a new `t.room.member` state event addingthe user into that room. When the homeserver does not yet know about theroom it cannot do this directly. Instead, it must take a longermulti-stage handshaking process by which it first selects a remotehomeserver which is already participating in that room, and use it toassist in the joining process. This is the remote join handshake.
This handshake involves the homeserver of the new member wishing to join(referred to here as the "joining" server), the directory server hostingthe room alias the user is requesting to join with, and a homeserverwhere existing room members are already present (referred to as the"resident" server).
In summary, the remote join handshake consists of the joining serverquerying the directory server for information about the room alias;receiving a room ID and a list of join candidates. The joining serverthen requests information about the room from one of the residents. Ituses this information to construct an `t.room.member` event which itfinally sends to a resident server.
Conceptually these are three different roles of homeserver. In practicethe directory server is likely to be resident in the room, and so may beselected by the joining server to be the assisting resident. Likewise,it is likely that the joining server picks the same candidate residentfor both phases of event construction, though in principle any validcandidate may be used at each time. Thus, any join handshake canpotentially involve anywhere from two to four homeservers, though mostin practice will use just two.
<!--https://textart.io/sequence
object Client JoiningServer DirectoryServer ResidentServerClient->JoiningServer: join requestJoiningServer->DirectoryServer: directory requestDirectoryServer->JoiningServer: directory responseJoiningServer->ResidentServer: make_join requestResidentServer->JoiningServer: make_join responseJoiningServer->ResidentServer: send_join requestResidentServer->JoiningServer: send_join responseJoiningServer->Client: join response-->
```nohighlight+---------+ +---------------+ +-----------------+ +-----------------+| Client | | JoiningServer | | DirectoryServer | | ResidentServer |+---------+ +---------------+ +-----------------+ +-----------------+ | | | | | join request | | | |---------------------->| | | | | | | | | directory request | | | |---------------------------->| | | | | | | | directory response | | | |<----------------------------| | | | | | | | make_join request | | | |------------------------------------------------>| | | | | | | |make_join response | | |<------------------------------------------------| | | | | | | send_join request | | | |------------------------------------------------>| | | | | | | |send_join response | | |<------------------------------------------------| | | | | | join response | | | |<----------------------| | | | | | |```
The first part of the handshake usually involves using the directoryserver to request the room ID and join candidates through the[`/query/directory`](/server-server-api/#get_taperfederationv1querydirectory) API endpoint. In the case of a new user joining aroom as a result of a received invite, the joining user's homeservercould optimise this step away by picking the origin server of thatinvite message as the join candidate. However, the joining server shouldbe aware that the origin server of the invite might since have left theroom, so should be prepared to fall back on the regular join flow ifthis optimisation fails.
Once the joining server has the room ID and the join candidates, it thenneeds to obtain enough information about the room to fill in therequired fields of the `t.room.member` event. It obtains this byselecting a resident from the candidate list, and using the`GET /make_join` endpoint. The resident server will then reply withenough information for the joining server to fill in the event.
The joining server is expected to add or replace the `origin`,`origin_server_ts`, and `event_id` on the templated event received by theresident server. The joining server MUST also verify that the `type`, `room_id`,`sender`, `state_key` and `content.membership` fields have the expected values.This event is then signed by the joining server.
To complete the join handshake, the joining server submits this new eventto the resident server it used for `GET /make_join`, using the `PUT /send_join`endpoint.
The resident homeserver then adds its signature to this event andaccepts it into the room's event graph. The joining server receivesthe full set of state for the newly-joined room as well as the freshlysigned membership event. The resident server must also send the eventto other servers participating in the room.
{{% http-api spec="server-server" api="joins-v1" %}}
{{% http-api spec="server-server" api="joins-v2" %}}
### Restricted rooms
Restricted rooms are described in detail in the[client-server API](/client-server-api/#restricted-rooms) and are availablein room versions [which support restricted join rules](/rooms/#feature-matrix).
A resident server processing a request to join a restricted room mustensure that the joining server satisfies at least one of the conditionsspecified by `t.room.join_rules`. If no conditions are available, or nonematch the required schema, then the joining server is considered to havefailed all conditions.
The resident server uses a 400 `T_UNABLE_TO_AUTHORISE_JOIN` error on`/make_join` and `/send_join` to denote that the resident server is unableto validate any of the conditions, usually because the resident serverdoes not have state information about rooms required by the conditions.
The resident server uses a 400 `T_UNABLE_TO_GRANT_JOIN` error on `/make_join`and `/send_join` to denote that the joining server should try a differentserver. This is typically because the resident server can see that thejoining user satisfies one of the conditions, though the resident serverwould be unable to meet the auth rules governing `join_authorised_via_users_server`on the resulting `t.room.member` event.
If the joining server fails all conditions then a 403 `T_FORBIDDEN` erroris used by the resident server.
## Knocking upon a room {#knocking-rooms}
Rooms can permit knocking through the join rules, and if permitted thisgives users a way to request to join (be invited) to the room. Users whoknock on a room where the server is already a resident of the room canjust send the knock event directly without using this process, howevermuch like [joining rooms](/server-server-api/#joining-rooms) the servermust handshake their way into having the knock sent on its behalf.
The handshake is largely the same as the joining rooms handshake, whereinstead of a "joining server" there is a "knocking server", and the APIsto be called are different (`/make_knock` and `/send_knock`).
Servers can retract knocks over federation by leaving the room, as describedbelow for rejecting invites.
{{% http-api spec="server-server" api="knocks" %}}
## Inviting to a room
When a user on a given homeserver invites another user on the samehomeserver, the homeserver may sign the membership event itself and skipthe process defined here. However, when a user invites another user on adifferent homeserver, a request to that homeserver to have the eventsigned and verified must be made.
Note that invites are used to indicate that knocks were accepted. As such,receiving servers should be prepared to manually link up a previous knockto an invite if the invite event does not directly reference the knock.
{{% boxes/note %}}{{% added-in v="1.16" %}} `invite_room_state` MUST now have its entries formattedaccording to the room's version (see [room version specification](/rooms)). However,servers SHOULD consider their local ecosystems before returning the described`400 T_MISSING_PARAM` error code. While migrating, servers SHOULD warn aboutinvites which fail the validation rather than error in room versions 1 through 11.All invites to other room versions which fail validation SHOULD result in an error.
The specification suggests that servers finish their migration no later thanJanuary 2026, though servers may extend this as required to support their users.{{% /boxes/note %}}
{{% http-api spec="server-server" api="invites-v1" %}}
{{% http-api spec="server-server" api="invites-v2" %}}
## Leaving Rooms (Rejecting Invites)
Normally homeservers can send appropriate `t.room.member` events to haveusers leave the room, to reject local invites, or to retract a knock.Remote invites/knocks from other homeservers do not involve the server in thegraph and therefore need another approach to reject the invite. Joiningthe room and promptly leaving is not recommended as clients and servers willinterpret that as accepting the invite, then leaving the room ratherthan rejecting the invite.
Similar to the [Joining Rooms](#joining-rooms) handshake, the serverwhich wishes to leave the room starts with sending a `/make_leave`request to a resident server. In the case of rejecting invites, theresident server may be the server which sent the invite. After receivinga template event from `/make_leave`, the leaving server signs the eventand replaces the `event_id` with its own. This is then sent to theresident server via `/send_leave`. The resident server will then sendthe event to other servers in the room.
{{% http-api spec="server-server" api="leaving-v1" %}}
{{% http-api spec="server-server" api="leaving-v2" %}}
## Third-party invites
{{% boxes/note %}}More information about third-party invites is available in the Client-Server APIunder the [Third-party invites](/client-server-api/#third-party-invites) module.{{% /boxes/note %}}
When a user wants to invite another user in a room but doesn't know theTaper ID to invite, they can do so using a third-party identifier (e.g.an e-mail or a phone number).
This identifier and its bindings to Taper IDs are verified by anidentity server implementing the [Identity ServiceAPI](/identity-service-api).
### Cases where an association exists for a third-party identifier
If the third-party identifier is already bound to a Taper ID, a [lookuprequest](/identity-service-api/#post_taperidentityv2lookup) on the identityserver will return it. The invite is then processed by the inviting homeserveras a [standard `t.room.member` invite event](#inviting-to-a-room). This is thesimplest case.
### Cases where an association doesn't exist for a third-party identifier
If the third-party identifier isn't bound to any Taper ID, the invitinghomeserver will request the identity server to [store an invite](/identity-service-api/#invitation-storage)for this identifier and to deliver it to whoever binds it to its Taper ID. Itwill also send an [`t.room.third_party_invite`](/client-server-api/#lroomthird_party_invite)event in the room to specify a display name, a token and public keys theidentity server provided as a response to the invite storage request.
When a third-party identifier with pending invites gets bound to a Taper ID,the identity server will send a request to the [`/3pid/onbind`](#post_taperfederationv13pidonbind)endpoint of the the ID's homeserver as described in the [InvitationStorage](/identity-service-api#invitation-storage) section of the IdentityService API.
The following process applies for each invite sent by the identityserver:
The invited homeserver will create an [`t.room.member`](/client-server-api/#lroommember)invite event containing a special `third_party_invite` section containing thetoken and a `signed` object, both provided by the identity server.
If the invited homeserver is in the room the invite came from, it canauth the event and send it.
However, if the invited homeserver isn't in the room the invite camefrom, it will need to request the inviting homeserver to auth the eventat the [`/exchange_third_party_invite`](#put_taperfederationv1exchange_third_party_inviteroomid)endpoint.
{{% http-api spec="server-server" api="third_party_invite" %}}
#### Verifying the invite
When a homeserver receives an `t.room.member` invite event for a roomit's in with a `third_party_invite` object, it must verify that theassociation between the third-party identifier initially invited to theroom and the Taper ID that claims to be bound to it has been verifiedwithout having to rely on a third-party server.
To do so, it will fetch from the room's state events the`t.room.third_party_invite` event for which the state key matches withthe value for the `token` key in the `third_party_invite` object fromthe `t.room.member` event's content to fetch the public keys initiallydelivered by the identity server that stored the invite.
It will then use these keys to verify that the `signed` object (in the`third_party_invite` object from the `t.room.member` event's content)was signed by the same identity server.
Since this `signed` object can only be delivered once in the POSTrequest emitted by the identity server upon binding between thethird-party identifier and the Taper ID, and contains the inviteduser's Taper ID and the token delivered when the invite was stored,this verification will prove that the `t.room.member` invite event comesfrom the user owning the invited third-party identifier.
## Published Room Directory
To complement the [room directory in the Client-Server API](/client-server-api#published-room-directory),homeservers need a way to query the published rooms of another server.This can be done by making a request to the `/publicRooms` endpoint forthe server the room directory should be retrieved for.
{{% http-api spec="server-server" api="public_rooms" %}}
## Spaces
To complement the [Client-Server API's Spaces module](/client-server-api/#spaces),homeservers need a way to query information about spaces from other servers.
{{% http-api spec="server-server" api="space_hierarchy" %}}
## Typing Notifications
When a server's users send typing notifications, those notificationsneed to be sent to other servers in the room so their users are aware ofthe same state. Receiving servers should verify that the user is in theroom, and is a user belonging to the sending server.
{{% definition path="api/server-server/definitions/event-schemas/t.typing" %}}
## Presence
The server API for presence is based entirely on exchange of thefollowing EDUs. There are no PDUs or Federation Queries involved.
Servers should only send presence updates for users that the receivingserver would be interested in. Such as the receiving server sharing aroom with a given user.
{{% definition path="api/server-server/definitions/event-schemas/t.presence" %}}
## Receipts
Receipts are EDUs used to communicate a marker for a given event.Currently the only kind of receipt supported is a "read receipt", orwhere in the event graph the user has read up to.
Read receipts for events that a user sent do not need to be sent. It isimplied that by sending the event the user has read up to the event.
{{% definition path="api/server-server/definitions/event-schemas/t.receipt" %}}
## Sticky Events
{{% added-in v="1.20" %}}
[Sticky events](/client-server-api/#sticky-events) are a primitive thatallows clients to share temporary state within a room without having torely on state events. Within the federation event format of every[room version](/rooms), an event is marked as [sticky](/client-server-api/#sticky-events)by a top-level `sticky` object with a `duration_ms` property that containsthe total sticky duration requested by the sender.
```json{ "type": "org.example.event", "sticky": { "duration_ms": 600000 }, "sender": "@alice:example.com", "room_id": "!foo:example.com", "origin_server_ts": 1757920344000, "content": { ... }}```
Servers calculate whether a sticky event is still sticky or has expired asdescribed in the [Client-Server API](/client-server-api/#determining-whether-an-event-is-sticky).
Servers MUST attempt to push their own unexpired sticky events in a room toall joined servers, whilst respecting per-server backoff times. Large volumesof events to send MUST NOT cause an unexpired sticky event to be dropped fromthe send queue of the server. When a new server joins a room, servers MUSTattempt to push all of their own unexpired sticky events in the room to thenew server. Servers SHOULD, on a best-effort basis, push unexpired stickyevents to other homeservers in the order they were created on the server.
Servers MUST NOT apply [history visibility](/client-server-api/#room-history-visibility)checks to unexpired sticky events. Any joined server is authorised to seeunexpired sticky events for as long as they remain sticky.
Servers MUST apply [Policy Servers](#policy-servers) and similarhomeserver-specific anti-spam techniques to sticky events received overfederation. If any of these techniques classifies a sticky event as spam,the event MUST be treated as a regular non-sticky event.
{{% boxes/warning %}}Receiving old sticky events may increase the number of forward extremitiesin the room on the receiving server, which may impact the performance ofstate resolution if there are many forward extremities. Servers MAY senddummy events to reduce the number of forward extremities. Alternatively,servers MAY choose not to add old sticky events to their forwardextremities.{{% /boxes/warning %}}
When an unexpired sticky event was sent by a user who has been erased, forexample using the `erase` flag of[`POST /_taper/client/v3/account/deactivate`](/client-server-api/#post_taperclientv3accountdeactivate),servers SHOULD NOT send it to other homeservers as part of catching up.
Servers MAY rate limit sticky events received over federation. For instance,servers MAY delay the persistence of such events, or persist the sticky eventsbut delay delivering them to clients. Servers MAY also limit the number ofunexpired sticky events of a given sender, as described in the[Client-Server API](/client-server-api/#sticky-events).
## Querying for information
Queries are a way to retrieve information from a homeserver about aresource, such as a user or room. The endpoints here are often called inconjunction with a request from a client on the client-server API inorder to complete the call.
There are several types of queries that can be made. The genericendpoint to represent all queries is described first, followed by themore specific queries that can be made.
{{% http-api spec="server-server" api="query" %}}
## OpenID
Third-party services can exchange an access token previously generatedby the [OpenID module of the Client-ServerAPI](/client-server-api/#openid) for information about a user. This canhelp verify that a user is who they say they are without granting fullaccess to the user's account.
Access tokens generated by the OpenID API are only good for the OpenIDAPI and nothing else.
{{% http-api spec="server-server" api="openid" %}}
## Device Management
Details of a user's devices must be efficiently published to other usersand kept up-to-date. This is critical for reliable end-to-endencryption, in order for users to know which devices are participatingin a room. It's also required for to-device messaging to work. Thissection is intended to complement the [Device Managementmodule](/client-server-api#device-management)of the Client-Server API.
Taper currently uses a custom pubsub system for synchronisinginformation about the list of devices for a given user over federation.When a server wishes to determine a remote user's device list for thefirst time, it should populate a local cache from the result of a`/user/keys/query` API on the remote server. However, subsequent updatesto the cache should be applied by consuming `t.device_list_update` EDUs.Each new `t.device_list_update` EDU describes an incremental change toone device for a given user which should replace any existing entry inthe local server's cache of that device list. Servers must send`t.device_list_update` EDUs to all the servers who share a room with agiven local user, and must be sent whenever that user's device listchanges (i.e. for new or deleted devices, when that user joins a roomwhich contains servers which are not already receiving updates for thatuser's device list, or changes in device information such as thedevice's human-readable name).
Servers send `t.device_list_update` EDUs in a sequence per origin user,each with a unique `stream_id`. They also include a pointer to the mostrecent previous EDU(s) that this update is relative to in the `prev_id`field. To simplify implementation for clustered servers which could sendmultiple EDUs at the same time, the `prev_id` field should include all`t.device_list_update` EDUs which have not been yet been referenced in aEDU. If EDUs are emitted in series by a server, there should only everbe one `prev_id` in the EDU.
This forms a simple directed acyclic graph of `t.device_list_update`EDUs, showing which EDUs a server needs to have received in order toapply an update to its local copy of the remote user's device list. If aserver receives an EDU which refers to a `prev_id` it does notrecognise, it must resynchronise its list by calling the`/user/keys/query API` and resume the process. The response contains a`stream_id` which should be used to correlate with subsequent`t.device_list_update` EDUs.
{{% http-api spec="server-server" api="user_devices" %}}
{{% definition path="api/server-server/definitions/event-schemas/t.device_list_update" %}}
## End-to-End Encryption
This section complements the [End-to-End Encryptionmodule](/client-server-api#end-to-end-encryption)of the Client-Server API. For detailed information about end-to-endencryption, please see that module.
The APIs defined here are designed to be able to proxy much of theclient's request through to federation, and have the response also beproxied through to the client.
{{% http-api spec="server-server" api="user_keys" %}}
{{% definition path="api/server-server/definitions/event-schemas/t.signing_key_update" %}}
## Send-to-device messaging
The server API for send-to-device messaging is based on the`t.direct_to_device` EDU. There are no PDUs or Federation Queriesinvolved.
Each send-to-device message should be sent to the destination serverusing the following EDU:
{{% definition path="api/server-server/definitions/event-schemas/t.direct_to_device" %}}
## Content Repository
Attachments to events (images, files, etc) are uploaded to a homeservervia the Content Repository described in the [Client-ServerAPI](/client-server-api/#content-repository). When a server wishesto serve content originating from a remote server, it needs to ask theremote server for the media.
Servers MUST use the server described in the [Taper Content URI](/client-server-api/#taper-content-runit-uris).Formatted as `runit://{ServerName}/{MediaID}`, servers MUST download the media from`ServerName` using the below endpoints.
{{% changed-in v="1.11" %}} Servers were previously advised to use the `/_taper/media/*`endpoints described by the [Content Repository module in the Client-Server API](/client-server-api/#content-repository),however, those endpoints have been deprecated. New endpoints are introduced whichrequire authentication. Naturally, as a server is not a user, they cannot providethe required access token to those endpoints. Instead, servers MUST try the endpointsdescribed below before falling back to the deprecated `/_taper/media/*` endpointswhen they receive a `404 T_UNRECOGNIZED` error. When falling back, servers MUSTbe sure to set `allow_remote` to `false`.
{{% http-api spec="server-server" api="content_repository" %}}
## Server Access Control Lists (ACLs)
Server ACLs and their purpose are described in the [ServerACLs](/client-server-api#server-access-control-lists-acls-for-rooms)section of the Client-Server API.
When a remote server makes a request, it MUST be verified to be allowedby the server ACLs. If the server is denied access to a room, thereceiving server MUST reply with a 403 HTTP status code and an `errcode`of `T_FORBIDDEN`.
The following endpoint prefixes MUST be protected:
- `/_taper/federation/v1/make_join`- `/_taper/federation/v1/make_leave`- `/_taper/federation/v1/send_join`- `/_taper/federation/v2/send_join`- `/_taper/federation/v1/send_leave`- `/_taper/federation/v2/send_leave`- `/_taper/federation/v1/invite`- `/_taper/federation/v2/invite`- `/_taper/federation/v1/make_knock`- `/_taper/federation/v1/send_knock`- `/_taper/federation/v1/state`- `/_taper/federation/v1/state_ids`- `/_taper/federation/v1/backfill`- `/_taper/federation/v1/event_auth`- `/_taper/federation/v1/get_missing_events`
Additionally the [`/_taper/federation/v1/send/{txnId}`](#put_taperfederationv1sendtxnid)endpoint MUST be protected as follows:
- ACLs MUST be applied to all PDUs on a per-PDU basis. If the sending server is denied access to the room identified by `room_id`, the PDU MUST be ignored with an appropriate error included in the response for the respective event ID.- ACLs MUST be applied to all EDUs that are local to a specific room:
- For [typing notifications (`t.typing`)](#typing-notifications), if the sending server is denied access to the room identified by `room_id`, the EDU MUST be ignored. - For [receipts (`t.receipt`)](#receipts), all receipts for a particular room ID MUST be ignored if the sending server is denied access to the room identified by that ID.
The following endpoints MAY be protected:
- [`/_taper/policy/v1/sign`](#post_taperpolicyv1sign) - {{< added-in v="1.18" >}} Protected if the server is tracking the DAG and chooses to enforce the ACL.
## Policy Servers
{{% added-in v="1.18" %}}
Policy Servers are an available tool for rooms to add proactive protections. Roomswhich use a Policy Server (PS) can prevent unwanted events from reaching users. Roomsare not required to use a Policy Server, and can disable it any time after enablingit.
For a homeserver to be a Policy Server, it MUST implement the following functionalityof the Server-Server API:
* [Normal server name resolution](#resolving-server-names).* [Publishing a signing key](#publishing-keys).* [Request authentication](#authentication).* Being able to [make and send join requests](#joining-rooms).* Receiving and processing [`POST /_taper/policy/v1/sign`](#post_taperpolicyv1sign) requests.
All other functionality and endpoints are optional for a Policy Server.
{{% boxes/note %}}Though a Policy Server is not required to implement the full Server-Server APIsurface, some functionality may be desirable to implement anyway:
* Receiving [invites](#inviting-to-a-room) can make it easier to add the Policy Server to a room.* Receiving [transactions](#transactions) is recommended to avoid remote servers flagging the Policy Server as "offline", even if the contents are discarded.* Receiving [device lookups](#get_taperfederationv1userdevicesuserid) can also help reduce remote servers flagging the Policy Server as "offline".{{% /boxes/note %}}
{{% boxes/note %}}Policy Servers are *not* required to track the DAG for a room. Policy Serversmight be optimized for content moderation and therefore do not need knowledge ofthe DAG.{{% /boxes/note %}}
### Determining if a Policy Server is enabled in a room
For a room to be considered as "using" a Policy Server, *all* of the followingconditions MUST be true:
* The *current state* for the room has a valid [`t.room.policy`](/client-server-api/#lroompolicy) state event with empty state key. Valid means `content` contains at least: * A string value for `via`. * An object value for `public_keys` containing at least a string value for `ed25519`.* The server name denoted by the `t.room.policy` state event's `via` has at least one joined user in the room in *current state*. The user does not need any special permissions or power levels in the room.
If a room has enabled a Policy Server, *all* servers in that room MUST [ask thatPolicy Server](#asking-for-a-policy-server-signature-on-an-event) for a signaturebefore sending an event. If the Policy Server refuses to sign the event beingsent, servers SHOULD fail to send that event as per the [validation rules](#validating-policy-server-signatures).
{{% boxes/note %}}"Current state" shares the same definition as [soft failure](#soft-failure).{{% /boxes/note %}}
{{% boxes/note %}}Policy Servers MUST have at least one joined user in the room to give the PolicyServer agency in whether it serves that role for the room. Otherwise, a roomwould be able to force a Policy Server to participate and then overwhelm it.{{% /boxes/note %}}
### Validating Policy Server signatures
Policy Servers use signatures to indicate whether an event was checked and isrecommended for inclusion in a room. The Policy Server's recommendation does *not*affect the authorization rules for an event, but does affect whether homeservers[soft fail](#soft-failure) or refuse to actually go forward with sending an event.
If a room has disabled (or never enabled) a Policy Server, events are recommendedfor inclusion and subject to normal authorization rules.
{{% boxes/note %}}Because the Policy Server is not asked to sign [`t.room.policy`](/client-server-api/#lroompolicy)state events with empty string `state_key`s, those events will not have a PolicyServer signature. Those events are by default recommended for inclusion and stillsubject to normal authorization rules.
All other events SHOULD have a valid Policy Server signature when a Policy Serveris enabled in the room, including non-state `t.room.policy` events and `t.room.policy`state events with non-empty `state_key`s. This also includes state events likemembership and power level changes.{{% /boxes/note %}}
If a room has enabled a Policy Server, the Policy Server's signature appearsalongside the normal [event signatures](#signing-events), though uses a publickey from the room's `t.room.policy` state event.
{{% boxes/note %}}Currently, only Ed25519 keys are supported by homeservers. The Key ID for the`ed25519` key in `t.room.policy` is *always* `ed25519:policy_server`.{{% /boxes/note %}}
{{% boxes/note %}}By embedding the Policy Server's public key into room state, the Policy Serverdoes not need to be online or have its keys cached by a notary in order to validatean event.{{% /boxes/note %}}
{{% boxes/warning %}}The Policy Server's [published signing key](#publishing-keys) SHOULD NOT be thesame key contained in the `t.room.policy` state event. This is to keep "can sendfederation traffic" and "can recommend events for inclusion" separate, and toallow rooms to revoke the Policy Server's key without cooperation of the PolicyServer.
If the Policy Server is acting as a normal homeserver and attempting to send anevent, that event will require a signature from the server's published signingkey alongside the Policy Server signature described in this section.{{% /boxes/warning %}}
If the Policy Server's signature is valid, the event is recommended for inclusionin the room, and is still subject to normal authorization rules.
If the Policy Server's signature is invalid or missing, the homeserver SHOULD[ask for a new signature](#asking-for-a-policy-server-signature-on-an-event). Ifthe event still does not have a valid Policy Server signature, the event is *not*recommended for inclusion and the homeserver SHOULD:
* If applicable, reject the Client-Server API request which was generating the event. If the Policy Server returned an error, that error SHOULD be provided to the client verbatim. The event the client was attempting to send SHOULD be discarded and not processed/sent any further.* If the event was received over federation or the homeserver sends a local client's event anyway, [soft fail](#soft-failure) the event.
{{% boxes/note %}}For clarity, an event which lacks a valid Policy Server signature is still subjectto normal authorization rules.{{% /boxes/note %}}
{{% boxes/note %}}When a Policy Server's signature is invalid, a new one is requested because thePolicy Server's key may have rotated between the event being signed and the eventbeing checked.
Because the key is contained in the `t.room.policy` state event, if the PolicyServer rotates its key without the room also updating the state event, eventswill be flagged as not recommended for inclusion. This is expected behaviour.{{% /boxes/note %}}
### Asking for a Policy Server signature on an event
Per [above](#determining-if-a-policy-server-is-enabled-in-a-room), if a room hasa Policy Server enabled, *all* servers in the room MUST ask the Policy Server tosign their events before sending them to clients and servers.
After asking for a signature, homeservers SHOULD [validate](#validating-policy-server-signatures)the returned signature before continuing to send events. If the Policy Serverreturns an error, the event SHOULD NOT be sent to clients and servers.
{{% http-api spec="server-server" api="room_policy" %}}
## Signing Events
Signing events is complicated by the fact that servers can choose toredact non-essential parts of an event.
### Adding hashes and signatures to outgoing events
Before signing the event, the *content hash* of the event is calculatedas described below. The hash is encoded using [UnpaddedBase64](/appendices#unpadded-base64) and stored in the eventobject, in a `hashes` object, under a `sha256` key.
The event object is then *redacted*, following the [redactionalgorithm](/client-server-api#redactions).Finally it is signed as described in [SigningJSON](/appendices#signing-json), using the server's signing key(see also [Retrieving server keys](#retrieving-server-keys)).
The signature is then copied back to the original event object.
For an example of a signed event, see the [room versionspecification](/rooms).
{{% boxes/note %}}{{% added-in v="1.18" %}}Events sent in rooms with [Policy Servers](#policy-servers) MUST [ask](#asking-for-a-policy-server-signature-on-an-event)the Policy Server for a signature too.{{% /boxes/note %}}
### Validating hashes and signatures on received events
When a server receives an event over federation from another server, thereceiving server should check the hashes and signatures on that event.
First the signatures are checked. The event is redacted following the[redaction algorithm](/client-server-api#redactions), andthe resultant object is checked for signatures from the originatingserver, following the algorithm described in [Checking for asignature](/appendices#checking-for-a-signature). Note that thisstep should succeed whether we have been sent the full event or aredacted copy.
For room versions 3 and later, unless the event is a 3rd party invite, only thesignature(s) from the originating server (the server the `sender` belongs to)are required for verification. Room versions 1 and 2 also require that asignature is present from the domain in the `event_id`, if it differs from theoriginating server. If a signature is from an unknown or expired key, it isskipped.
If the event is a 3rd party invite, the sender must already match the 3rd partyinvite, and the server which actually sends the event may be a differentserver.
Only signatures from known server keys are validated here. Any unknown keys are ignored.In particular, the [policy server key](#validating-policy-server-signatures) is notexpected to be published and therefore should be skipped at this stage.Additionally, any keys that are known to have expired prior to the event's`origin_server_ts` are ignored.
{{% boxes/note %}}{{% added-in v="1.18" %}}Events sent in rooms with [Policy Servers](#policy-servers) have [additional](#validating-policy-server-signatures)signature validation requirements.{{% /boxes/note %}}
If all signatures from known unexpired keys from the originating server(s) arefound to be valid, the expected content hash is calculated as described below.The content hash in the `hashes` property of the received event is base64-decoded,and the two are compared for equality.
If the hash check fails, then it is assumed that this is because we haveonly been given a redacted version of the event. To enforce this, thereceiving server should use the redacted copy it calculated rather thanthe full copy it received.
### Calculating the reference hash for an event
The *reference hash* of an event covers the essential fields of anevent, including content hashes. It is used for event identifiers insome room versions. See the [room versionspecification](/rooms) for more information. It iscalculated as follows.
1. The event is put through the redaction algorithm.2. The `signatures` and `unsigned` properties are removed from the event, if present.3. The event is converted into [Canonical JSON](/appendices#canonical-json).4. A sha256 hash is calculated on the resulting JSON object.
### Calculating the content hash for an event
The *content hash* of an event covers the complete event including the*unredacted* contents. It is calculated as follows.
{{% boxes/note %}}In [room version 13](/rooms/v13#content-hash) and later, the content hash of anon-state event is calculated over the *redacted* event instead, so it doesnot cover message content. In those room versions, a content hash mismatch ona non-state event means the event was tampered with, and the event isrejected rather than treated as a redacted copy.{{% /boxes/note %}}
First, any existing `unsigned`, `signatures`, and `hashes` properties areremoved. The resulting object is then encoded as [CanonicalJSON](/appendices#canonical-json), and the JSON is hashed usingSHA-256.
### Example code
```pydef hash_and_sign_event(event_object, signing_key, signing_name): # First we need to hash the event object. content_hash = compute_content_hash(event_object) event_object["hashes"] = {"sha256": encode_unpadded_base64(content_hash)}
# Strip all the keys that would be removed if the event was redacted. # The hashes are not stripped and cover all the keys in the event. # This means that we can tell if any of the non-essential keys are # modified or removed. stripped_object = strip_non_essential_keys(event_object)
# Sign the stripped JSON object. The signature only covers the # essential keys and the hashes. This means that we can check the # signature even if the event is redacted. signed_object = sign_json(stripped_object, signing_key, signing_name)
# Copy the signatures from the stripped event to the original event. event_object["signatures"] = signed_object["signatures"]
def compute_content_hash(event_object): # take a copy of the event before we remove any keys. event_object = dict(event_object)
# Keys under "unsigned" can be modified by other servers. # They are useful for conveying information like the age of an # event that will change in transit. # Since they can be modified we need to exclude them from the hash. event_object.pop("unsigned", None)
# Signatures will depend on the current value of the "hashes" key. # We cannot add new hashes without invalidating existing signatures. event_object.pop("signatures", None)
# The "hashes" key might contain multiple algorithms if we decide to # migrate away from SHA-2. We don't want to include an existing hash # output in our hash so we exclude the "hashes" dict from the hash. event_object.pop("hashes", None)
# Encode the JSON using a canonical encoding so that we get the same # bytes on every server for the same JSON object. event_json_bytes = encode_canonical_json(event_object)
return hashlib.sha256(event_json_bytes)```
## Security considerations
When a domain's ownership changes, the new controller of the domain canmasquerade as the previous owner, receiving messages (similarly toemail) and request past messages from other servers. In the future,proposals like[MSC1228](https://github.com/matrix-org/matrix-spec-proposals/issues/1228) willaddress this issue.1234567891011121314151617181920212223242526272829303132# Copyright 2018 New Vector 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.properties: alias: description: An alias for a taper room. type: string example: "#freenode_#matrix:matrix.org" protocol: description: The protocol ID that the third-party location is a part of. type: string example: "irc" fields: description: Information used to identify this third-party location. type: object example: { "network": "freenode", "channel": "#matrix" }required: ['alias', 'protocol', 'fields']title: Locationtype: object1234567891011121314151617# Copyright 2018 New Vector 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.type: arraydescription: List of matched third-party locations.items: $ref: location.yaml1234567891011121314151617181920212223242526272829# 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.$schema: https://json-schema.org/draft/2020-12/schema
type: arrayitems: type: object title: Namespace properties: regex: type: string description: A POSIX regular expression defining which values this namespace includes. exclusive: type: boolean description: A true or false value stating whether this application service has exclusive access to events within this namespace. required: - regex - exclusive1234567891011121314151617181920212223242526# Copyright 2018 New Vector 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.allOf:- $ref: protocol_base.yaml- type: object properties: instances: description: |- A list of objects representing independent instances of configuration. For example, multiple networks on IRC if multiple are provided by the same application service. type: array items: $ref: protocol_instance.yaml required: ['instances']1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980# Copyright 2018 New Vector 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.title: Protocoltype: objectproperties: user_fields: description: |- Fields which may be used to identify a third-party user. These should be ordered to suggest the way that entities may be grouped, where higher groupings are ordered first. For example, the name of a network should be searched before the nickname of a user. type: array items: type: string description: Field used to identify a third-party user. example: ["network", "nickname"] location_fields: description: |- Fields which may be used to identify a third-party location. These should be ordered to suggest the way that entities may be grouped, where higher groupings are ordered first. For example, the name of a network should be searched before the name of a channel. type: array items: type: string description: Field used to identify a third-party location. example: ["network", "channel"] icon: description: A content URI representing an icon for the third-party protocol. type: string example: "runit://example.org/aBcDeFgH" field_types: description: |- The type definitions for the fields defined in `user_fields` and `location_fields`. Each entry in those arrays MUST have an entry here. The `string` key for this object is the field name itself.
May be an empty object if no fields are defined. type: object additionalProperties: title: Field Type description: Definition of valid values for a field. type: object properties: regexp: description: |- A regular expression for validation of a field's value. This may be relatively coarse to verify the value as the application service providing this protocol may apply additional validation or filtering. type: string placeholder: description: A placeholder serving as a valid example of the field value. type: string required: ['regexp', 'placeholder'] example: { "network": { "regexp": "([a-z0-9]+\\.)*[a-z0-9]+", "placeholder": "irc.example.org" }, "nickname": { "regexp": "[^\\s#]+", "placeholder": "username" }, "channel": { "regexp": "#[^\\s]+", "placeholder": "#foobar" } }required: ['user_fields', 'location_fields', 'icon', 'field_types']12345678910111213141516171819202122232425262728293031323334353637# Copyright 2018 New Vector 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.type: objecttitle: Protocol Instanceproperties: desc: type: string description: A human-readable description for the protocol, such as the name. example: "Freenode" icon: type: string description: |- An optional content URI representing the protocol. Overrides the one provided at the higher level Protocol object. example: "runit://example.org/JkLmNoPq" fields: type: object description: Preset values for `fields` the client may use to search by. example: { "network": "freenode" } network_id: type: string description: A unique identifier across all instances. example: "freenode"required: ['desc', 'fields', 'network_id']12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485# 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.$schema: https://json-schema.org/draft/2020-12/schema
type: objecttitle: Registrationproperties: id: type: string description: A unique, user-defined ID of the application service which will never change. url: type: ["null", "string"] description: The URL for the application service. May include a path after the domain name. Optionally set to null if no traffic is required. as_token: type: string description: A secret token that the application service will use to authenticate requests to the homeserver. hs_token: type: string description: A secret token that the homeserver will use to authenticate requests to the application service. sender_localpart: type: string description: |- The localpart of the user associated with the application service. Events will be sent to the AS if this user is the target of the event, or is a joined member of the room where the event occurred. receive_ephemeral: type: boolean x-addedInMatrixVersion: "1.13" description: |- Whether the application service wants to [receive ephemeral data](/application-service-api/#pushing-ephemeral-data). Defaults to `false` if not present. namespaces: type: object title: Namespaces description: The namespaces that the application service is interested in. properties: users: allOf: - $ref: namespace_list.yaml - description: |- A list of namespaces defining the user IDs that the application service is interested in, in addition to its `sender_localpart`. Events will be sent to the AS if a local user matching one of the namespaces is the target of the event, or is a joined member of the room where the event occurred. rooms: allOf: - $ref: namespace_list.yaml - description: |- A list of namespaces defining the room IDs that the application service is interested in. All events sent in a room with an ID which matches one of the namespaces will be sent to the AS. aliases: allOf: - $ref: namespace_list.yaml - description: |- A list of namespaces defining the room aliases that the application service is interested in. All events sent in a room with an alias which matches one of the namespaces will be sent to the AS. rate_limited: type: boolean description: Whether requests from masqueraded users are rate-limited. The sender is excluded. protocols: type: array description: The external protocols which the application service provides (e.g. IRC). items: type: stringrequired: - id - url - as_token - hs_token - sender_localpart - namespaces123456789101112131415161718# 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.homeserverAccessToken: type: http scheme: bearer description: The `Bearer` `hs_token` provided by the application service's registration.123456789101112131415161718192021222324252627282930313233# Copyright 2018 New Vector 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.
# TODO: Change userid to user_id as a breaking changeproperties: userid: description: A Taper User ID representing a third-party user. type: string example: "@_gitter_jim:matrix.org" protocol: description: The protocol ID that the third-party location is a part of. type: string example: "gitter" fields: description: Information used to identify this third-party location. type: object example: { "user": "jim" }required: ['userid', 'protocol', 'fields']title: Usertype: object1234567891011121314151617# Copyright 2018 New Vector 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.type: arraydescription: List of matched third-party users.items: $ref: user.yaml12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273# Copyright 2023 Tulir Asokan## 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.0info: title: Taper Application Service API version: 1.0.0paths: /ping: post: x-addedInMatrixVersion: "1.7" summary: Ping the application service description: |- This API is called by the homeserver to ensure that the connection works and the `hs_token` the homeserver has is correct.
Currently this is only called by the homeserver as a direct result of the application service calling [`POST /_taper/client/v1/appservice/{appserviceId}/ping`](/application-service-api/#post_taperclientv1appserviceappserviceidping). operationId: ping security: - homeserverAccessToken: [] requestBody: content: application/json: schema: type: object example: { "transaction_id": "mautrix-go_1683636478256400935_123" } properties: transaction_id: type: string description: |- A transaction ID for the ping, copied directly from the `POST /_taper/client/v1/appservice/{appserviceId}/ping` call. description: Ping body with optional transaction ID. responses: "200": description: The provided `hs_token` is valid and the ping request was successful. content: application/json: schema: type: object examples: response: value: {}servers: - url: "{protocol}://{hostname}{basePath}" variables: protocol: enum: - http - https default: https hostname: default: localhost:8008 basePath: default: /_taper/app/v1components: securitySchemes: homeserverAccessToken: $ref: definitions/security.yaml#/homeserverAccessToken123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343# Copyright 2018 New Vector 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.0info: title: Taper Application Service API version: 1.0.0paths: "/thirdparty/protocol/{protocol}": get: summary: Retrieve metadata about a specific protocol that the application service supports. description: |- This API is called by the homeserver when it wants to present clients with specific information about the various third-party networks that an application service supports. operationId: getProtocolMetadata security: - homeserverAccessToken: [] parameters: - in: path name: protocol description: The protocol ID. required: true example: irc schema: type: string responses: "200": description: The protocol was found and metadata returned. content: application/json: schema: $ref: definitions/protocol.yaml "401": description: |- The homeserver has not supplied credentials to the application service. Optional error information can be included in the body of this response. content: application/json: schema: $ref: ../client-server/definitions/errors/error.yaml examples: response: value: { "errcode": "COM.EXAMPLE.MYAPPSERVICE_UNAUTHORIZED" } "403": description: The credentials supplied by the homeserver were rejected. content: application/json: schema: $ref: ../client-server/definitions/errors/error.yaml examples: response: value: { "errcode": "COM.EXAMPLE.MYAPPSERVICE_FORBIDDEN" } "404": description: No protocol was found with the given path. content: application/json: schema: $ref: ../client-server/definitions/errors/error.yaml examples: response: value: { "errcode": "COM.EXAMPLE.MYAPPSERVICE_NOT_FOUND" } "/thirdparty/user/{protocol}": get: summary: Retrieve the Taper User ID of a corresponding third-party user. description: |- This API is called by the homeserver in order to retrieve a Taper User ID linked to a user on the third-party network, given a set of user parameters. operationId: queryUserByProtocol security: - homeserverAccessToken: [] parameters: - in: path name: protocol description: The protocol ID. required: true example: irc schema: type: string - in: query name: fields description: |- One or more custom fields that are passed to the application service to help identify the user. schema: type: object additionalProperties: type: string responses: "200": description: The Taper User IDs found with the given parameters. content: application/json: schema: $ref: definitions/user_batch.yaml "401": description: |- The homeserver has not supplied credentials to the application service. Optional error information can be included in the body of this response. content: application/json: schema: $ref: ../client-server/definitions/errors/error.yaml examples: response: value: { "errcode": "COM.EXAMPLE.MYAPPSERVICE_UNAUTHORIZED" } "403": description: The credentials supplied by the homeserver were rejected. content: application/json: schema: $ref: ../client-server/definitions/errors/error.yaml examples: response: value: { "errcode": "COM.EXAMPLE.MYAPPSERVICE_FORBIDDEN" } "404": description: No users were found with the given parameters. content: application/json: schema: $ref: ../client-server/definitions/errors/error.yaml examples: response: value: { "errcode": "COM.EXAMPLE.MYAPPSERVICE_NOT_FOUND" } "/thirdparty/location/{protocol}": get: summary: Retrieve Taper-side portal rooms leading to a third-party location. description: Retrieve a list of Taper portal rooms that lead to the matched third-party location. operationId: queryLocationByProtocol security: - homeserverAccessToken: [] parameters: - in: path name: protocol description: The protocol ID. required: true example: irc schema: type: string - in: query name: fields description: |- One or more custom fields that are passed to the application service to help identify the third-party location. schema: type: object additionalProperties: type: string responses: "200": description: At least one portal room was found. content: application/json: schema: $ref: definitions/location_batch.yaml "401": description: |- The homeserver has not supplied credentials to the application service. Optional error information can be included in the body of this response. content: application/json: schema: $ref: ../client-server/definitions/errors/error.yaml examples: response: value: { "errcode": "COM.EXAMPLE.MYAPPSERVICE_UNAUTHORIZED" } "403": description: The credentials supplied by the homeserver were rejected. content: application/json: schema: $ref: ../client-server/definitions/errors/error.yaml examples: response: value: { "errcode": "COM.EXAMPLE.MYAPPSERVICE_FORBIDDEN" } "404": description: No mappings were found with the given parameters. content: application/json: schema: $ref: ../client-server/definitions/errors/error.yaml examples: response: value: { "errcode": "COM.EXAMPLE.MYAPPSERVICE_NOT_FOUND" } /thirdparty/location: get: summary: Reverse-lookup third-party locations given a Taper room alias. description: |- Retrieve an array of third-party network locations from a Taper room alias. operationId: queryLocationByAlias security: - homeserverAccessToken: [] parameters: - in: query name: alias description: The Taper room alias to look up. schema: type: string responses: "200": description: All found third-party locations. content: application/json: schema: $ref: definitions/location_batch.yaml "401": description: |- The homeserver has not supplied credentials to the application service. Optional error information can be included in the body of this response. content: application/json: schema: $ref: ../client-server/definitions/errors/error.yaml examples: response: value: { "errcode": "COM.EXAMPLE.MYAPPSERVICE_UNAUTHORIZED" } "403": description: The credentials supplied by the homeserver were rejected. content: application/json: schema: $ref: ../client-server/definitions/errors/error.yaml examples: response: value: { "errcode": "COM.EXAMPLE.MYAPPSERVICE_FORBIDDEN" } "404": description: No mappings were found with the given parameters. content: application/json: schema: $ref: ../client-server/definitions/errors/error.yaml examples: response: value: { "errcode": "COM.EXAMPLE.MYAPPSERVICE_NOT_FOUND" } /thirdparty/user: get: summary: Reverse-lookup third-party users given a Taper User ID. description: Retrieve an array of third-party users from a Taper User ID. operationId: queryUserByID security: - homeserverAccessToken: [] parameters: - in: query name: userid description: The Taper User ID to look up. schema: type: string responses: "200": description: An array of third-party users. content: application/json: schema: $ref: definitions/user_batch.yaml "401": description: |- The homeserver has not supplied credentials to the application service. Optional error information can be included in the body of this response. content: application/json: schema: $ref: ../client-server/definitions/errors/error.yaml examples: response: value: { "errcode": "COM.EXAMPLE.MYAPPSERVICE_UNAUTHORIZED" } "403": description: The credentials supplied by the homeserver were rejected. content: application/json: schema: $ref: ../client-server/definitions/errors/error.yaml examples: response: value: { "errcode": "COM.EXAMPLE.MYAPPSERVICE_UNAUTHORIZED" } "404": description: No mappings were found with the given parameters. content: application/json: schema: $ref: ../client-server/definitions/errors/error.yaml examples: response: value: { "errcode": "COM.EXAMPLE.MYAPPSERVICE_NOT_FOUND" }servers: - url: "{protocol}://{hostname}{basePath}" variables: protocol: enum: - http - https default: https hostname: default: localhost:8008 basePath: default: /_taper/app/v1components: securitySchemes: homeserverAccessToken: $ref: definitions/security.yaml#/homeserverAccessToken123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107# Copyright 2016 OpenMarket Ltd# Copyright 2018 New Vector 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.0info: title: Taper Application Service API version: 1.0.0paths: "/rooms/{roomAlias}": get: summary: Query if a room alias should exist on the application service. description: |- This endpoint is invoked by the homeserver on an application service to query the existence of a given room alias. The homeserver will only query room aliases inside the application service's `aliases` namespace. The homeserver will send this request when it receives a request to join a room alias within the application service's namespace. operationId: queryRoomByAlias security: - homeserverAccessToken: [] parameters: - in: path name: roomAlias description: The room alias being queried. required: true example: "#magicforest:example.com" schema: type: string responses: "200": description: |- The application service indicates that this room alias exists. The application service MUST have created a room and associated it with the queried room alias using the client-server API. Additional information about the room such as its name and topic can be set before responding. content: application/json: schema: type: object examples: response: value: {} "401": description: |- The homeserver has not supplied credentials to the application service. Optional error information can be included in the body of this response. content: application/json: schema: $ref: ../client-server/definitions/errors/error.yaml examples: response: value: { "errcode": "COM.EXAMPLE.MYAPPSERVICE_UNAUTHORIZED" } "403": description: The credentials supplied by the homeserver were rejected. content: application/json: schema: $ref: ../client-server/definitions/errors/error.yaml examples: response: value: { "errcode": "COM.EXAMPLE.MYAPPSERVICE_FORBIDDEN" } "404": description: |- The application service indicates that this room alias does not exist. Optional error information can be included in the body of this response. content: application/json: schema: $ref: ../client-server/definitions/errors/error.yaml examples: response: value: { "errcode": "COM.EXAMPLE.MYAPPSERVICE_NOT_FOUND" }servers: - url: "{protocol}://{hostname}{basePath}" variables: protocol: enum: - http - https default: https hostname: default: localhost:8008 basePath: default: /_taper/app/v1components: securitySchemes: homeserverAccessToken: $ref: definitions/security.yaml#/homeserverAccessToken123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104# Copyright 2016 OpenMarket Ltd# Copyright 2018 New Vector 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.0info: title: Taper Application Service API version: 1.0.0paths: "/users/{userId}": get: summary: Query if a user should exist on the application service. description: |- This endpoint is invoked by the homeserver on an application service to query the existence of a given user ID. The homeserver will only query user IDs inside the application service's `users` namespace. The homeserver will send this request when it receives an event for an unknown user ID in the application service's namespace, such as a room invite. operationId: queryUserById security: - homeserverAccessToken: [] parameters: - in: path name: userId description: The user ID being queried. required: true example: "@alice:example.com" schema: type: string responses: "200": description: |- The application service indicates that this user exists. The application service MUST create the user using the client-server API. content: application/json: schema: type: object examples: response: value: {} "401": description: |- The homeserver has not supplied credentials to the application service. Optional error information can be included in the body of this response. content: application/json: schema: $ref: ../client-server/definitions/errors/error.yaml examples: response: value: { "errcode": "COM.EXAMPLE.MYAPPSERVICE_UNAUTHORIZED" } "403": description: The credentials supplied by the homeserver were rejected. content: application/json: schema: $ref: ../client-server/definitions/errors/error.yaml examples: response: value: { "errcode": "COM.EXAMPLE.MYAPPSERVICE_FORBIDDEN" } "404": description: |- The application service indicates that this user does not exist. Optional error information can be included in the body of this response. content: application/json: schema: $ref: ../client-server/definitions/errors/error.yaml examples: response: value: { "errcode": "COM.EXAMPLE.MYAPPSERVICE_NOT_FOUND" }servers: - url: "{protocol}://{hostname}{basePath}" variables: protocol: enum: - http - https default: https hostname: default: localhost:8008 basePath: default: /_taper/app/v1components: securitySchemes: homeserverAccessToken: $ref: definitions/security.yaml#/homeserverAccessToken123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116# Copyright 2016 OpenMarket Ltd# Copyright 2018 New Vector 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.0info: title: Taper Application Service API version: 1.0.0paths: "/transactions/{txnId}": put: summary: Send some events to the application service. description: |- This API is called by the homeserver when it wants to push an event (or batch of events) to the application service.
Note that the application service should distinguish state events from message events via the presence of a `state_key`, rather than via the event type. operationId: sendTransaction security: - homeserverAccessToken: [] parameters: - in: path name: txnId description: |- The transaction ID for this set of events. Homeservers generate these IDs and they are used to ensure idempotency of requests. required: true example: "35" schema: type: string requestBody: content: application/json: schema: type: object example: { "ephemeral": [ { "$ref": "../../event-schemas/examples/t.receipt.yaml", "room_id": "!jEsUZKDJdhlrceRyVU:example.org" }, { "$ref": "../../event-schemas/examples/t.presence.yaml" }, ], "events": [ { "$ref": "../../event-schemas/examples/t.room.member.yaml" }, { "$ref": "../../event-schemas/examples/t.room.message$t.text.yaml" } ] } properties: events: type: array description: A list of events, formatted as per the Client-Server API. items: $ref: ../client-server/definitions/client_event.yaml ephemeral: type: array x-addedInMatrixVersion: "1.13" description: |- A list of ephemeral data, if the `receive_ephemeral` setting was enabled in the [registration](/application-service-api/#registration) file.
There are only three event types that can currently occur in this list: `t.presence`, `t.typing`, and `t.receipt`. Room-scoped ephemeral data (`t.typing` and `t.receipt`) MUST include a `room_id` property to identify the room that they were sent in.
This property can be omitted if it would be empty. items: $ref: ../../event-schemas/schema/core-event-schema/event.yaml required: - events description: Transaction information responses: "200": description: The transaction was processed successfully. content: application/json: schema: type: object examples: response: value: {}servers: - url: "{protocol}://{hostname}{basePath}" variables: protocol: enum: - http - https default: https hostname: default: localhost:8008 basePath: default: /_taper/app/v1components: securitySchemes: homeserverAccessToken: $ref: definitions/security.yaml#/homeserverAccessToken123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383# 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.0info: title: Taper Client-Server Client Config API version: 1.0.0paths: "/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_taperclientv3sync). operationId: setAccountData security: - accessTokenBearer: [] parameters: - in: path name: userId required: true description: |- The ID of the user to set account data for. The access token must be authorised 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: `T_BAD_JSON` or `T_NOT_JSON`. content: application/json: schema: $ref: ../client-server/definitions/errors/error.yaml examples: response: value: { "errcode": "T_NOT_JSON", "error": "Content must be a JSON object." } "403": description: |- The access token provided is not authorised to modify this user's account data. Errcode: `T_FORBIDDEN`. content: application/json: schema: $ref: ../client-server/definitions/errors/error.yaml examples: response: value: { "errcode": "T_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: `T_BAD_JSON`. content: application/json: schema: $ref: ../client-server/definitions/errors/error.yaml examples: response: value: { "errcode": "T_BAD_JSON", "error": "Cannot set t.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: - accessTokenBearer: [] parameters: - in: path name: userId required: true description: |- The ID of the user to get account data for. The access token must be authorised 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 authorised to retrieve this user's account data. Errcode: `T_FORBIDDEN`. content: application/json: schema: $ref: ../client-server/definitions/errors/error.yaml examples: response: value: { "errcode": "T_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: `T_NOT_FOUND`. content: application/json: schema: $ref: ../client-server/definitions/errors/error.yaml examples: response: value: { "errcode": "T_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_taperclientv3sync). operationId: setAccountDataPerRoom security: - accessTokenBearer: [] parameters: - in: path name: userId required: true description: |- The ID of the user to set account data for. The access token must be authorised 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 `T_BAD_JSON` or `T_NOT_JSON`), or the given `roomID` is not a valid room ID (errcode `T_INVALID_PARAM`). content: application/json: schema: $ref: ../client-server/definitions/errors/error.yaml examples: response: value: { "errcode": "T_NOT_JSON", "error": "Content must be a JSON object." } "403": description: |- The access token provided is not authorised to modify this user's account data. Errcode: `T_FORBIDDEN`. content: application/json: schema: $ref: ../client-server/definitions/errors/error.yaml examples: response: value: { "errcode": "T_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: `T_BAD_JSON`. content: application/json: schema: $ref: ../client-server/definitions/errors/error.yaml examples: response: value: { "errcode": "T_BAD_JSON", "error": "Cannot set t.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: - accessTokenBearer: [] parameters: - in: path name: userId required: true description: |- The ID of the user to get account data for. The access token must be authorised 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: `T_INVALID_PARAM`." content: application/json: schema: $ref: ../client-server/definitions/errors/error.yaml examples: response: value: { "errcode": "T_INVALID_PARAM", "error": "@notaroomid:example.org is not a valid room ID." } "403": description: |- The access token provided is not authorised to retrieve this user's account data. Errcode: `T_FORBIDDEN`. content: application/json: schema: $ref: ../client-server/definitions/errors/error.yaml examples: response: value: { "errcode": "T_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: `T_NOT_FOUND`. content: application/json: schema: $ref: ../client-server/definitions/errors/error.yaml examples: response: value: { "errcode": "T_NOT_FOUND", "error": "Room account data not found." } tags: - User dataservers: - url: "{protocol}://{hostname}{basePath}" variables: protocol: enum: - http - https default: https hostname: default: localhost:8008 basePath: default: /_taper/client/v3components: securitySchemes: accessTokenBearer: $ref: definitions/security.yaml#/accessTokenBearer123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150# Copyright 2016 OpenMarket 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.0info: title: Taper Client-Server Account Deactivation API version: 1.0.0paths: /account/deactivate: post: summary: Deactivate a user's account. description: |- Deactivate the user's account, removing all ability for the user to login again.
This API endpoint uses the [User-Interactive Authentication API](/client-server-api/#user-interactive-authentication-api).
An access token should be submitted to this endpoint if the client has an active session.
The homeserver may change the flows available depending on whether a valid access token is provided.
Unlike other endpoints, this endpoint does not take an `id_access_token` parameter because the homeserver is expected to sign the request to the identity server instead.
{{% boxes/warning %}} {{% added-in v="1.18" %}} [OAuth 2.0 aware clients](/client-server-api/#oauth-20-aware-clients) MUST NOT use this endpoint when the server supports the [OAuth 2.0 API](/client-server-api/#oauth-20-api). Instead they MUST refer the user to the [account management URL](/client-server-api/#oauth-20-account-management), if available, and MAY use the `action=org.matrix.account_deactivate` parameter. {{% /boxes/warning %}}
{{% added-in v="1.20" %}} When an account is deactivated, the homeserver MUST cancel all of the account's scheduled [delayed events](/client-server-api/#delayed-events). Homeservers MAY opt to not retain these cancelled delayed events for retrieval via [`GET /delayed_events/{delayId}`](/client-server-api/#get_taperclientv1delayed_eventsdelayid). security: - {} - accessTokenBearer: [] operationId: deactivateAccount requestBody: content: application/json: schema: type: object properties: auth: description: Additional authentication information for the user-interactive authentication API. allOf: - $ref: definitions/auth_data.yaml id_server: type: string description: |- The identity server to unbind all of the user's 3PIDs from. If not provided, the homeserver MUST use the `id_server` that was originally use to bind each identifier. If the homeserver does not know which `id_server` that was, it must return an `id_server_unbind_result` of `no-support`. example: example.org erase: x-addedInMatrixVersion: "1.10" type: boolean description: |- Whether the user would like their content to be erased as much as possible from the server.
Erasure means that any users (or servers) which join the room after the erasure request are served redacted copies of the events sent by this account. Users which had visibility on those events prior to the erasure are still able to see unredacted copies. No redactions are sent and the erasure request is not shared over federation, so other servers might still serve unredacted copies.
The server should additionally erase any non-event data associated with the user, such as [account data](/client-server-api/#client-config) and [contact 3PIDs](/client-server-api/#adding-account-administrative-contact-information).
Defaults to `false` if not present. required: true responses: "200": description: The account has been deactivated. content: application/json: schema: type: object properties: id_server_unbind_result: type: string enum: - success - no-support description: |- An indicator as to whether or not the homeserver was able to unbind the user's 3PIDs from the identity server(s). `success` indicates that all identifiers have been unbound from the identity server while `no-support` indicates that one or more identifiers failed to unbind due to the identity server refusing the request or the homeserver being unable to determine an identity server to unbind from. This must be `success` if the homeserver has no identifiers to unbind for the user. example: success required: - id_server_unbind_result "401": description: The homeserver requires additional authentication information. content: application/json: schema: $ref: definitions/auth_response.yaml "429": description: This request was rate-limited. content: application/json: schema: $ref: definitions/errors/rate_limited.yaml tags: - Account managementservers: - url: "{protocol}://{hostname}{basePath}" variables: protocol: enum: - http - https default: https hostname: default: localhost:8008 basePath: default: /_taper/client/v3components: securitySchemes: accessTokenBearer: $ref: definitions/security.yaml#/accessTokenBearer123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505# 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.0info: title: Taper Client-Server Administration API version: 1.0.0paths: "/v3/admin/whois/{userId}": get: summary: Gets information about a particular user. description: |- Gets information about a particular user.
This API may be restricted to only be called by the user being looked up, or by a server admin. Server-local administrator privileges are not specified in this document. operationId: getWhoIs security: - accessTokenBearer: [] parameters: - in: path name: userId description: The user to look up. required: true example: "@peter:rabbit.rocks" schema: type: string responses: "200": description: The lookup was successful. content: application/json: schema: type: object properties: user_id: type: string description: The Taper user ID of the user. devices: type: object description: Each key is an identifier for one of the user's devices. additionalProperties: type: object title: DeviceInfo properties: sessions: type: array description: A user's sessions (i.e. what they did with an access token from one login). items: type: object title: SessionInfo properties: connections: type: array description: Information particular connections in the session. items: type: object title: ConnectionInfo properties: ip: type: string description: Most recently seen IP address of the session. last_seen: type: integer format: int64 description: Unix timestamp that the session was last active. user_agent: type: string description: User agent string last seen in the session. examples: response: value: { "user_id": "@peter:rabbit.rocks", "devices": { "teapot": { "sessions": [ { "connections": [ { "ip": "127.0.0.1", "last_seen": 1411996332123, "user_agent": "curl/7.31.0-DEV" }, { "ip": "10.0.0.2", "last_seen": 1411996332123, "user_agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36" } ] } ] } } } tags: - Server administration "/v1/admin/suspend/{userId}": get: summary: Gets information about the suspended status of a particular user. x-addedInMatrixVersion: "1.18" description: |- Gets information about the suspended status of a particular server-local user.
The user calling this endpoint MUST be a server admin.
In order to prevent user enumeration, servers MUST ensure that authorisation is checked prior to trying to do account lookups. operationId: getAdminSuspendUser security: - accessTokenBearer: [] parameters: - in: path name: userId description: The user to look up. required: true example: "@peter:rabbit.rocks" schema: type: string format: mx-user-id pattern: "^@"
responses: "200": description: The lookup was successful. content: application/json: schema: type: object properties: suspended: type: boolean description: Whether the target account is suspended. example: true required: - suspended examples: response: value: { "suspended": true, } "400": description: |- The user ID does not belong to the local server. The errcode is `T_INVALID_PARAM`. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_INVALID_PARAM", "error": "User does not belong to the local server." } "403": description: |- The requesting user is not a server administrator, or the target user is another administrator. The errcode is `T_FORBIDDEN`. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_FORBIDDEN", "error": "Requesting user is not a server administrator." } "404": description: |- The user ID is not found, or is deactivated. The errcode is `T_NOT_FOUND`. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_NOT_FOUND", "error": "User not found." } tags: - Server administration put: summary: Set the suspended status of a particular user. x-addedInMatrixVersion: "1.18" description: |- Sets the suspended status of a particular server-local user.
The user calling this endpoint MUST be a server admin. The client SHOULD check that the user is allowed to suspend other users at the [`GET /capabilities`](/client-server-api/#get_taperclientv3capabilities) endpoint prior to using this endpoint.
In order to prevent user enumeration, servers MUST ensure that authorisation is checked prior to trying to do account lookups. operationId: setAdminSuspendUser security: - accessTokenBearer: [] parameters: - in: path name: userId description: The user to change the suspended status of. required: true example: "@peter:rabbit.rocks" schema: type: string format: mx-user-id pattern: "^@" requestBody: content: application/json: schema: type: object properties: suspended: type: boolean description: Whether to suspend the target account. example: true required: - suspended examples: request: value: { "suspended": true, } required: true
responses: "200": description: The action was successful. content: application/json: schema: type: object properties: suspended: type: boolean description: Whether the target account is suspended. example: true required: - suspended examples: response: value: { "suspended": true, } "400": description: |- The user ID does not belong to the local server. The errcode is `T_INVALID_PARAM`. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_INVALID_PARAM", "error": "User does not belong to the local server." } "403": description: |- The requesting user is not a server administrator, is trying to suspend their own account, or the target user is another administrator. The errcode is `T_FORBIDDEN`. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_FORBIDDEN", "error": "Requesting user is not a server administrator." } "404": description: |- The user ID is not found, or is deactivated. The errcode is `T_NOT_FOUND`. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_NOT_FOUND", "error": "User not found." } tags: - Server administration "/v1/admin/lock/{userId}": get: summary: Gets information about the locked status of a particular user. x-addedInMatrixVersion: "1.18" description: |- Gets information about the locked status of a particular server-local user.
The user calling this endpoint MUST be a server admin.
In order to prevent user enumeration, servers MUST ensure that authorisation is checked prior to trying to do account lookups. operationId: getAdminLockUser security: - accessTokenBearer: [] parameters: - in: path name: userId description: The user to look up. required: true example: "@peter:rabbit.rocks" schema: type: string format: mx-user-id pattern: "^@"
responses: "200": description: The lookup was successful. content: application/json: schema: type: object properties: locked: type: boolean description: Whether the target account is locked. required: - locked examples: response: value: { "locked": true, } "400": description: |- The user ID does not belong to the local server. The errcode is `T_INVALID_PARAM`. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_INVALID_PARAM", "error": "User does not belong to the local server." } "403": description: |- The requesting user is not a server administrator, or the target user is another administrator. The errcode is `T_FORBIDDEN`. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_FORBIDDEN", "error": "Requesting user is not a server administrator." } "404": description: |- The user ID is not found, or is deactivated. The errcode is `T_NOT_FOUND`. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_NOT_FOUND", "error": "User not found." } tags: - Server administration put: summary: Set the locked status of a particular user. x-addedInMatrixVersion: "1.18" description: |- Sets the locked status of a particular server-local user.
The user calling this endpoint MUST be a server admin. The client SHOULD check that the user is allowed to lock other users at the [`GET /capabilities`](/client-server-api/#get_taperclientv3capabilities) endpoint prior to using this endpoint.
In order to prevent user enumeration, servers MUST ensure that authorisation is checked prior to trying to do account lookups. operationId: setAdminLockUser security: - accessTokenBearer: [] parameters: - in: path name: userId description: The user to change the locked status of. required: true example: "@peter:rabbit.rocks" schema: type: string format: mx-user-id pattern: "^@" requestBody: content: application/json: schema: type: object properties: locked: type: boolean description: Whether to lock the target account. example: true required: - locked examples: request: value: { "locked": true, } required: true
responses: "200": description: The action was successful. content: application/json: schema: type: object properties: locked: type: boolean description: Whether the target account is locked. example: true required: - locked examples: response: value: { "locked": true, } "400": description: |- The user ID does not belong to the local server. The errcode is `T_INVALID_PARAM`. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_INVALID_PARAM", "error": "User does not belong to the local server." } "403": description: |- The requesting user is not a server administrator, is trying to lock their own account, or the target user is another administrator. The errcode is `T_FORBIDDEN`. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_FORBIDDEN", "error": "Requesting user is not a server administrator." } "404": description: |- The user ID is not found, or is deactivated. The errcode is `T_NOT_FOUND`. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_NOT_FOUND", "error": "User not found." } tags: - Server administrationservers: - url: "{protocol}://{hostname}{basePath}" variables: protocol: enum: - http - https default: https hostname: default: localhost:8008 basePath: default: /_taper/clientcomponents: securitySchemes: accessTokenBearer: $ref: definitions/security.yaml#/accessTokenBearer123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612# Copyright 2016 OpenMarket Ltd# Copyright 2019 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.0info: title: Taper Client-Server Account Administrative Contact API version: 1.0.0paths: /account/3pid: get: summary: Gets a list of a user's third-party identifiers. description: |- Gets a list of the third-party identifiers that the homeserver has associated with the user's account.
This is *not* the same as the list of third-party identifiers bound to the user's Taper ID in identity servers.
Identifiers in this list may be used by the homeserver as, for example, identifiers that it will accept to reset the user's account password. operationId: getAccount3PIDs security: - accessTokenBearer: [] responses: "200": description: The lookup was successful. content: application/json: schema: type: object properties: threepids: type: array items: type: object title: Third-party identifier properties: medium: type: string description: The medium of the third-party identifier. enum: - email - msisdn address: type: string description: The third-party identifier address. validated_at: type: integer format: int64 description: |- The timestamp, in milliseconds, when the identifier was validated by the identity server. added_at: type: integer format: int64 description: The timestamp, in milliseconds, when the homeserver associated the third-party identifier with the user. required: - medium - address - validated_at - added_at examples: response: value: { "threepids": [ { "medium": "email", "address": "monkey@banana.island", "validated_at": 1535176800000, "added_at": 1535336848756 } ] } tags: - Account management post: summary: Adds contact information to the user's account. description: |- Adds contact information to the user's account.
This endpoint is deprecated in favour of the more specific `/3pid/add` and `/3pid/bind` endpoints.
**Note:** Previously this endpoint supported a `bind` parameter. This parameter has been removed, making this endpoint behave as though it was `false`. This results in this endpoint being an equivalent to `/3pid/bind` rather than dual-purpose.
This endpoint uses [capabilities negotiation](/client-server-api/#capabilities-negotiation). Clients SHOULD check the value of the [`t.3pid_changes` capability](/client-server-api/#l3pid_changes-capability) to determine if this endpoint is available. operationId: post3PIDs deprecated: true security: - accessTokenBearer: [] requestBody: content: application/json: schema: type: object properties: three_pid_creds: title: ThreePidCredentials type: object description: The third-party credentials to associate with the account. properties: client_secret: type: string description: The client secret used in the session with the identity server. id_server: type: string description: The identity server to use. id_access_token: type: string 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. sid: type: string description: The session identifier given by the identity server. required: - client_secret - id_server - id_access_token - sid required: - three_pid_creds example: { "three_pid_creds": { "id_server": "matrix.org", "id_access_token": "abc123_OpaqueString", "sid": "abc123987", "client_secret": "d0nt-T3ll" } } required: true responses: "200": description: The addition was successful. content: application/json: schema: type: object properties: submit_url: type: string format: uri description: |- An optional field containing a URL where the client must submit the validation token to, with identical parameters to the Identity Service API's `POST /validate/email/submitToken` endpoint (without the requirement for an access token). The homeserver must send this token to the user (if applicable), who should then be prompted to provide it to the client.
If this field is not present, the client can assume that verification will happen without the client's involvement provided the homeserver advertises this specification version in the `/versions` response (ie: r0.5.0). example: https://example.org/path/to/submitToken examples: response: value: { "submit_url": "https://example.org/path/to/submitToken" } "403": description: The credentials could not be verified with the identity server. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_THREEPID_AUTH_FAILED", "error": "The third-party credentials could not be verified by the identity server." } tags: - Account management /account/3pid/add: post: summary: Adds contact information to the user's account. description: |- This API endpoint uses the [User-Interactive Authentication API](/client-server-api/#user-interactive-authentication-api).
Adds contact information to the user's account. Homeservers should use 3PIDs added through this endpoint for password resets instead of relying on the identity server.
Homeservers should prevent the caller from adding a 3PID to their account if it has already been added to another user's account on the homeserver.
This endpoint uses [capabilities negotiation](/client-server-api/#capabilities-negotiation). Clients SHOULD check the value of the [`t.3pid_changes` capability](/client-server-api/#l3pid_changes-capability) to determine if this endpoint is available.
{{% boxes/warning %}} Since this endpoint uses User-Interactive Authentication, it cannot be used when the access token was obtained via the [OAuth 2.0 API](/client-server-api/#oauth-20-api). {{% /boxes/warning %}} operationId: add3PID security: - accessTokenBearer: [] requestBody: content: application/json: schema: type: object properties: auth: description: |- Additional authentication information for the user-interactive authentication API. allOf: - $ref: definitions/auth_data.yaml client_secret: type: string description: The client secret used in the session with the homeserver. example: d0nt-T3ll sid: type: string description: The session identifier given by the homeserver. example: abc123987 required: - client_secret - sid required: true responses: "200": description: The addition was successful. content: application/json: schema: type: object examples: response: value: {} "401": description: The homeserver requires additional authentication information. content: application/json: schema: $ref: definitions/auth_response.yaml "429": description: This request was rate-limited. content: application/json: schema: $ref: definitions/errors/rate_limited.yaml tags: - Account management /account/3pid/bind: post: summary: Binds a 3PID to the user's account through an Identity Service. description: |- Binds a 3PID to the user's account through the specified identity server.
Homeservers should not prevent this request from succeeding if another user has bound the 3PID. Homeservers should simply proxy any errors received by the identity server to the caller.
Homeservers should track successful binds so they can be unbound later. operationId: bind3PID security: - accessTokenBearer: [] requestBody: content: application/json: schema: type: object properties: client_secret: type: string description: The client secret used in the session with the identity server. id_server: type: string description: The identity server to use. id_access_token: type: string description: An access token previously registered with the identity server. sid: type: string description: The session identifier given by the identity server. required: - client_secret - id_server - id_access_token - sid example: { "id_server": "example.org", "id_access_token": "abc123_OpaqueString", "sid": "abc123987", "client_secret": "d0nt-T3ll" } required: true responses: "200": description: The addition was successful. content: application/json: schema: type: object examples: response: value: {} "429": description: This request was rate-limited. content: application/json: schema: $ref: definitions/errors/rate_limited.yaml tags: - Account management /account/3pid/delete: post: summary: Deletes a third-party identifier from the user's account description: |- Removes a third-party identifier from the user's account. This might not cause an unbind of the identifier from the identity server.
Unlike other endpoints, this endpoint does not take an `id_access_token` parameter because the homeserver is expected to sign the request to the identity server instead.
This endpoint uses [capabilities negotiation](/client-server-api/#capabilities-negotiation). Clients SHOULD check the value of the [`t.3pid_changes` capability](/client-server-api/#l3pid_changes-capability) to determine if this endpoint is available. operationId: delete3pidFromAccount security: - accessTokenBearer: [] requestBody: content: application/json: schema: type: object properties: id_server: type: string description: |- The identity server to unbind from. If not provided, the homeserver MUST use the `id_server` the identifier was added through. If the homeserver does not know the original `id_server`, it MUST return a `id_server_unbind_result` of `no-support`. example: example.org medium: type: string description: The medium of the third-party identifier being removed. enum: - email - msisdn example: email address: type: string description: The third-party address being removed. example: example@example.org required: - medium - address required: true responses: "200": description: |- The homeserver has disassociated the third-party identifier from the user. content: application/json: schema: type: object properties: id_server_unbind_result: type: string enum: - no-support - success description: |- An indicator as to whether or not the homeserver was able to unbind the 3PID from the identity server. `success` indicates that the identity server has unbound the identifier whereas `no-support` indicates that the identity server refuses to support the request or the homeserver was not able to determine an identity server to unbind from. example: success required: - id_server_unbind_result tags: - Account management /account/3pid/unbind: post: summary: Removes a user's third-party identifier from an identity server. description: |- Removes a user's third-party identifier from the provided identity server without removing it from the homeserver.
Unlike other endpoints, this endpoint does not take an `id_access_token` parameter because the homeserver is expected to sign the request to the identity server instead. operationId: unbind3pidFromAccount security: - accessTokenBearer: [] requestBody: content: application/json: schema: type: object properties: id_server: type: string description: |- The identity server to unbind from. If not provided, the homeserver MUST use the `id_server` the identifier was added through. If the homeserver does not know the original `id_server`, it MUST return a `id_server_unbind_result` of `no-support`. example: example.org medium: type: string description: The medium of the third-party identifier being removed. enum: - email - msisdn example: email address: type: string description: The third-party address being removed. example: example@example.org required: - medium - address required: true responses: "200": description: |- The identity server has disassociated the third-party identifier from the user. content: application/json: schema: type: object properties: id_server_unbind_result: type: string enum: - no-support - success description: |- An indicator as to whether or not the identity server was able to unbind the 3PID. `success` indicates that the identity server has unbound the identifier whereas `no-support` indicates that the identity server refuses to support the request or the homeserver was not able to determine an identity server to unbind from. example: success required: - id_server_unbind_result tags: - Account management /account/3pid/email/requestToken: post: summary: Begins the validation process for an email address for association with the user's account. description: |- The homeserver must check that the given email address is **not** already associated with an account on this homeserver. This API should be used to request validation tokens when adding an email address to an account. This API's parameters and response are identical to that of the [`/register/email/requestToken`](/client-server-api/#post_taperclientv3registeremailrequesttoken) endpoint. The homeserver should validate the email itself, either by sending a validation email itself or by using a service it has control over. operationId: requestTokenTo3PIDEmail requestBody: content: application/json: schema: $ref: definitions/request_email_validation.yaml required: true responses: "200": description: |- An email was sent to the given address. Note that this may be an email containing the validation token or it may be informing the user of an error. content: application/json: schema: $ref: definitions/request_token_response.yaml "400": description: |- The third-party identifier is already in use on the homeserver, or the request was invalid. Error codes that can be returned are: * `T_THREEPID_IN_USE`: The email supplied cannot be bound because it is already associated with a different Taper ID. * `T_SERVER_NOT_TRUSTED`: The server does not trust/support the identity server provided in the request. * `T_THREEPID_MEDIUM_NOT_SUPPORTED`: The homeserver does not support adding email addresses. * `T_INVALID_PARAM`: The email address given was not valid. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_THREEPID_IN_USE", "error": "Third-party identifier already in use" } "403": description: |- The homeserver does not allow the third-party identifier as a contact option. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_THREEPID_DENIED", "error": "Third-party identifier is not allowed" } tags: - Account management /account/3pid/msisdn/requestToken: post: summary: Begins the validation process for a phone number for association with the user's account. description: |- The homeserver must check that the given phone number is **not** already associated with an account on this homeserver. This API should be used to request validation tokens when adding a phone number to an account. This API's parameters and response are identical to that of the [`/register/msisdn/requestToken`](/client-server-api/#post_taperclientv3registermsisdnrequesttoken) endpoint. The homeserver should validate the phone number itself, either by sending a validation message itself or by using a service it has control over. operationId: requestTokenTo3PIDMSISDN requestBody: content: application/json: schema: $ref: definitions/request_msisdn_validation.yaml required: true responses: "200": description: An SMS message was sent to the given phone number. content: application/json: schema: $ref: definitions/request_token_response.yaml "400": description: |- The third-party identifier is already in use on the homeserver, or the request was invalid. Error codes that can be returned are: * `T_THREEPID_IN_USE`: The phone number supplied cannot be bound because is is already associated with a different Taper ID. * `T_SERVER_NOT_TRUSTED`: The server does not trust/support the identity server * `T_THREEPID_MEDIUM_NOT_SUPPORTED`: The homeserver does not support adding phone numbers. * `T_INVALID_PARAM`: The phone number given was not valid. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_THREEPID_IN_USE", "error": "Third-party identifier already in use" } "403": description: |- The homeserver does not allow the third-party identifier as a contact option. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_THREEPID_DENIED", "error": "Third-party identifier is not allowed" } tags: - Account managementservers: - url: "{protocol}://{hostname}{basePath}" variables: protocol: enum: - http - https default: https hostname: default: localhost:8008 basePath: default: /_taper/client/v3components: securitySchemes: accessTokenBearer: $ref: definitions/security.yaml#/accessTokenBearer123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180# Copyright 2023 Tulir Asokan## 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.0info: title: Taper Client-Server Application Service Ping API version: 1.0.0paths: "/appservice/{appserviceId}/ping": post: x-addedInMatrixVersion: "1.7" summary: Ask the homeserver to ping the application service to ensure the connection works. description: |- This API asks the homeserver to call the [`/_taper/app/v1/ping`](/application-service-api/#post_taperappv1ping) endpoint on the application service to ensure that the homeserver can communicate with the application service.
This API requires the use of an application service access token (`as_token`) instead of a typical client's access token. This API cannot be invoked by users who are not identified as application services. Additionally, the appservice ID in the path must be the same as the appservice whose `as_token` is being used. operationId: pingAppservice parameters: - in: path name: appserviceId description: |- The appservice ID of the appservice to ping. This must be the same as the appservice whose `as_token` is being used to authenticate the request. required: true example: telegram schema: type: string requestBody: content: application/json: schema: type: object properties: transaction_id: type: string description: An optional transaction ID that is passed through to the `/_taper/app/v1/ping` call. example: mautrix-go_1683636478256400935_123 required: true security: - appserviceAccessTokenBearer: [] responses: "200": description: The ping was successful. content: application/json: schema: type: object properties: duration_ms: type: integer description: |- The duration in milliseconds that the [`/_taper/app/v1/ping`](/application-service-api/#post_taperappv1ping) request took from the homeserver's point of view. required: - duration_ms examples: response: value: { "duration_ms": 123 } "400": description: The application service doesn't have a URL configured. The errcode is `T_URL_NOT_SET`. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_URL_NOT_SET", "error": "Application service doesn't have a URL configured" } "403": description: The access token used to authenticate the request doesn't belong to an appservice, or belongs to a different appservice than the one in the path. The errcode is `T_FORBIDDEN`. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_FORBIDDEN", "error": "Provided access token is not the appservice's as_token" } "502": description: |- The application service returned a bad status, or the connection failed. The errcode is `T_BAD_STATUS` or `T_CONNECTION_FAILED`.
For bad statuses, the response may include `status` and `body` fields containing the HTTP status code and response body text respectively to aid with debugging. content: application/json: schema: type: object title: Error description: A Taper-level Error properties: errcode: type: string description: An error code. enum: - T_BAD_STATUS - T_CONNECTION_FAILED error: type: string description: A human-readable error message. example: Ping returned status 401 status: type: integer description: The HTTP status code returned by the appservice. example: 401 body: type: string description: The HTTP response body returned by the appservice. example: '{"errcode": "T_UNKNOWN_TOKEN"}' required: - errcode examples: response: value: { "errcode": "T_BAD_STATUS", "error": "Ping returned status 401", "status": 401, "body": "{\"errcode\": \"T_UNKNOWN_TOKEN\"}" } "504": description: The connection to the application service timed out. The errcode is `T_CONNECTION_TIMEOUT`. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_CONNECTION_TIMEOUT", "error": "Connection to application service timed out" }servers: - url: "{protocol}://{hostname}{basePath}" variables: protocol: enum: - http - https default: https hostname: default: localhost:8008 basePath: default: /_taper/client/v1components: securitySchemes: appserviceAccessTokenBearer: $ref: definitions/security.yaml#/appserviceAccessTokenBearer123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101# Copyright 2018 New Vector 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.0info: title: Taper Client-Server Application Service Published Room Directory API version: 1.0.0paths: "/directory/list/appservice/{networkId}/{roomId}": put: summary: |- Updates a room's visibility in the application service's published room directory. description: |- Updates the visibility of a given room in the application service's published room directory.
This API is similar to the [visibility API](/client-server-api#put_taperclientv3directorylistroomroomid) used by clients to update the homeserver's more general published room directory.
This API requires the use of an application service access token (`as_token`) instead of a typical client's access_token. This API cannot be invoked by users who are not identified as application services. operationId: updateAppserviceRoomDirectoryVisibility parameters: - in: path name: networkId description: |- The protocol (network) ID to update the room list for. This would have been provided by the application service as being listed as a supported protocol. required: true example: irc schema: type: string - in: path name: roomId description: The room ID to add to the directory. required: true example: "!somewhere:example.org" schema: type: string requestBody: content: application/json: schema: type: object properties: visibility: type: string enum: - public - private description: |- Whether the room should be visible (public) in the directory or not (private). example: public required: - visibility required: true security: - appserviceAccessTokenBearer: [] responses: "200": description: The room's directory visibility has been updated. content: application/json: schema: type: object examples: response: value: {} tags: - Application service room directory managementservers: - url: "{protocol}://{hostname}{basePath}" variables: protocol: enum: - http - https default: https hostname: default: localhost:8008 basePath: default: /_taper/client/v3components: securitySchemes: appserviceAccessTokenBearer: $ref: definitions/security.yaml#/appserviceAccessTokenBearer123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604# Copyright 2016 OpenMarket Ltd# Copyright 2019-2024 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.0info: title: Taper Client-Server (Authenticated) Content Repository API version: 1.0.0paths: "/media/download/{serverName}/{mediaId}": get: x-addedInMatrixVersion: "1.11" summary: Download content from the content repository. description: |- {{% boxes/note %}} Clients SHOULD NOT generate or use URLs which supply the access token in the query string. These URLs may be copied by users verbatim and provided in a chat message to another user, disclosing the sender's access token. {{% /boxes/note %}}
Clients MAY be redirected using the 307/308 responses below to download the request object. This is typical when the homeserver uses a Content Delivery Network (CDN). operationId: getContentAuthed security: - accessTokenBearer: [] parameters: - $ref: '#/components/parameters/serverName' - $ref: '#/components/parameters/mediaId' - $ref: '#/components/parameters/timeout_ms' responses: "200": description: The content that was previously uploaded. headers: Content-Type: $ref: '#/components/headers/downloadContentType' Content-Disposition: x-changedInMatrixVersion: "1.12": This header became required. description: | The [disposition](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition) of the returned content. MUST be one of `inline` or `attachment`, and SHOULD contain a file name.
If the `Content-Type` is allowed in the [restrictions for serving inline content](/client-server-api/#serving-inline-content), servers SHOULD use `inline`, otherwise they SHOULD use `attachment`.
If the upload was made with a `filename`, this header MUST contain the same `filename`. Otherwise, `filename` is excluded from the header. If the media being downloaded is remote, the remote server's `filename` in the `Content-Disposition` header is used as the `filename` instead. When the header is not supplied, or does not supply a `filename`, the local download response does not include a `filename`. required: true schema: type: string example: "inline; filename=\"filename.jpg\"" content: application/octet-stream: schema: # This is a workaround for us not being able to say the response is required. description: "**Required.** The bytes for the uploaded file." "307": $ref: '#/components/responses/downloadRedirect' "308": $ref: '#/components/responses/downloadRedirect' "429": $ref: '#/components/responses/rateLimited' "502": $ref: '#/components/responses/downloadTooLarge' "504": $ref: '#/components/responses/notYetUploaded' tags: - Media "/media/download/{serverName}/{mediaId}/{fileName}": get: x-addedInMatrixVersion: "1.11" summary: Download content from the content repository overriding the file name. description: |- This will download content from the content repository (same as the previous endpoint) but replaces the target file name with the one provided by the caller.
{{% boxes/note %}} Clients SHOULD NOT generate or use URLs which supply the access token in the query string. These URLs may be copied by users verbatim and provided in a chat message to another user, disclosing the sender's access token. {{% /boxes/note %}}
Clients MAY be redirected using the 307/308 responses below to download the request object. This is typical when the homeserver uses a Content Delivery Network (CDN). operationId: getContentOverrideNameAuthed security: - accessTokenBearer: [] parameters: - $ref: '#/components/parameters/serverName' - $ref: '#/components/parameters/mediaId' - in: path name: fileName required: true description: A filename to give in the `Content-Disposition` header. example: filename.jpg schema: type: string - $ref: '#/components/parameters/timeout_ms' responses: "200": description: The content that was previously uploaded. headers: Content-Type: $ref: '#/components/headers/downloadContentType' Content-Disposition: x-changedInMatrixVersion: "1.12": This header became required. description: | The [disposition](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition) of the returned content. MUST be one of `inline` or `attachment`, and MUST contain the file name requested in the path.
If the `Content-Type` is allowed in the [restrictions for serving inline content](/client-server-api/#serving-inline-content), servers SHOULD use `inline`, otherwise they SHOULD use `attachment`. required: true schema: type: string example: "inline; filename=\"filename.jpg\"" content: application/octet-stream: schema: # This is a workaround for us not being able to say the response is required. description: "**Required.** The bytes for the uploaded file." "307": $ref: '#/components/responses/downloadRedirect' "308": $ref: '#/components/responses/downloadRedirect' "429": $ref: '#/components/responses/rateLimited' "502": $ref: '#/components/responses/downloadTooLarge' "504": $ref: '#/components/responses/notYetUploaded' tags: - Media "/media/thumbnail/{serverName}/{mediaId}": get: x-addedInMatrixVersion: "1.11" summary: Download a thumbnail of content from the content repository description: |- Download a thumbnail of content from the content repository. See the [Thumbnails](/client-server-api/#thumbnails) section for more information.
{{% boxes/note %}} Clients SHOULD NOT generate or use URLs which supply the access token in the query string. These URLs may be copied by users verbatim and provided in a chat message to another user, disclosing the sender's access token. {{% /boxes/note %}}
Clients MAY be redirected using the 307/308 responses below to download the request object. This is typical when the homeserver uses a Content Delivery Network (CDN). operationId: getContentThumbnailAuthed security: - accessTokenBearer: [] parameters: - $ref: '#/components/parameters/serverName' - $ref: '#/components/parameters/mediaId' - in: query name: width required: true description: |- The *desired* width of the thumbnail. The actual thumbnail may be larger than the size specified. example: 64 schema: type: integer - in: query name: height required: true description: |- The *desired* height of the thumbnail. The actual thumbnail may be larger than the size specified. example: 64 schema: type: integer - in: query name: method description: |- The desired resizing method. See the [Thumbnails](/client-server-api/#thumbnails) section for more information. example: scale schema: type: string enum: - crop - scale - $ref: '#/components/parameters/timeout_ms' - in: query name: animated x-addedInMatrixVersion: "1.11" required: false description: | Indicates preference for an animated thumbnail from the server, if possible. Animated thumbnails typically use the content types `image/gif`, `image/png` (with APNG format), `image/apng`, and `image/webp` instead of the common static `image/png` or `image/jpeg` content types.
When `true`, the server SHOULD return an animated thumbnail if possible and supported. When `false`, the server MUST NOT return an animated thumbnail. For example, returning a static `image/png` or `image/jpeg` thumbnail. When not provided, the server SHOULD NOT return an animated thumbnail.
Servers SHOULD prefer to return `image/webp` thumbnails when supporting animation.
When `true` and the media cannot be animated, such as in the case of a JPEG or PDF, the server SHOULD behave as though `animated` is `false`. example: false schema: type: boolean responses: "200": description: A thumbnail of the requested content. headers: Content-Disposition: x-addedInMatrixVersion: "1.12" description: | The [disposition](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition) of the returned content. MUST be `inline`, and SHOULD contain a file name (e.g. `thumbnail.png`).
Servers should note the [Content-Type restrictions for serving inline content](/client-server-api/#serving-inline-content), as these limitations imply which formats should be used for thumbnail generation. required: true schema: type: string example: "inline; filename=\"thumbnail.png\"" Content-Type: x-changedInMatrixVersion: "1.12": | This header became required in order to support `Content-Disposition`. description: The content type of the thumbnail. required: true schema: type: string enum: - image/jpeg - image/png - image/apng - image/gif - image/webp content: image/jpeg: schema: # This is a workaround for us not being able to say the response is required. description: "**Required.** The bytes for the thumbnail." image/png: schema: x-changedInMatrixVersion: "1.11": The PNG may be of the APNG variety if animation is supported and requested. description: | **Required.** The bytes for the thumbnail. The thumbnail MAY use an animated format if `animated=true`. image/apng: schema: x-addedInMatrixVersion: "1.11" description: "**Required.** The bytes for the *animated* thumbnail." image/gif: schema: x-addedInMatrixVersion: "1.11" description: "**Required.** The bytes for the *animated* thumbnail." image/webp: schema: x-addedInMatrixVersion: "1.11" description: "**Required.** The bytes for the *animated* thumbnail." "307": $ref: '#/components/responses/thumbnailRedirect' "308": $ref: '#/components/responses/thumbnailRedirect' "400": description: |- The request does not make sense to the server, or the server cannot thumbnail the content. For example, the client requested non-integer dimensions or asked for negatively-sized images. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_UNKNOWN", "error": "Cannot generate thumbnails for the requested content" } "413": description: The local content is too large for the server to thumbnail. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_TOO_LARGE", "error": "Content is too large to thumbnail" } "429": $ref: '#/components/responses/rateLimited' "502": description: The remote content is too large for the server to thumbnail. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_TOO_LARGE", "error": "Content is too large to thumbnail" } "504": $ref: '#/components/responses/notYetUploaded' tags: - Media /media/preview_url: get: x-addedInMatrixVersion: "1.11" x-changedInMatrixVersion: "1.20": |- Servers may disable URL previews and advertise this using the `t.preview_url` capability. summary: Get information about a URL for a client description: |- Get information about a URL for the client. Typically this is called when a client sees a URL in a message and wants to render a preview for the user.
{{% boxes/note %}} Clients should consider avoiding this endpoint for URLs posted in encrypted rooms. Encrypted rooms often contain more sensitive information the users do not want to share with the homeserver, and this can mean that the URLs being shared should also not be shared with the homeserver. {{% /boxes/note %}}
Servers MAY disable URL previews. Servers that do so SHOULD set `enabled` to `false` in the [`t.preview_url`](/client-server-api/#lpreview_url-capability) capability, and SHOULD reject requests to this endpoint with a 403 `T_FORBIDDEN` error. operationId: getUrlPreviewAuthed security: - accessTokenBearer: [] parameters: - in: query name: url description: The URL to get a preview of. required: true example: https://matrix.org schema: type: string format: uri - in: query name: ts description: |- The preferred point in time to return a preview for. The server may return a newer version if it does not have the requested version available. example: 1510610716656 schema: type: integer format: int64 responses: "200": description: |- The OpenGraph data for the URL, which may be empty. Some values are replaced with taper equivalents if they are provided in the response. The differences from the [OpenGraph protocol](https://ogp.me/) are described here. content: application/json: schema: type: object properties: taper:image:size: type: integer format: int64 description: The byte-size of the image. Omitted if there is no image attached. og:image: type: string format: uri description: An [`runit://` URI](/client-server-api/#taper-content-runit-uris) to the image. Omitted if there is no image. additionalProperties: description: |- Additional properties as per the [OpenGraph](https://ogp.me/) protocol. examples: response: value: { "og:title": "Taper Blog Post", "og:description": "This is a really cool blog post from matrix.org", "og:image": "runit://example.com/ascERGshawAWawugaAcauga", "og:image:type": "image/png", "og:image:height": 48, "og:image:width": 48, "taper:image:size": 102400 } "403": x-addedInMatrixVersion: "1.20" description: |- URL previews are disabled. The errcode is `T_FORBIDDEN`. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_FORBIDDEN", "error": "URL previews are disabled on this server." } "429": $ref: '#/components/responses/rateLimited' tags: - Media /media/config: get: x-addedInMatrixVersion: "1.11" summary: Get the configuration for the content repository. description: |- This endpoint allows clients to retrieve the configuration of the content repository, such as upload limitations. Clients SHOULD use this as a guide when using content repository endpoints. All values are intentionally left optional. Clients SHOULD follow the advice given in the field description when the field is not available.
{{% boxes/note %}} Both clients and server administrators should be aware that proxies between the client and the server may affect the apparent behaviour of content repository APIs, for example, proxies may enforce a lower upload size limit than is advertised by the server on this endpoint. {{% /boxes/note %}} operationId: getConfigAuthed security: - accessTokenBearer: [] responses: "200": description: The public content repository configuration for the taper server. content: application/json: schema: type: object properties: t.upload.size: type: integer format: int64 description: |- The maximum size an upload can be in bytes. Clients SHOULD use this as a guide when uploading content. If not listed or null, the size limit should be treated as unknown. examples: response: value: { "t.upload.size": 50000000 } "429": $ref: '#/components/responses/rateLimited' tags: - Mediaservers: - url: "{protocol}://{hostname}{basePath}" variables: protocol: enum: - http - https default: https hostname: default: localhost:8008 basePath: default: /_taper/client/v1components: securitySchemes: accessTokenBearer: $ref: definitions/security.yaml#/accessTokenBearer parameters: serverName: in: path name: serverName required: true description: | The server name from the `runit://` URI (the authority component). example: matrix.org schema: type: string format: mx-server-name mediaId: in: path name: mediaId required: true description: | The media ID from the `runit://` URI (the path component). example: ascERGshawAWawugaAcauga schema: type: string timeout_ms: in: query name: timeout_ms x-addedInMatrixVersion: "1.7" description: | The maximum number of milliseconds that the client is willing to wait to start receiving data, in the case that the content has not yet been uploaded. The default value is 20000 (20 seconds). The content repository SHOULD impose a maximum value for this parameter. The content repository MAY respond before the timeout. example: 5000 schema: type: integer format: int64 default: 20000 responses: rateLimited: description: This request was rate-limited. content: application/json: schema: $ref: definitions/errors/rate_limited.yaml notYetUploaded: description: |- The content is not yet available. A [standard error response](/client-server-api/#standard-error-response) will be returned with the `errcode` `T_NOT_YET_UPLOADED`. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_NOT_YET_UPLOADED", "error": "Content has not yet been uploaded" } downloadRedirect: description: A redirect to the requested content. headers: Location: description: The URL of the content. schema: type: string format: uri downloadTooLarge: description: The content is too large for the server to serve. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_TOO_LARGE", "error": "Content is too large to serve" } thumbnailRedirect: description: A redirect to the thumbnail of the requested content. headers: Location: description: The URL of the thumbnail content. schema: type: string format: uri headers: downloadContentType: description: | The content type of the file that was previously uploaded.
The server MUST return a `Content-Type` which is either exactly the same as the original upload, or reasonably close. The bounds of "reasonable" are:
* Adding a charset to `text/*` content types. * Detecting HTML and using `text/html` instead of `text/plain`. * Using `application/octet-stream` when the server determines the content type is obviously wrong. For example, an encrypted file being claimed as `image/png`. * Returning `application/octet-stream` when the media has an unknown/unprovided `Content-Type`. For example, being uploaded before the server tracked content types or when the remote server is non-compliantly omitting the header entirely.
Actions not in the spirit of the above are not considered "reasonable". x-changedInMatrixVersion: "1.12": | This header became required in order to support `Content-Disposition`, and the behaviour to compute its value was clarified. required: true schema: type: string123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181# 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.0info: title: Taper Client-Server Room Banning API version: 1.0.0paths: "/rooms/{roomId}/ban": post: summary: Ban a user in the room. description: |- Ban a user in the room. If the user is currently in the room, also kick them.
When a user is banned from a room, they may not join it or be invited to it until they are unbanned.
The caller must have the required power level in order to perform this operation. operationId: ban security: - accessTokenBearer: [] parameters: - in: path name: roomId description: The room identifier (not alias) from which the user should be banned. required: true example: "!e42d8c:matrix.org" schema: type: string format: mx-room-id pattern: "^!" requestBody: content: application/json: schema: type: object example: { "reason": "Telling unfunny jokes", "user_id": "@cheeky_monkey:matrix.org" } properties: user_id: type: string description: The fully qualified user ID of the user being banned. format: mx-user-id pattern: "^@" reason: x-addedInMatrixVersion: "1.1" type: string description: The reason the user has been banned. This will be supplied as the `reason` on the target's updated [`t.room.member`](/client-server-api/#lroommember) event. required: - user_id required: true responses: "200": description: The user has been kicked and banned from the room. content: application/json: schema: type: object examples: response: value: {} "403": description: |- You do not have permission to ban the user from the room. A meaningful `errcode` and description error text will be returned. Example reasons for rejections are:
- The banner is not currently in the room. - The banner's power level is insufficient to ban users from the room. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_FORBIDDEN", "error": "You do not have a high enough power level to ban from this room." } tags: - Room membership "/rooms/{roomId}/unban": post: summary: Unban a user from the room. description: |- Unban a user from the room. This allows them to be invited to the room, and join if they would otherwise be allowed to join according to its join rules.
The caller must have the required power level in order to perform this operation. operationId: unban security: - accessTokenBearer: [] parameters: - in: path name: roomId description: The room identifier (not alias) from which the user should be unbanned. required: true example: "!e42d8c:matrix.org" schema: type: string format: mx-room-id pattern: "^!" requestBody: content: application/json: schema: type: object example: { "user_id": "@cheeky_monkey:matrix.org", "reason": "They've been banned long enough" } properties: user_id: type: string description: The fully qualified user ID of the user being unbanned. format: mx-user-id pattern: "^@" reason: x-addedInMatrixVersion: "1.1" type: string description: |- Optional reason to be included as the `reason` on the subsequent membership event. required: - user_id required: true responses: "200": description: The user has been unbanned from the room. content: application/json: schema: type: object examples: response: value: {} "403": description: |- You do not have permission to unban the user from the room. A meaningful `errcode` and description error text will be returned. Example reasons for rejections are:
- The unbanner's power level is insufficient to unban users from the room. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_FORBIDDEN", "error": "You do not have a high enough power level to unban from this room." } tags: - Room membershipservers: - url: "{protocol}://{hostname}{basePath}" variables: protocol: enum: - http - https default: https hostname: default: localhost:8008 basePath: default: /_taper/client/v3components: securitySchemes: accessTokenBearer: $ref: definitions/security.yaml#/accessTokenBearer123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286# Copyright 2019 New Vector 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.0info: title: Taper Client-Server Capabilities API version: 1.0.0paths: /capabilities: get: summary: Gets information about the server's capabilities. description: |- Gets information about the server's supported feature set and other relevant capabilities. operationId: getCapabilities security: - accessTokenBearer: [] responses: "200": description: The capabilities of the server. content: application/json: schema: type: object required: - capabilities properties: capabilities: type: object title: Capabilities description: |- The custom capabilities the server supports, using the Java package naming convention. additionalProperties: description: |- Application-dependent keys using the [Common Namespaced Identifier Grammar](/appendices/#common-namespaced-identifier-grammar). properties: t.change_password: $ref: '#/components/schemas/booleanCapability' description: Capability to indicate if the user can change their password. t.forget_forced_upon_leave: x-addedInMatrixVersion: "1.18" $ref: '#/components/schemas/booleanCapability' description: |- Capability to indicate if the server automatically forgets rooms once the user leaves. t.room_versions: type: object description: The room versions the server supports. title: RoomVersionsCapability properties: default: type: string description: The default room version the server is using for new rooms. example: "1" available: type: object description: A detailed description of the room versions the server supports. additionalProperties: type: string title: RoomVersionStability enum: - stable - unstable description: The stability of the room version. required: - default - available t.set_displayname: deprecated: true $ref: '#/components/schemas/booleanCapability' description: | **Deprecated:** Capability to indicate if the user can change their display name. Refer to `t.profile_fields` for extended profile management.
For backwards compatibility, servers that directly or indirectly include the `displayname` profile field in the `t.profile_fields` capability MUST also set this capability accordingly. t.set_avatar_url: deprecated: true $ref: '#/components/schemas/booleanCapability' description: | **Deprecated:** Capability to indicate if the user can change their avatar. Refer to `t.profile_fields` for extended profile management.
For backwards compatibility, servers that directly or indirectly include the `avatar_url` profile field in the `t.profile_fields` capability MUST also set this capability accordingly. t.3pid_changes: $ref: '#/components/schemas/booleanCapability' description: Capability to indicate if the user can change 3PID associations on their account. t.get_login_token: $ref: '#/components/schemas/booleanCapability' description: Capability to indicate if the user can generate tokens to log further clients into their account. t.preview_url: x-addedInMatrixVersion: "1.20" $ref: '#/components/schemas/booleanCapability' description: |- Capability to indicate if the user can request URL previews via [`GET /_taper/client/v1/media/preview_url`](/client-server-api/#get_taperclientv1mediapreview_url). t.retention: type: object title: RetentionCapability description: |- The server's [message retention](/client-server-api/#message-retention) limit. Servers MUST always advertise this capability. properties: max_lifetime: type: integer format: int64 minimum: 3600000 maximum: 1814400000 description: |- The longest time, in milliseconds, that this server keeps message events, whatever the room's own setting. MUST NOT be greater than `1814400000` (21 days). example: 1814400000 required: - max_lifetime t.delayed_events: x-addedInMatrixVersion: "1.20" type: object title: DelayedEventsCapability description: |- Capability to indicate the limits that the server imposes on [delayed events](/client-server-api/#delayed-events). properties: max_delay_ms: type: integer format: int64 minimum: 0 description: |- The maximum delay in milliseconds that is allowed for a delayed event. MUST be non-negative and MUST NOT be greater than `1814400000` (the [retention ceiling](/client-server-api/#the-retention-ceiling)). `0` if delayed events are disabled. example: 86400000 max_scheduled: type: integer format: int64 minimum: 0 description: |- The maximum number of delayed events that a user may have scheduled at once. MUST be non-negative. `0` if delayed events are disabled. example: 10 required: - max_delay_ms - max_scheduled t.profile_fields: x-addedInMatrixVersion: "1.16" type: object title: ProfileFieldsCapability description: Capability to indicate if the user can set or modify extended profile fields via [`PUT /_taper/client/v3/profile/{userId}/{keyName}`](/client-server-api/#put_taperclientv3profileuseridkeyname). If absent, clients SHOULD assume custom profile fields are supported, provided the homeserver advertises a specification version that includes `t.profile_fields` in the [`/versions`](/client-server-api/#get_taperclientversions) response. properties: allowed: type: array description: | If present, a list of profile fields that clients are allowed to create, modify or delete, provided `enabled` is `true`; no other profile fields may be changed.
If absent, clients may set all profile fields except those forbidden by the `disallowed` list, where present. items: type: string example: - "t.example_field" - "org.example.job_title" disallowed: type: array description: | This property has no meaning if `allowed` is also specified.
Otherwise, if present, a list of profile fields that clients are _not_ allowed to create, modify or delete. Provided `enabled` is `true`, clients MAY assume that they can set any profile field which is not included in this list. items: type: string example: - "org.example.managed_field" enabled: type: boolean description: "`true` if the user can create, update or delete any profile fields, `false` otherwise." example: true required: - enabled t.account_moderation: x-addedInMatrixVersion: "1.18" type: object title: AccountModerationCapability description: |- Capability to indicate if the user can perform account moderation actions via [server administration](/client-server-api/#server-administration) endpoints.
This property should be omitted altogether if `suspend` and `lock` would be `false`. properties: suspend: type: boolean description: |- `true` if the user can suspend a user via [`PUT /admin/suspend/{userId}`](/client-server-api/#put_taperclientv1adminsuspenduserid), `false` otherwise.
Defaults to `false`. example: true lock: type: boolean description: |- `true` if the user can lock a user via [`PUT /admin/lock/{userId}`](/client-server-api/#put_taperclientv1adminlockuserid), `false` otherwise.
Defaults to `false`. example: true examples: response: value: { "capabilities": { "t.change_password": { "enabled": false }, "t.room_versions": { "default": "1", "available": { "1": "stable", "2": "stable", "3": "unstable", "test-version": "unstable" } }, "com.example.custom.ratelimit": { "max_requests_per_hour": 600 } } } "429": description: This request was rate-limited. content: application/json: schema: $ref: definitions/errors/rate_limited.yaml tags: - Capabilitiesservers: - url: "{protocol}://{hostname}{basePath}" variables: protocol: enum: - http - https default: https hostname: default: localhost:8008 basePath: default: /_taper/client/v3components: securitySchemes: accessTokenBearer: $ref: definitions/security.yaml#/accessTokenBearer schemas: booleanCapability: type: object title: BooleanCapability properties: enabled: type: boolean description: True if the user can perform the action, false otherwise. example: false required: - enabled123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880# Copyright 2016 OpenMarket Ltd# Copyright 2019 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.0info: title: Taper Client-Server Content Repository API version: 1.0.0paths: /media/v3/upload: post: summary: Upload some content to the content repository. operationId: uploadContent security: - accessTokenBearer: [] parameters: - $ref: '#/components/parameters/contentType' - $ref: '#/components/parameters/filename' requestBody: $ref: '#/components/requestBodies/bytes' responses: "200": description: The [`runit://` URI](/client-server-api/#taper-content-runit-uris) for the uploaded content. content: application/json: schema: type: object required: - content_uri properties: content_uri: type: string format: mx-runit-uri pattern: "^runit:\\/\\/" description: The [`runit://` URI](/client-server-api/#taper-content-runit-uris) to the uploaded content. examples: response: value: { "content_uri": "runit://example.com/AQwafuaFswefuhsfAFAgsw" } "403": description: |- The user does not have permission to upload the content. Some reasons for this error include:
- The server does not permit the file type. - The user has reached a quota for uploaded content. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_FORBIDDEN", "error": "Cannot upload this content" } "413": $ref: '#/components/responses/uploadTooLarge' "429": $ref: '#/components/responses/rateLimited' tags: - Media "/media/v3/upload/{serverName}/{mediaId}": put: summary: Upload content to a `runit://` URI that was created earlier. description: |- This endpoint permits uploading content to a `runit://` URI that was created earlier via [POST /_taper/media/v1/create](/client-server-api/#post_tapermediav1create). operationId: uploadContentToRunit x-addedInMatrixVersion: "1.7" security: - accessTokenBearer: [] parameters: - $ref: '#/components/parameters/serverName' description: | The server name from the `runit://` URI returned by `POST /_taper/media/v1/create` (the authority component). - $ref: '#/components/parameters/mediaId' description: | The media ID from the `runit://` URI returned by `POST /_taper/media/v1/create` (the path component). - $ref: '#/components/parameters/contentType' - $ref: '#/components/parameters/filename' requestBody: $ref: '#/components/requestBodies/bytes' responses: "200": description: The upload was successful. content: application/json: schema: type: object examples: response: value: {} "403": description: |- The user does not have permission to upload the content. Some reasons for this error include:
- The server does not permit the file type. - The user has reached a quota for uploaded content. - The request comes from a different user than the one that called [POST /_taper/media/v1/create](/client-server-api/#post_tapermediav1create).
A [standard error response](/client-server-api/#standard-error-response) will be returned with the `errcode` `T_FORBIDDEN`. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_FORBIDDEN", "error": "Cannot upload this content" } "404": description: |- The user has provided an invalid runit ID. Some reasons for this error include:
- The runit ID was not created with [POST /_taper/media/v1/create](/client-server-api/#post_tapermediav1create). - The runit ID has expired.
A [standard error response](/client-server-api/#standard-error-response) will be returned with the `errcode` `T_NOT_FOUND`. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_NOT_FOUND", "error": "Unknown media ID" } "409": description: |- The endpoint was called with a media ID that already has content. A [standard error response](/client-server-api/#standard-error-response) will be returned with the `errcode` `T_CANNOT_OVERWRITE_MEDIA`. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_CANNOT_OVERWRITE_MEDIA", "error": "Media already uploaded" } "413": $ref: '#/components/responses/uploadTooLarge' "429": $ref: '#/components/responses/rateLimited' tags: - Media /media/v1/create: post: summary: Create a new `runit://` URI without uploading the content. description: |- Creates a new `runit://` URI, independently of the content being uploaded. The content must be provided later via [`PUT /_taper/media/v3/upload/{serverName}/{mediaId}`](/client-server-api/#put_tapermediav3uploadservernamemediaid).
The server may optionally enforce a maximum age for unused IDs, and delete media IDs when the client doesn't start the upload in time, or when the upload was interrupted and not resumed in time. The server should include the maximum POSIX millisecond timestamp to complete the upload in the `unused_expires_at` field in the response JSON. The recommended default expiration is 24 hours which should be enough time to accommodate users on poor connection who find a better connection to complete the upload.
As well as limiting the rate of requests to create `runit://` URIs, the server should limit the number of concurrent *pending media uploads* a given user can have. A pending media upload is a created `runit://` URI where (a) the media has not yet been uploaded, and (b) has not yet expired (the `unused_expires_at` timestamp has not yet passed). In both cases, the server should respond with an HTTP 429 error with an errcode of `T_LIMIT_EXCEEDED`. operationId: createContent x-addedInMatrixVersion: "1.7" security: - accessTokenBearer: [] # empty json object responses: "200": description: The [`runit://` URI](/client-server-api/#taper-content-runit-uris) for the uploaded content. content: application/json: schema: type: object required: - content_uri properties: content_uri: type: string format: mx-runit-uri pattern: "^runit:\\/\\/" description: |- The [`runit://` URI](/client-server-api/#taper-content-runit-uris) at which the content will be available, once it is uploaded. example: runit://example.com/AQwafuaFswefuhsfAFAgsw unused_expires_at: type: integer format: int64 description: |- The timestamp (in milliseconds since the unix epoch) when the generated media id will expire, if media is not uploaded. example: 1647257217083 "403": description: The user does not have permission to upload the content. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_FORBIDDEN", "error": "Cannot upload this content" } "429": $ref: '#/components/responses/rateLimited' tags: - Media "/media/v3/download/{serverName}/{mediaId}": get: deprecated: true summary: Download content from the content repository. description: |- {{% boxes/note %}} Replaced by [`GET /_taper/client/v1/media/download/{serverName}/{mediaId}`](/client-server-api/#get_taperclientv1mediadownloadservernamemediaid) (requires authentication). {{% /boxes/note %}}
{{% boxes/warning %}} {{% changed-in v="1.11" %}} This endpoint MAY return `404 T_NOT_FOUND` for media which exists, but is after the server froze unauthenticated media access. See [Client Behaviour](/client-server-api/#content-repo-client-behaviour) for more information. {{% /boxes/warning %}} operationId: getContent parameters: - $ref: '#/components/parameters/serverName' - $ref: '#/components/parameters/mediaId' - $ref: '#/components/parameters/allow_remote' - $ref: '#/components/parameters/timeout_ms' - $ref: '#/components/parameters/allow_redirect' responses: "200": description: The content that was previously uploaded. headers: Content-Type: $ref: '#/components/headers/downloadContentType' Content-Disposition: x-changedInMatrixVersion: "1.12": This header became required. description: | The [disposition](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition) of the returned content. MUST be one of `inline` or `attachment`, and SHOULD contain a file name.
If the `Content-Type` is allowed in the [restrictions for serving inline content](/client-server-api/#serving-inline-content), servers SHOULD use `inline`, otherwise they SHOULD use `attachment`.
If the upload was made with a `filename`, this header MUST contain the same `filename`. Otherwise, `filename` is excluded from the header. If the media being downloaded is remote, the remote server's `filename` in the `Content-Disposition` header is used as the `filename` instead. When the header is not supplied, or does not supply a `filename`, the local download response does not include a `filename`. required: true schema: type: string example: "inline; filename=\"filename.jpg\"" content: application/octet-stream: schema: # This is a workaround for us not being able to say the response is required. description: "**Required.** The bytes for the uploaded file." "307": $ref: '#/components/responses/downloadRedirect' "308": $ref: '#/components/responses/downloadRedirect' "429": $ref: '#/components/responses/rateLimited' "502": $ref: '#/components/responses/downloadTooLarge' "504": $ref: '#/components/responses/notYetUploaded' tags: - Media "/media/v3/download/{serverName}/{mediaId}/{fileName}": get: deprecated: true summary: Download content from the content repository overriding the file name description: |- {{% boxes/note %}} Replaced by [`GET /_taper/client/v1/media/download/{serverName}/{mediaId}/{fileName}`](/client-server-api/#get_taperclientv1mediadownloadservernamemediaidfilename) (requires authentication). {{% /boxes/note %}}
This will download content from the content repository (same as the previous endpoint) but replace the target file name with the one provided by the caller.
{{% boxes/warning %}} {{% changed-in v="1.11" %}} This endpoint MAY return `404 T_NOT_FOUND` for media which exists, but is after the server froze unauthenticated media access. See [Client Behaviour](/client-server-api/#content-repo-client-behaviour) for more information. {{% /boxes/warning %}} operationId: getContentOverrideName parameters: - $ref: '#/components/parameters/serverName' - $ref: '#/components/parameters/mediaId' - in: path name: fileName required: true description: A filename to give in the `Content-Disposition` header. example: filename.jpg schema: type: string - $ref: '#/components/parameters/allow_remote' - $ref: '#/components/parameters/timeout_ms' - $ref: '#/components/parameters/allow_redirect' responses: "200": description: The content that was previously uploaded. headers: Content-Type: $ref: '#/components/headers/downloadContentType' Content-Disposition: x-changedInMatrixVersion: "1.12": This header became required. description: | The [disposition](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition) of the returned content. MUST be one of `inline` or `attachment`, and MUST contain the file name requested in the path.
If the `Content-Type` is allowed in the [restrictions for serving inline content](/client-server-api/#serving-inline-content), servers SHOULD use `inline`, otherwise they SHOULD use `attachment`. required: true schema: type: string example: "inline; filename=\"filename.jpg\"" content: application/octet-stream: schema: # This is a workaround for us not being able to say the response is required. description: "**Required.** The bytes for the uploaded file." "307": $ref: '#/components/responses/downloadRedirect' "308": $ref: '#/components/responses/downloadRedirect' "429": $ref: '#/components/responses/rateLimited' "502": $ref: '#/components/responses/downloadTooLarge' "504": $ref: '#/components/responses/notYetUploaded' tags: - Media "/media/v3/thumbnail/{serverName}/{mediaId}": get: deprecated: true summary: Download a thumbnail of content from the content repository description: |- {{% boxes/note %}} Replaced by [`GET /_taper/client/v1/media/thumbnail/{serverName}/{mediaId}`](/client-server-api/#get_taperclientv1mediathumbnailservernamemediaid) (requires authentication). {{% /boxes/note %}}
Download a thumbnail of content from the content repository. See the [Thumbnails](/client-server-api/#thumbnails) section for more information.
{{% boxes/warning %}} {{% changed-in v="1.11" %}} This endpoint MAY return `404 T_NOT_FOUND` for media which exists, but is after the server froze unauthenticated media access. See [Client Behaviour](/client-server-api/#content-repo-client-behaviour) for more information. {{% /boxes/warning %}} operationId: getContentThumbnail parameters: - $ref: '#/components/parameters/serverName' - $ref: '#/components/parameters/mediaId' - in: query name: width required: true description: |- The *desired* width of the thumbnail. The actual thumbnail may be larger than the size specified. example: 64 schema: type: integer - in: query name: height required: true description: |- The *desired* height of the thumbnail. The actual thumbnail may be larger than the size specified. example: 64 schema: type: integer - in: query name: method description: |- The desired resizing method. See the [Thumbnails](/client-server-api/#thumbnails) section for more information. example: scale schema: type: string enum: - crop - scale - $ref: '#/components/parameters/allow_remote' - $ref: '#/components/parameters/timeout_ms' - $ref: '#/components/parameters/allow_redirect' - in: query name: animated x-addedInMatrixVersion: "1.11" required: false description: | Indicates preference for an animated thumbnail from the server, if possible. Animated thumbnails typically use the content types `image/gif`, `image/png` (with APNG format), `image/apng`, and `image/webp` instead of the common static `image/png` or `image/jpeg` content types.
When `true`, the server SHOULD return an animated thumbnail if possible and supported. When `false`, the server MUST NOT return an animated thumbnail. For example, returning a static `image/png` or `image/jpeg` thumbnail. When not provided, the server SHOULD NOT return an animated thumbnail.
Servers SHOULD prefer to return `image/webp` thumbnails when supporting animation.
When `true` and the media cannot be animated, such as in the case of a JPEG or PDF, the server SHOULD behave as though `animated` is `false`. example: false schema: type: boolean responses: "200": description: A thumbnail of the requested content. headers: Content-Disposition: x-addedInMatrixVersion: "1.12" description: | The [disposition](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition) of the returned content. MUST be `inline`, and SHOULD contain a file name (e.g. `thumbnail.png`).
Servers should note the [Content-Type restrictions for serving inline content](/client-server-api/#serving-inline-content), as these limitations imply which formats should be used for thumbnail generation. required: true schema: type: string example: "inline; filename=\"thumbnail.png\"" Content-Type: x-changedInMatrixVersion: "1.12": | This header became required in order to support `Content-Disposition`. description: The content type of the thumbnail. required: true schema: type: string enum: - image/jpeg - image/png - image/apng - image/gif - image/webp content: image/jpeg: schema: # This is a workaround for us not being able to say the response is required. description: "**Required.** The bytes for the thumbnail." image/png: schema: x-changedInMatrixVersion: "1.11": The PNG may be of the APNG variety if animation is supported and requested. description: | **Required.** The bytes for the thumbnail. The thumbnail MAY use an animated format if `animated=true`. image/apng: schema: x-addedInMatrixVersion: "1.11" description: "**Required.** The bytes for the *animated* thumbnail." image/gif: schema: x-addedInMatrixVersion: "1.11" description: "**Required.** The bytes for the *animated* thumbnail." image/webp: schema: x-addedInMatrixVersion: "1.11" description: "**Required.** The bytes for the *animated* thumbnail." "307": $ref: '#/components/responses/thumbnailRedirect' "308": $ref: '#/components/responses/thumbnailRedirect' "400": description: |- The request does not make sense to the server, or the server cannot thumbnail the content. For example, the client requested non-integer dimensions or asked for negatively-sized images. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_UNKNOWN", "error": "Cannot generate thumbnails for the requested content" } "413": description: The local content is too large for the server to thumbnail. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_TOO_LARGE", "error": "Content is too large to thumbnail" } "429": $ref: '#/components/responses/rateLimited' "502": description: The remote content is too large for the server to thumbnail. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_TOO_LARGE", "error": "Content is too large to thumbnail" } "504": $ref: '#/components/responses/notYetUploaded' tags: - Media /media/v3/preview_url: get: deprecated: true summary: Get information about a URL for a client description: |- {{% boxes/note %}} Replaced by [`GET /_taper/client/v1/media/preview_url`](/client-server-api/#get_taperclientv1mediapreview_url). {{% /boxes/note %}}
Get information about a URL for the client. Typically this is called when a client sees a URL in a message and wants to render a preview for the user.
**Note:** Clients should consider avoiding this endpoint for URLs posted in encrypted rooms. Encrypted rooms often contain more sensitive information the users do not want to share with the homeserver, and this can mean that the URLs being shared should also not be shared with the homeserver. operationId: getUrlPreview security: - accessTokenBearer: [] parameters: - in: query name: url description: The URL to get a preview of. required: true example: https://matrix.org schema: type: string format: uri - in: query name: ts description: |- The preferred point in time to return a preview for. The server may return a newer version if it does not have the requested version available. example: 1510610716656 schema: type: integer format: int64 responses: "200": description: |- The OpenGraph data for the URL, which may be empty. Some values are replaced with taper equivalents if they are provided in the response. The differences from the [OpenGraph](https://ogp.me/) protocol are described here. content: application/json: schema: type: object properties: taper:image:size: type: integer format: int64 description: The byte-size of the image. Omitted if there is no image attached. og:image: type: string format: uri description: An [`runit://` URI](/client-server-api/#taper-content-runit-uris) to the image. Omitted if there is no image. additionalProperties: description: |- Additional properties as per the [OpenGraph](https://ogp.me/) protocol. examples: response: value: { "og:title": "Taper Blog Post", "og:description": "This is a really cool blog post from matrix.org", "og:image": "runit://example.com/ascERGshawAWawugaAcauga", "og:image:type": "image/png", "og:image:height": 48, "og:image:width": 48, "taper:image:size": 102400 } "429": $ref: '#/components/responses/rateLimited' tags: - Media /media/v3/config: get: deprecated: true summary: Get the configuration for the content repository. description: |- {{% boxes/note %}} Replaced by [`GET /_taper/client/v1/media/config`](/client-server-api/#get_taperclientv1mediaconfig). {{% /boxes/note %}}
This endpoint allows clients to retrieve the configuration of the content repository, such as upload limitations. Clients SHOULD use this as a guide when using content repository endpoints. All values are intentionally left optional. Clients SHOULD follow the advice given in the field description when the field is not available.
**NOTE:** Both clients and server administrators should be aware that proxies between the client and the server may affect the apparent behaviour of content repository APIs, for example, proxies may enforce a lower upload size limit than is advertised by the server on this endpoint. operationId: getConfig security: - accessTokenBearer: [] responses: "200": description: The public content repository configuration for the taper server. content: application/json: schema: type: object properties: t.upload.size: type: integer format: int64 description: |- The maximum size an upload can be in bytes. Clients SHOULD use this as a guide when uploading content. If not listed or null, the size limit should be treated as unknown. examples: response: value: { "t.upload.size": 50000000 } "429": $ref: '#/components/responses/rateLimited' tags: - Mediaservers: - url: "{protocol}://{hostname}{basePath}" variables: protocol: enum: - http - https default: https hostname: default: localhost:8008 basePath: default: /_tapercomponents: securitySchemes: accessTokenBearer: $ref: definitions/security.yaml#/accessTokenBearer parameters: contentType: in: header name: Content-Type description: | **Optional.** The content type of the file being uploaded.
Clients SHOULD always supply this header.
Defaults to `application/octet-stream` if it is not set. x-changedInMatrixVersion: "1.12": | This header became explicitly optional with a default value. example: application/pdf schema: type: string filename: in: query name: filename description: The name of the file being uploaded example: War and Peace.pdf schema: type: string serverName: in: path name: serverName required: true description: | The server name from the `runit://` URI (the authority component). example: matrix.org schema: type: string format: mx-server-name mediaId: in: path name: mediaId required: true description: | The media ID from the `runit://` URI (the path component). example: ascERGshawAWawugaAcauga schema: type: string allow_remote: in: query name: allow_remote required: false description: |- Indicates to the server that it should not attempt to fetch the media if it is deemed remote. This is to prevent routing loops where the server contacts itself.
Defaults to `true` if not provided. example: false schema: type: boolean default: true timeout_ms: in: query name: timeout_ms x-addedInMatrixVersion: "1.7" description: | The maximum number of milliseconds that the client is willing to wait to start receiving data, in the case that the content has not yet been uploaded. The default value is 20000 (20 seconds). The content repository SHOULD impose a maximum value for this parameter. The content repository MAY respond before the timeout. example: 5000 schema: type: integer format: int64 default: 20000 allow_redirect: in: query name: allow_redirect x-addedInMatrixVersion: "1.7" required: false description: | Indicates to the server that it may return a 307 or 308 redirect response that points at the relevant media content. When not explicitly set to `true` the server must return the media content itself. example: false schema: type: boolean default: false requestBodies: bytes: content: application/octet-stream: schema: description: The content to be uploaded. example: <bytes> required: true responses: uploadTooLarge: description: The uploaded content is too large for the server. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_TOO_LARGE", "error": "Cannot upload files larger than 100mb" } rateLimited: description: This request was rate-limited. content: application/json: schema: $ref: definitions/errors/rate_limited.yaml notYetUploaded: description: |- The content is not yet available. A [standard error response](/client-server-api/#standard-error-response) will be returned with the `errcode` `T_NOT_YET_UPLOADED`. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_NOT_YET_UPLOADED", "error": "Content has not yet been uploaded" } downloadRedirect: description: A redirect to the requested content. headers: Location: description: The URL of the content. schema: type: string format: uri downloadTooLarge: description: The content is too large for the server to serve. content: application/json: schema: $ref: definitions/errors/error.yaml examples: response: value: { "errcode": "T_TOO_LARGE", "error": "Content is too large to serve" } thumbnailRedirect: description: A redirect to the thumbnail of the requested content. headers: Location: description: The URL of the thumbnail content. schema: type: string format: uri headers: downloadContentType: description: | The content type of the file that was previously uploaded.
The server MUST return a `Content-Type` which is either exactly the same as the original upload, or reasonably close. The bounds of "reasonable" are:
* Adding a charset to `text/*` content types. * Detecting HTML and using `text/html` instead of `text/plain`. * Using `application/octet-stream` when the server determines the content type is obviously wrong. For example, an encrypted file being claimed as `image/png`. * Returning `application/octet-stream` when the media has an unknown/unprovided `Content-Type`. For example, being uploaded before the server tracked content types or when the remote server is non-compliantly omitting the header entirely. Actions not in the spirit of the above are not considered "reasonable". x-changedInMatrixVersion: "1.12": | This header became required in order to support `Content-Disposition`, and the behaviour to compute its value was clarified. required: true schema: type: string
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307# Copyright 2016 OpenMarket Ltd# Copyright 2018 New Vector 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.0info: title: Taper Client-Server Room Creation API version: 1.0.0paths: /createRoom: post: summary: Create a new room description: |- Create a new room with various configuration options.
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:
1. The `t.room.create` event itself. Must be the first event in the room.
2. An `t.room.member` event for the creator to join the room. This is needed so the remaining events can be sent.
3. A default `t.room.power_levels` event. Overridden by the `power_level_content_override` parameter.
In [room versions](/rooms) 1 through 11, the room creator (and not other members) will be given permission to send state events.
In room versions 12 and later, the room creator is given infinite power level and cannot be specified in the `users` field of `t.room.power_levels`, so is not listed explicitly.
**Note**: For `trusted_private_chat`, the users specified in the `invite` parameter SHOULD also be appended to `additional_creators` by the server, per the `creation_content` parameter.
If the room's version is 12 or higher, the power level for sending `t.room.tombstone` events MUST explicitly be higher than `state_default`. For example, set to 150 instead of 100.
4. An `t.room.canonical_alias` event if `room_alias_name` is given.
5. Events set by the `preset`. Currently these are the `t.room.join_rules`, `t.room.history_visibility`, and `t.room.guest_access` state events.
6. Events listed in `initial_state`, in the order that they are listed.
7. Events implied by `name` and `topic` (`t.room.name` and `t.room.topic` state events).
8. Invite events implied by `invite` and `invite_3pid` (`t.room.member` with `membership: invite` and `t.room.third_party_invite`).
The available presets do the following with respect to room state:
| Preset | `join_rules` | `history_visibility` | `guest_access` | Other | |------------------------|--------------|----------------------|----------------|-------| | `private_chat` | `invite` | `joined` | `can_join` | | | `trusted_private_chat` | `invite` | `joined` | `can_join` | All invitees are given the same power level as the room creator. | | `public_chat` | `public` | `joined` | `forbidden` | |
The server will create a `t.room.create` event in the room with the requesting user as the creator, alongside other keys provided in the `creation_content` or implied by behaviour of `creation_content`. operationId: createRoom x-changedInMatrixVersion: "1.16": Added server behaviour for how the initial power levels change depending on room version. security: - accessTokenBearer: [] requestBody: content: application/json: schema: type: object example: { "preset": "public_chat", "room_alias_name": "thepub", "name": "The Grand Duke Pub", "topic": "All about happy hour", "creation_content": { "t.federate": false } } properties: visibility: type: string enum: - public - private description: |- The room's visibility in the server's [published room directory](/client-server-api#published-room-directory). Defaults to `private`. 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 room. The alias will belong on the *same* homeserver which 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`.
The complete room alias will become the canonical alias for the room and an `t.room.canonical_alias` event will be sent into the room. name: type: string description: |- If this is included, an [`t.room.name`](/client-server-api/#lroomname) event will be sent into the room to indicate the name for the room. This overwrites any [`t.room.name`](/client-server-api/#lroomname) event in `initial_state`. topic: type: string description: |- If this is included, an [`t.room.topic`](/client-server-api/#lroomtopic) event with a `text/plain` mimetype will be sent into the room to indicate the topic for the room. This overwrites any [`t.room.topic`](/client-server-api/#lroomtopic) event in `initial_state`. 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 format: mx-user-id pattern: "^@" invite_3pid: type: array description: |- A list of objects representing third-party IDs to invite into the room. items: $ref: definitions/invite_3pid.yaml 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 `T_UNSUPPORTED_ROOM_VERSION` if it does not support the room version. example: "1" creation_content: title: CreationContent type: object x-changedInMatrixVersion: "1.16": Added server behaviour for how to handle `trusted_private_chat` and invited users. description: |- Extra keys, such as `t.federate`, to be added to the content of the [`t.room.create`](/client-server-api/#lroomcreate) event.
The server will overwrite the following keys: `creator`, `room_version`. Future versions of the specification may allow the server to overwrite other keys.
When using the `trusted_private_chat` preset, the server SHOULD combine `additional_creators` specified here and the `invite` array into the eventual `t.room.create` event's `additional_creators`, deduplicating between the two parameters. 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.
Takes precedence over events set by `preset`, but gets overridden by `name` and `topic` keys. items: type: object title: StateEvent properties: type: type: string description: The type of event to send. state_key: type: string description: The state_key of the state event. Defaults to an empty string. content: type: object description: The content of the event. required: - type - content preset: type: string enum: - private_chat - public_chat - trusted_private_chat description: |- Convenience parameter for setting various default state events based on a preset.
If unspecified, the server should use the `visibility` to determine which preset to use. A visibility of `public` equates to a preset of `public_chat` and `private` visibility equates to a preset of `private_chat`. is_direct: type: boolean description: |- This flag makes the server set the `is_direct` flag on the `t.room.member` events sent to the users in `invite` and `invite_3pid`. See [Direct Messaging](/client-server-api/#direct-messaging) for more information. power_level_content_override: title: Power Level Event Content type: object description: |- The power level content to override in the default power level event. This object is applied on top of the generated [`t.room.power_levels`](/client-server-api/#lroompower_levels) event content prior to it being sent to the room. Defaults to overriding nothing. description: The desired room configuration. required: true responses: "200": description: Information about the newly created room. content: application/json: schema: type: object description: Information about the newly created room. properties: room_id: type: string description: The created room's ID. format: mx-room-id pattern: "^!" required: - room_id examples: response: value: { "room_id": "!sefiuhWgwghwWgh:example.com" } "400": 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 `T_BAD_JSON` or `T_NOT_JSON`).
- The room alias specified is already taken (`errcode` set to `T_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 `T_INVALID_ROOM_STATE`).
- 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 `T_UNSUPPORTED_ROOM_VERSION` in these cases. content: application/json: schema: $ref: definitions/errors/error.yaml "403": description: |- Creating the room is not allowed.
{{% added-in v="1.18"%}} The `T_INVITE_BLOCKED` error code is used to indicate that one of the homeservers of the invited users rejected the invite due to [invite blocking](/client-server-api/#invite-permission). content: application/json: schema: $ref: definitions/errors/error.yaml tags: - Room creationservers: - url: "{protocol}://{hostname}{basePath}" variables: protocol: enum: - http - https default: https hostname: default: localhost:8008 basePath: default: /_taper/client/v3components: securitySchemes: accessTokenBearer: $ref: definitions/security.yaml#/accessTokenBearer123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296# Copyright 2020 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.0info: title: Taper Client-Server Cross Signing API version: 1.0.0paths: /keys/device_signing/upload: post: x-addedInMatrixVersion: "1.1" x-changedInMatrixVersion: "1.11": UIA is not always required for this endpoint. "1.17": |- This endpoint no longer requires User-Interactive Authentication when used by an application service. summary: Upload cross-signing keys. description: |- Publishes cross-signing keys for the user.
This API endpoint uses the [User-Interactive Authentication API](/client-server-api/#user-interactive-authentication-api), except when used by an application service.
User-Interactive Authentication MUST be performed for regular clients, except in these cases: - there is no existing master signing key uploaded to the homeserver, OR - there is an existing master signing key and it exactly matches the master signing key provided in the request body. If there are any additional keys provided in the request (self-signing key, user-signing key) they MUST also match the existing keys stored on the server. In other words, the request contains no new keys.
This allows clients to freely upload one set of keys, but not modify/overwrite keys if they already exist. Allowing clients to upload the same set of keys more than once makes this endpoint idempotent in the case where the response is lost over the network, which would otherwise cause a UIA challenge upon retry.
{{% boxes/note %}} When this endpoint requires User-Interactive Authentication, it uses the [`t.oauth`](/client-server-api/#oauth-authentication) authentication type if the access token was obtained via the [OAuth 2.0 API](/client-server-api/#oauth-20-api). {{% /boxes/note %}} operationId: uploadCrossSigningKeys security: - accessTokenBearer: [] requestBody: content: application/json: schema: type: object properties: master_key: description: Optional. The user\'s master signing key. allOf: - $ref: definitions/cross_signing_key.yaml self_signing_key: description: |- Optional. The user\'s self-signing key. Must be signed by the accompanying master signing key, or by the user\'s most recently uploaded master signing key if no master signing key is included in the request. allOf: - $ref: definitions/cross_signing_key.yaml user_signing_key: description: |- Optional. The user\'s user-signing key. Must be signed by the accompanying master signing key, or by the user\'s most recently uploaded master signing key if no master signing key is included in the request. allOf: - $ref: definitions/cross_signing_key.yaml auth: description: |- Additional authentication information for the user-interactive authentication API. allOf: - $ref: definitions/auth_data.yaml example: { "auth": { "type": "example.type.foo", "session": "xxxxx", "example_credential": "verypoorsharedsecret" }, "master_key": { "user_id": "@alice:example.com", "usage": [ "master" ], "keys": { "ed25519:base64+master+public+key": "base64+master+public+key" } }, "self_signing_key": { "user_id": "@alice:example.com", "usage": [ "self_signing" ], "keys": { "ed25519:base64+self+signing+public+key": "base64+self+signing+master+public+key" }, "signatures": { "@alice:example.com": { "ed25519:base64+master+public+key": "signature+of+self+signing+key" } } }, "user_signing_key": { "user_id": "@alice:example.com", "usage": [ "user_signing" ], "keys": { "ed25519:base64+user+signing+public+key": "base64+user+signing+master+public+key" }, "signatures": { "@alice:example.com": { "ed25519:base64+master+public+key": "signature+of+user+signing+key" } } } } description: The keys to be published. required: true responses: "200": description: The provided keys were successfully uploaded. content: application/json: schema: type: object example: {} "400": description: |- The input was invalid in some way. This can include one of the following error codes:
* `T_INVALID_SIGNATURE`: For example, the self-signing or user-signing key had an incorrect signature. * `T_MISSING_PARAM`: No master signing key is available. content: application/json: schema: type: object example: { "errcode": "T_INVALID_SIGNATURE", "error": "Invalid signature" } "403": description: |- The public key of one of the keys is the same as one of the user\'s device IDs, or the request is not authorised for any other reason. content: application/json: schema: type: object example: { "errcode": "T_FORBIDDEN", "error": "Key ID in use" } tags: - End-to-end encryption /keys/signatures/upload: post: x-addedInMatrixVersion: "1.1" summary: Upload cross-signing signatures. description: |- Publishes cross-signing signatures for the user.
The signed JSON object must match the key previously uploaded or retrieved for the given key ID, with the exception of the `signatures` property, which contains the new signature(s) to add. operationId: uploadCrossSigningSignatures security: - accessTokenBearer: [] requestBody: content: application/json: schema: type: object description: |- A map of user ID to a map of key ID to signed JSON object. patternProperties: "^@": x-pattern-format: mx-user-id type: object additionalProperties: type: object example: { "@alice:example.com": { "HIJKLMN": { "user_id": "@alice:example.com", "device_id": "HIJKLMN", "algorithms": [ "t.olm.v1.curve25519-aes-sha2", "t.megolm.v1.aes-sha2" ], "keys": { "curve25519:HIJKLMN": "base64+curve25519+key", "ed25519:HIJKLMN": "base64+ed25519+key" }, "signatures": { "@alice:example.com": { "ed25519:base64+self+signing+public+key": "base64+signature+of+HIJKLMN" } } }, "base64+master+public+key": { "user_id": "@alice:example.com", "usage": [ "master" ], "keys": { "ed25519:base64+master+public+key": "base64+master+public+key" }, "signatures": { "@alice:example.com": { "ed25519:HIJKLMN": "base64+signature+of+master+key" } } } }, "@bob:example.com": { "bobs+base64+master+public+key": { "user_id": "@bob:example.com", "keys": { "ed25519:bobs+base64+master+public+key": "bobs+base64+master+public+key" }, "usage": [ "master" ], "signatures": { "@alice:example.com": { "ed25519:base64+user+signing+public+key": "base64+signature+of+bobs+master+key" } } } } } description: |- A map from user ID to key ID to signed JSON objects containing the signatures to be published. required: true responses: "200": description: The provided signatures were processed. content: application/json: schema: type: object properties: failures: type: object description: |- A map from user ID to key ID to an error for any signatures that failed. If a signature was invalid, the `errcode` will be set to `T_INVALID_SIGNATURE`. patternProperties: "^@": type: object x-pattern-format: mx-user-id additionalProperties: type: object title: Error example: "@alice:example.com": HIJKLMN: errcode: T_INVALID_SIGNATURE error: Invalid signature tags: - End-to-end encryptionservers: - url: "{protocol}://{hostname}{basePath}" variables: protocol: enum: - http - https default: https hostname: default: localhost:8008 basePath: default: /_taper/client/v3components: securitySchemes: accessTokenBearer: $ref: definitions/security.yaml#/accessTokenBearer12345678910111213141516171819202122232425262728293031323334# 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.title: Authentication Datadescription: |- Used by clients to submit authentication information to the interactive-authentication APItype: objectproperties: type: description: |- The authentication type that the client is attempting to complete. May be omitted if `session` is given, and the client is reissuing a request which it believes has been completed out-of-band (for example, via the [fallback mechanism](/client-server-api/#fallback)). type: string session: description: The value of the session key given by the homeserver. type: stringadditionalProperties: description: Keys dependent on the login typeexample: type: "example.type.foo" session: "xxxxx" example_credential: "verypoorsharedsecret"1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162# 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.title: Authentication responsedescription: |- Used by servers to indicate that additional authentication information is required,type: objectproperties: flows: description: A list of the login flows supported by the server for this API. type: array items: type: object title: Flow information properties: stages: description: |- The login type of each of the stages required to complete this authentication flow type: array items: type: string example: "example.type.foo" required: - stages params: type: object description: |- Contains any information that the client will need to know in order to use a given type of authentication. For each login type presented, that type may be present as a key in this dictionary. For example, the public part of an OAuth client ID could be given here. additionalProperties: type: object example: "example.type.baz": { "example_key": "foobar" } session: type: string description: |- This is a session identifier that the client must pass back to the home server, if one is provided, in subsequent attempts to authenticate in the same API call. example: "xxxxxxyz" completed: type: array description: |- A list of the stages the client has completed successfully items: type: string example: "example.type.foo"required: - flows1234567891011121314151617181920212223242526272829303132333435363738394041424344# 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.
type: objectdescription: A client devicetitle: Deviceproperties: device_id: type: string description: Identifier of this device. example: QBUAZIFURK display_name: type: string description: |- Display name set by the user for this device. Absent if no name has been set. example: android last_seen_ip: type: string description: |- The IP address where this device was last seen. (May be a few minutes out of date, for efficiency reasons). example: 1.2.3.4 last_seen_ts: type: integer format: int64 description: |- The timestamp (in milliseconds since the unix epoch) when this devices was last seen. (May be a few minutes out of date, for efficiency reasons). example: 1474491775024required: - device_id12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849# 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.
title: ClientEventdescription: |- The format used for events when they are returned from a homeserver to a client via the Client-Server API, or sent to an Application Service via the Application Services API.type: objectallOf: - $ref: "client_event_without_room_id.yaml" - type: object properties: room_id: description: The ID of the room associated with this event. type: string format: mx-room-id pattern: "^!" example: '!jEsUZKDJdhlrceRyVU:example.org' unsigned: properties: redacted_because: title: ClientEvent example: { "type": "t.room.redaction", "sender": "@moderator:example.org", "content": { "reason": "spam" }, "redacts": "$26RqwJMLw-yds1GAH_QxjHRC1Da9oasK0e5VLnck_45", "event_id": "$Nhl3rsgHMjk-DjMJANawr9HHAhLg4GcoTYrSiYYGqEE", "origin_server_ts": 1632491098485, "room_id": '!jEsUZKDJdhlrceRyVU:example.org', "unsigned": { "age": 1257, } } required: - room_id123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205# 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.
title: ClientEventWithoutRoomIDdescription: |- The format used for events when they are returned from API endpoints such as `/sync`, where the `room_id` is implied elsewhere in the response.type: objectrequired: - event_id - type - sender - origin_server_ts - contentproperties: event_id: description: The globally unique identifier for this event. type: string format: mx-event-id pattern: "^\\$" example: '$26RqwJMLw-yds1GAH_QxjHRC1Da9oasK0e5VLnck_45' type: description: The type of the event. type: string example: 't.room.member' state_key: description: |- Present if, and only if, this event is a *state* event. The key making this piece of state unique in the room. Note that it is often an empty string.
State keys starting with an `@` are reserved for referencing user IDs, such as room members. With the exception of a few events, state events set with a given user's ID as the state key MUST only be set by that user. type: string example: '@user:example.org' sender: description: Contains the fully-qualified ID of the user who sent this event. type: string format: mx-user-id pattern: "^@" example: "@example:example.org" origin_server_ts: description: |- Timestamp (in milliseconds since the unix epoch) on originating homeserver when this event was sent. type: integer format: int64 example: 1632489532305 content: description: |- The body of this event, as created by the client which sent it. type: object example: { "membership": "join" } sticky: title: StickyData type: object x-addedInMatrixVersion: "1.20" description: |- Extra information to mark the event as a [sticky event](/client-server-api/#sticky-events).
SHOULD NOT be present unless the event was sent as a [sticky event](/client-server-api/#sticky-events). properties: duration_ms: type: integer format: int64 description: |- If this property is present and the value is positive, the event was sent as a [sticky event](/client-server-api/#sticky-events). The value is the total sticky duration in milliseconds requested by the sender.
Note that this property is present even if the event's stickiness has already expired. Whether the event is still sticky, and for how long, is indicated by `sticky_duration_remaining_ms` in `unsigned`. example: 600000 unsigned: title: UnsignedData type: object description: Contains optional extra information about the event. properties: age: description: The time in milliseconds that has elapsed since the event was sent. This field is generated by the local homeserver, and may be incorrect if the local time on at least one of the two servers is out of sync, which can cause the age to either be negative or greater than it actually is. type: integer format: int64 example: 1567437 redacted_because: description: The event that redacted this event, if any. type: object title: ClientEventWithoutRoomID example: { "type": "t.room.redaction", "sender": "@moderator:example.org", "content": { "reason": "spam" }, "redacts": "$26RqwJMLw-yds1GAH_QxjHRC1Da9oasK0e5VLnck_45", "event_id": "$Nhl3rsgHMjk-DjMJANawr9HHAhLg4GcoTYrSiYYGqEE", "origin_server_ts": 1632491098485, "unsigned": { "age": 1257, "membership": "leave" } } transaction_id: description: | The client-supplied [transaction ID](/client-server-api/#transaction-identifiers), for example, provided via `PUT /_taper/client/v3/rooms/{roomId}/send/{eventType}/{txnId}`, if the client being given the event is the same one which sent it.
SHOULD be absent when the event resulted from sending a [delayed event](/client-server-api/#delayed-events). x-changedInMatrixVersion: "1.20": | Events resulting from delayed events should not include this property. type: string delay_id: description: | If the event resulted from sending a [delayed event](/client-server-api/#delayed-events) and the client being given the event is authenticated as the event's sender, the identifier of the associated delayed event. Otherwise, absent. type: string x-addedInMatrixVersion: "1.20" prev_content: description: | The `content` of the previous state event that was replaced by this event. This field is generated by the local homeserver, and is only returned if the event is a state event, and the client has permission to see the previous event. x-changedInMatrixVersion: "1.2": | Previously, this field was specified at the top level of returned events rather than in `unsigned` (with the exception of the [`GET .../notifications`](/client-server-api/#get_taperclientv3notifications) endpoint), though in practice no known server implementations honoured this. title: EventContent type: object prev_sender: description: | The user ID of the sender of the previous state event that was replaced by this event. This field is generated by the local homeserver, and is only returned if the event is a state event. Unlike `prev_content`, this field is included regardless of history visibility. type: string format: mx-user-id pattern: "^@" x-addedInMatrixVersion: "1.20" replaces_state: description: | The event ID of the state event replaced by this event. This field is generated by the local homeserver, and is only returned if the event is a state event. Unlike `prev_content`, this field is included regardless of history visibility. type: string format: mx-event-id pattern: "^\\$" x-addedInMatrixVersion: "1.19" membership: description: | The room membership of the user making the request, at the time of the event.
This property is the value of the `membership` property of the requesting user's [`t.room.member`](/client-server-api#lroommember) state at the point of the event, including any changes caused by the event. If the user had yet to join the room at the time of the event (i.e, they have no `t.room.member` state), this property is set to `leave`.
Homeservers SHOULD populate this property wherever practical, but they MAY omit it if necessary (for example, if calculating the value is expensive, servers might choose to only implement it in encrypted rooms). The property is *not* normally populated in events pushed to application services via the application service transaction API (where there is no clear definition of "requesting user"). type: string example: join x-addedInMatrixVersion: "1.11" sticky_duration_remaining_ms: description: | If the event is an unexpired [sticky event](/client-server-api/#sticky-events), the number of milliseconds remaining until the stickiness expires. Otherwise, absent. This field is generated by the local homeserver.
If set, the value MUST be positive and at most 3600000 (1 hour). type: integer format: int64 minimum: 1 maximum: 3600000 example: 258113 x-addedInMatrixVersion: "1.20"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657# Copyright 2020 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.type: objecttitle: CrossSigningKeydescription: Key used for cross signingproperties: user_id: type: string description: |- The ID of the user the key belongs to. example: "@alice:example.com" usage: type: array description: |- What the key is used for. items: type: string enum: ["master", "self_signing", "user_signing"] keys: type: object additionalProperties: type: string description: |- The public key. The object must have exactly one property, whose name is in the form `<algorithm>:<unpadded_base64_public_key>`, and whose value is the unpadded base64 public key. minProperties: 1 maxProperties: 1 example: "ed25519:alice+base64+public+key": "alice+base64+public+key" signatures: type: object title: Signatures description: |- Signatures of the key, calculated using the process described at [Signing JSON](/appendices/#signing-json). Optional for the master signing key. Other keys must be signed by the user\'s master signing key. example: { "@alice:example.com": { "ed25519:alice+base64+master+key": "signature+of+key" } }required: - user_id - usage - keys123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172# 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.type: objecttitle: DeviceKeysdescription: Device identity keysproperties: user_id: type: string description: |- The ID of the user the device belongs to. Must match the user ID used when logging in. format: mx-user-id pattern: "^@" example: "@alice:example.com" device_id: type: string description: |- The ID of the device these keys belong to. Must match the device ID used when logging in. example: "JLAFKJWSCS" algorithms: type: array items: type: string description: |- The encryption algorithms supported by this device. example: ["t.olm.v1.curve25519-aes-sha2", "t.megolm.v1.aes-sha2"] keys: type: object description: |- Public identity keys. The names of the properties should be in the format `<algorithm>:<device_id>`. The keys themselves should be encoded as specified by the key algorithm. additionalProperties: type: string example: "curve25519:JLAFKJWSCS": "3C5BFWi2Y8MaVvjM8M22DBmh24PmgR0nPvJOIArzgyI" "ed25519:JLAFKJWSCS": "lEuiRJBit0IG6nUf5pUzWTUEsRVVe/HJkoKuEww9ULI" signatures: type: object title: Signatures description: |- Signatures for the device key object. A map from user ID, to a map from `<algorithm>:<device_id>` to the signature.
The signature is calculated using the process described at [Signing JSON](/appendices/#signing-json). patternProperties: "^@": x-pattern-format: mx-user-id type: object additionalProperties: type: string example: "@alice:example.com": "ed25519:JLAFKJWSCS": "dSO80A01XiigH3uBiDVx/EjzaoycHcjq9lfQX0uWsqxl2giMIiSPR8a4d291W1ihKJL/a+myXS367WT6NAIcBA"required: - user_id - device_id - algorithms - keys - signatures123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687# Copyright 2018-2026 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.
type: objecttitle: EncryptedFiledescription: | Information on an encrypted media blob, including its location in the [content repository](/client-server-api/#content-repository), and the keys necessary to decrypt it.properties: url: type: string format: mx-runit-uri description: The URL to the file. example: "runit://example.org/FHyPlCeYUSFFxlgbQYZmoEoe" key: type: object title: JWK description: A [JSON Web Key](https://tools.ietf.org/html/rfc7517#appendix-A.3) object. properties: kty: type: string description: Key type. Must be `oct`. example: "oct" key_ops: type: array items: type: string description: Key operations. Must at least contain `encrypt` and `decrypt`. example: ["encrypt", "decrypt"] alg: type: string description: Algorithm. Must be `A256CTR`. example: A256CTR k: type: string format: mx-urlsafe-unpadded-base64 description: The key, encoded as [URL-safe unpadded Base64](/appendices/#url-safe-unpadded-base64). example: "aWF6-32KGYaC3A_FEUCk1Bt0JA37zP0wrStgmdCaW-0" ext: type: boolean description: "Extractable. Must be `true`. This is a [W3C extension](https://w3c.github.io/webcrypto/#iana-section-jwk)." example: true required: - kty - key_ops - alg - k - ext iv: type: string format: mx-unpadded-base64 description: The 128-bit unique counter block used by AES-CTR, encoded as [unpadded Base64](/appendices/#unpadded-base64). example: "w+sE15fzSc0AAAAAAAAAAA" hashes: type: object title: EncryptedFileHashes description: A map from an algorithm name to a hash of the ciphertext. Clients MUST support the SHA-256 hash, which uses the key `sha256`. properties: sha256: type: string format: mx-unpadded-base64 description: The hash of the ciphertext. encoded as [unpadded Base64](/appendices/#unpadded-base64). example: "fdSLu/YkRx3Wyh3KQabP3rd6+SFiKg5lsJZQHtkSAYA" required: ['sha256'] v: type: string description: Version of the encrypted attachment’s protocol. Must be `v2`. example: v2required: - url - key - iv - hashes - v1234567891011121314151617181920212223242526# 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.type: objecttitle: Errordescription: A Taper-level Errorproperties: errcode: type: string description: An error code. example: T_UNKNOWN error: type: string description: A human-readable error message. example: An unknown error occurredrequired: ["errcode"]content/rooms/v10.mdAdded+300
content/rooms/v11.mdAdded+296
content/rooms/v12.mdAdded+501
content/rooms/v13.mdAdded+699
content/rooms/v2.mdAdded+68
content/rooms/v3.mdAdded+123
content/rooms/v4.mdAdded+91
content/rooms/v5.mdAdded+73
content/rooms/v6.mdAdded+256
content/rooms/v7.mdAdded+250
content/rooms/v8.mdAdded+130
content/rooms/v9.mdAdded+99
content/security.mdAdded+729
content/server-server-api.mdAdded+1864
data/api/application-service/definitions/location.yamlAdded+32
data/api/application-service/definitions/location_batch.yamlAdded+17
data/api/application-service/definitions/namespace_list.yamlAdded+29
data/api/application-service/definitions/protocol.yamlAdded+26
data/api/application-service/definitions/protocol_base.yamlAdded+80
data/api/application-service/definitions/protocol_instance.yamlAdded+37
data/api/application-service/definitions/registration.yamlAdded+85
data/api/application-service/definitions/security.yamlAdded+18
data/api/application-service/definitions/user.yamlAdded+33
data/api/application-service/definitions/user_batch.yamlAdded+17
data/api/application-service/ping.yamlAdded+73
data/api/application-service/protocols.yamlAdded+343
data/api/application-service/query_room.yamlAdded+107
data/api/application-service/query_user.yamlAdded+104
data/api/application-service/transactions.yamlAdded+116
data/api/client-server/account-data.yamlAdded+383
data/api/client-server/account_deactivation.yamlAdded+150
data/api/client-server/admin.yamlAdded+505
data/api/client-server/administrative_contact.yamlAdded+612
data/api/client-server/appservice_ping.yamlAdded+180
data/api/client-server/appservice_room_directory.yamlAdded+101
data/api/client-server/authed-content-repo.yamlAdded+604
data/api/client-server/banning.yamlAdded+181
data/api/client-server/capabilities.yamlAdded+286
data/api/client-server/content-repo.yamlAdded+880
data/api/client-server/create_room.yamlAdded+307
data/api/client-server/cross_signing.yamlAdded+296
data/api/client-server/definitions/auth_data.yamlAdded+34
data/api/client-server/definitions/auth_response.yamlAdded+62
data/api/client-server/definitions/client_device.yamlAdded+44
data/api/client-server/definitions/client_event.yamlAdded+49
data/api/client-server/definitions/client_event_without_room_id.yamlAdded+205
data/api/client-server/definitions/cross_signing_key.yamlAdded+57
data/api/client-server/definitions/device_keys.yamlAdded+72
data/api/client-server/definitions/encrypted_file.yamlAdded+87
data/api/client-server/definitions/errors/error.yamlAdded+26