# Expunge deleted messages from a label

Detaches messages marked with the deleted flag from this label. Messages left with no remaining labels move to Recently deleted and can be restored until permanent purge.

## `POST /api/v1/mailboxes/{mailboxId}/labels/{label}/expunge`

### Path parameters

- `mailboxId` (string, required) — Mailbox ULID identifier
- `label` (string, required) — Label or folder name (e.g. INBOX, Archive, custom)

### Responses

**200** — Expunged message list

`application/json` → ExpungeResult

- `expunged` (ExpungedUID[], required) — List of expunged message UIDs and IDs
  - `messageId` (string, required) — Expunged message ULID
  - `uid` (integer <int64>, required) — Expunged message UID
- `messagesExpunged` (integer <int64>, required) — Total count of messages removed from this label

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

`application/json` → ErrorBody

**404** — Mailbox or label not found

`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 POST 'https://api.open.email/api/v1/mailboxes/{mailboxId}/labels/{label}/expunge' \
  -H 'Authorization: Bearer oek_…'
```

## TypeScript SDK

[`openemail.labels.expunge`](/docs/sdks/typescript/labels/expunge)

```ts
const expungeResult = await openemail.labels.expunge(mailboxId, label)
```
