# Restore a received message

POST /v1/messages/{message_id}/restore

Source: https://cherami.to/docs/api/trash/restore-message



{/* Generated from apps/web/openapi. Edit the contract, not this file. */}

`POST /v1/messages/{message_id}/restore`

Requires an [API key](https://cherami.to/docs/api#authentication): `Authorization: Bearer YOUR_CREDENTIAL`.

Brings a received message back from [Trash](https://cherami.to/docs/api/trash/list-trash). Send no request body. It returns to listings, search and its conversation, with its labels and attachments, and repeating a restore is safe.

Restoring every message of a deleted conversation brings the conversation back. After `restorable_until` the message can't be restored and the request returns `404`.

## Parameters [#parameters]

| Parameter    | Location | Required | Type   | Meaning                                  |
| ------------ | -------- | -------- | ------ | ---------------------------------------- |
| `message_id` | path     | Yes      | string | Cherami resource ID returned by the API. |

## curl example [#curl-example]

Supply `CHERAMI_API_KEY` privately.

```sh
curl --silent --show-error --include --request POST \
  "https://cherami.to/v1/messages/MESSAGE_ID/restore" \
  --header "Authorization: Bearer $CHERAMI_API_KEY"
```

## Responses [#responses]

### HTTP 200 [#http-200]

Success.

* `X-Request-ID`: Identifies this request; include it when reporting a problem.

Content type: `application/json`.

[Restored](#schema-restored)

```json
{
  "id": "11111111-1111-4111-8111-111111111111",
  "inbox_id": "11111111-1111-4111-8111-111111111111",
  "thread_id": null,
  "status": "restored",
  "message": "Example"
}
```

### HTTP 401 [#http-401]

`unauthorized`: Send a valid API key as `Authorization: Bearer <key>`. If the key stopped working, get a new one through [recovery](https://cherami.to/docs/guides/recovery).

* `X-Request-ID`: Identifies this request; include it when reporting a problem.
* `WWW-Authenticate`: `"Bearer"`

Content type: `application/json`.

[Error](#schema-error)

### HTTP 403 [#http-403]

`operation_not_allowed`: Sending, or deletion and restore, is turned off for this account; the message says which. Contact [hello@cherami.to](mailto:hello@cherami.to).

* `X-Request-ID`: Identifies this request; include it when reporting a problem.

Content type: `application/json`.

[Error](#schema-error)

### HTTP 404 [#http-404]

`not_found`: The resource does not exist or does not belong to this account. A reply or forward source must also be in the sending inbox.

* `X-Request-ID`: Identifies this request; include it when reporting a problem.

Content type: `application/json`.

[Error](#schema-error)

### HTTP 500 [#http-500]

`internal_error`: The operation failed. Retry a read; after a write the change may have happened, so recover as [retry by operation](https://cherami.to/docs/api/errors#retry-by-operation) describes.

* `X-Request-ID`: Identifies this request; include it when reporting a problem.

Content type: `application/json`.

[Error](#schema-error)

### HTTP 503 [#http-503]

`content_unavailable`: Stored content could not be read. Retry later.

* `X-Request-ID`: Identifies this request; include it when reporting a problem.

Content type: `application/json`.

[Error](#schema-error)

## Schema: Restored [#schema-restored]

restored: this request brought the message back. already\_live: it wasn't in Trash and nothing changed. thread\_id is its conversation now; null for a received message that isn't ready.

| Field       | Required | Type                             | Meaning and constraints |
| ----------- | -------- | -------------------------------- | ----------------------- |
| `id`        | Yes      | string                           | Cherami resource ID.    |
| `inbox_id`  | Yes      | string                           | Cherami resource ID.    |
| `thread_id` | Yes      | string or null                   |                         |
| `status`    | Yes      | `"restored"` or `"already_live"` |                         |
| `message`   | Yes      | string                           |                         |

## Schema: Error [#schema-error]

| Field   | Required | Type   | Meaning and constraints |
| ------- | -------- | ------ | ----------------------- |
| `error` | Yes      | object |                         |

### `error` fields [#error-fields]

| Field     | Required | Type   | Meaning and constraints                                               |
| --------- | -------- | ------ | --------------------------------------------------------------------- |
| `code`    | Yes      | string | Code to handle. Handle a code you don't recognize by its HTTP status. |
| `message` | Yes      | string | Explanation of this case; its wording can change.                     |

[Errors, limits and pagination](https://cherami.to/docs/api/errors) · [Download OpenAPI 3.1](https://cherami.to/openapi.json)
