# List drafts

GET /v1/inboxes/{inbox_id}/drafts

Source: https://cherami.to/docs/api/drafts/list-drafts



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

`GET /v1/inboxes/{inbox_id}/drafts`

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

Lists the inbox's drafts, newest first, filtered by `state`. Drafts don't appear in mail listings, search or conversations until sent.

## Parameters [#parameters]

| Parameter  | Location | Required | Type                                  | Meaning                                                                                                                                                                                                       |
| ---------- | -------- | -------- | ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `inbox_id` | path     | Yes      | string                                | Cherami resource ID returned by the API.                                                                                                                                                                      |
| `limit`    | query    | No       | integer                               | Results per page. `minimum`: `1` `maximum`: `100` `default`: `20`                                                                                                                                             |
| `cursor`   | query    | No       | string                                | next\_cursor from the previous page. Keep the URL, filters and order unchanged.                                                                                                                               |
| `state`    | query    | No       | `"draft"` or `"submitted"` or `"all"` | draft: unsent drafts. submitted: drafts with a send attempt. all: both, for checking whether an uncertain creation happened. Only limit, cursor and state are accepted, each at most once. `default`: `draft` |

## curl example [#curl-example]

Supply `CHERAMI_API_KEY` privately.

```sh
curl --silent --show-error --include --request GET \
  "https://cherami.to/v1/inboxes/INBOX_ID/drafts" \
  --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`.

| Field         | Required | Type                                            | Meaning and constraints |
| ------------- | -------- | ----------------------------------------------- | ----------------------- |
| `drafts`      | Yes      | array of [DraftMetadata](#schema-draftmetadata) |                         |
| `next_cursor` | Yes      | string or null                                  |                         |

```json
{
  "drafts": [],
  "next_cursor": null
}
```

### HTTP 400 [#http-400]

`invalid_limit`: Use an integer from 1 to 100.

`invalid_cursor`: Send a cursor only to the listing, filters and order that returned it, or restart from the first page.

`invalid_draft`: Correct the draft field, `source` or listing parameter the message names.

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

Content type: `application/json`.

[Error](#schema-error)

### 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 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 503 [#http-503]

`draft_unavailable`: The draft request failed. Repeat a draft send with the same draft ID: it never sends twice. Repeat a creation with its original idempotency key and payload; without a key, list drafts first. Read the draft before repeating an edit. Retry a read or a deletion.

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

Content type: `application/json`.

[Error](#schema-error)

## Schema: DraftMetadata [#schema-draftmetadata]

| Field             | Required | Type                       | Meaning and constraints                                                                                           |
| ----------------- | -------- | -------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| `id`              | Yes      | string                     | Cherami resource ID.                                                                                              |
| `inbox_id`        | Yes      | string                     | Cherami resource ID.                                                                                              |
| `state`           | Yes      | `"draft"` or `"submitted"` |                                                                                                                   |
| `subject`         | Yes      | string                     |                                                                                                                   |
| `created_at`      | Yes      | string                     | UTC timestamp with milliseconds. `format`: `date-time` `pattern`: `^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$` |
| `updated_at`      | Yes      | string                     | UTC timestamp with milliseconds. `format`: `date-time` `pattern`: `^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$` |
| `sent_message_id` | Yes      | string or null             |                                                                                                                   |

## 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)
