---
allOf:
  - $ref: core-event-schema/event.yaml

description: |-
  This event type is used to request keys for end-to-end encryption. It is sent as an
  unencrypted [to-device](/client-server-api/#send-to-device-messaging) event.
properties:
  content:
    properties:
      body:
        description: |-
          Information about the requested key. Required when `action` is
          `request`.
        properties:
          algorithm:
            type: string
            description: |-
              The encryption algorithm the requested key in this event is to be used
              with.
          room_id:
            type: string
            description: The room where the key is used.
          sender_key:
            type: string
            x-changedInMatrixVersion:
              "1.3": |-
                Previously this field was required, however given it offers no additional
                security or privacy benefit it has been deprecated. See [`m.megolm.v1.aes-sha2`](#mmegolmv1aes-sha2)
                for more information.
            description: |-
              The Curve25519 key of the device which initiated the session originally.

              **Deprecated**: This field provides no additional security or privacy benefit
              and must not be read from. It should still be included on outgoing messages
              (if the event for which keys are being requested for *also* has a `sender_key`),
              however must not be used to find the corresponding session. See [`m.megolm.v1.aes-sha2`](#mmegolmv1aes-sha2)
              for more information.
          session_id:
            type: string
            description: The ID of the session that the key is for.
        required:
          - algorithm
          - room_id
          - session_id
        type: object
        title: RequestedKeyInfo
      action:
        enum:
          - request
          - request_cancellation
        type: string
      requesting_device_id:
        description: ID of the device requesting the key.
        type: string
      request_id:
        description: |-
          A random string uniquely identifying the request for a key. If the key is
          requested multiple times, it should be reused. It should also reused in order
          to cancel a request.
        type: string
    required:
      - action
      - requesting_device_id
      - request_id
    type: object
  type:
    enum:
      - m.room_key_request
    type: string
type: object
