---
title: "Upload end-to-end encryption keys."
method: POST
path: "/_matrix/client/v3/keys/upload"
tags: ["End-to-end encryption"]
---

# Upload end-to-end encryption keys.

`POST /_matrix/client/v3/keys/upload`

## Request

- Base URL: `https://matrix.org`
- URL: `https://matrix.org/_matrix/client/v3/keys/upload`
- Auth: one of:
  - API key in query parameter `access_token`
  - HTTP bearer
- TypeScript: <https://skmtc.dev/matrix/apis/matrix-client-server-api/docs/_matrix/client/v3/keys/upload/post.ts> (a function with typed inputs; its response is checked against the schema)

Publishes end-to-end encryption keys for the device.

## Request body

- object
  - `device_keys` object: Device identity keys
    - `algorithms` string[], required: The encryption algorithms supported by this device.
    - `device_id` string, required: The ID of the device these keys belong to. Must match the device ID used when logging in.
    - `keys` object, required: 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.
    - `signatures` object, required: 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](https://spec.matrix.org/v1.19/appendices/#signing-json).
    - `user_id` string, required: The ID of the user the device belongs to. Must match the user ID used when logging in.
  - `fallback_keys` object: One-time public keys. The names of the properties should be in the format `<algorithm>:<key_id>`. The format of the key is determined by the [key algorithm](https://spec.matrix.org/v1.19/client-server-api/#key-algorithms).
  - `one_time_keys` object: One-time public keys. The names of the properties should be in the format `<algorithm>:<key_id>`. The format of the key is determined by the [key algorithm](https://spec.matrix.org/v1.19/client-server-api/#key-algorithms).

## Response `200`

The provided keys were successfully uploaded.

- object
  - `one_time_key_counts` object, required: For each key algorithm, the number of unclaimed one-time keys of that type currently held on the server for this device. If an algorithm is not listed, the count for that algorithm is to be assumed zero.

---

[API](https://skmtc.dev/matrix/apis/matrix-client-server-api.md) - [All operations](https://skmtc.dev/matrix/apis/matrix-client-server-api/llms.txt) - [OpenAPI document](https://skmtc.dev/matrix/apis/matrix-client-server-api/revisions/c7fe4072c681?raw)
