# Delete a message

Soft-deletes a message to trash or permanently purges it. Use label to detach from a single label.

## `DELETE /api/v1/mailboxes/{mailboxId}/messages/{messageId}`

### Path parameters

- `mailboxId` (string, required) — Mailbox ULID identifier
- `messageId` (string, required) — Message ULID identifier

### Query parameters

- `label` (string) — Remove message from this specific label only
- `purge` ("true" | "false") — Set to 'true' to permanently delete message immediately instead of moving to trash

### Responses

**200** — Message deletion result

`application/json` → MessageDeleteResult

- `blobOrphaned` (boolean) — True if message blob was permanently deleted from storage
- `deleted` (boolean) — True if message was deleted
- `expunged` (boolean) — True if the message was expunged (Recently deleted tier)
- `expungedAt` (integer <int64>) — Timestamp when the message was expunged, in epoch seconds
- `purgeAfter` (integer <int64>) — Timestamp when message will be permanently purged
- `purged` (boolean) — True if message was permanently purged
- `removedFromLabel` (string) — Label name the message was removed from

**400** — validation_failed or label_purge_exclusive

`application/json` → ErrorOrValidation

**401** — unauthorized: the bearer credential is missing, malformed, expired, or revoked. Carries a `WWW-Authenticate: Bearer` challenge

`application/json` → ErrorBody

**404** — Mailbox, message, or label not found

`application/json` → ErrorBody

**409** — not_labeled — message does not have the specified label

`application/json` → ErrorBody

**503** — temporary_failure: the platform's storage could not answer just now; retry after the Retry-After window. Any operation can answer this. A write that got it may have been applied, so retry it with the same idempotency key where it takes one, or read the state back first (see Transient failures in the API description)

`application/json` → ErrorBody

### Example request

```bash
curl -X DELETE 'https://api.open.email/api/v1/mailboxes/{mailboxId}/messages/{messageId}' \
  -H 'Authorization: Bearer oek_…'
```

## TypeScript SDK

[`openemail.messages.delete`](/docs/sdks/typescript/messages/delete)

```ts
const messageDeleteResult = await openemail.messages.delete(mailboxId, messageId)
```
