---
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
            description: |-
              The Curve25519 key of the device which initiated the session originally.
          session_id:
            type: string
            description: The ID of the session that the key is for.
        required:
          - algorithm
          - room_id
          - session_id
          - sender_key
        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
