---
title: "Restore the keys of encrypted messages from the key backup of the Matrix account"
method: POST
path: "/ocs/v2.php/apps/spreed/api/{apiVersion}/matrix/account/backup"
tags: ["matrix_account"]
---

# Restore the keys of encrypted messages from the key backup of the Matrix account

`POST /ocs/v2.php/apps/spreed/api/{apiVersion}/matrix/account/backup`

## Request

- The document declares no server URL.
- Auth: one of:
  - HTTP bearer
  - HTTP basic

The recovery key (security key) unlocks the key backup. The key of the backup is kept, so keys that are missing later are looked up in it.

## Path parameters

- `apiVersion` 'v1', required

## Headers

- `OCS-APIRequest` boolean, required

## Request body

- object
  - `recoveryKey` string, required: Recovery key as shown by Matrix clients

## Response `200`

Keys restored

- object
  - `ocs` object, required
    - `meta` OCSMeta, required
      - `status` string, required
      - `statuscode` integer, required
      - `message` string
      - `totalitems` string
      - `itemsperpage` string
    - `data` object, required
      - `restored` integer, required

## Other responses

- `400`: Encryption is not available on the server or the recovery key is wrong
- `401`: Current user is not logged in
- `404`: No active linked account or no key backup
- `502`: The homeserver could not be reached

## Changes

- **2026-10-13** `85dbe8df1bb7`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/nextcloud/apis/spreed-full/changes/ocs/v2.php/apps/spreed/api/:apiVersion/matrix/account/backup/post.md)

---

[API](https://skmtc.dev/nextcloud/apis/spreed-full.md) - [All operations](https://skmtc.dev/nextcloud/apis/spreed-full/llms.txt) - [OpenAPI document](https://skmtc.dev/nextcloud/apis/spreed-full/revisions/1d24d3b8fec0?raw)
