# forwarding.setForwardAll

Forward all mail to a destination.

Points forward-everything at a verified destination, and resumes it if it was paused. Junk, bounce and daemon mail are never forwarded.

```ts
openemail.forwarding.setForwardAll(
  mailboxId: string,
  body: ForwardingSetForwardAllBody,
  options?: CallOptions,
): ApiPromise<Forwarding>
```

It calls `PUT /mailboxes/{mailboxId}/forwarding/all`: [Forward all mail to a destination](/docs/api/filtering/put_ForwardingAllSet) in the API reference.

## Example

```ts
const forwarding = await openemail.forwarding.setForwardAll(mailboxId, { destinationId: '…' })
```

## Arguments

| Argument | Type | Description |
| --- | --- | --- |
| `mailboxId` | `string` | Mailbox ULID identifier. The path's `{mailboxId}`. |
| `body` | [`ForwardingSetForwardAllBody`](#forwardingsetforwardallbody) | The request's body. |

## Options

It takes no options of its own. Every call also takes `signal`, `timeout`, `retry` and `headers`, which say how that one call is sent ([call options](/docs/sdks/typescript/calling-methods#call-options)).

## Answer

Awaited, it is the API's JSON, [`Forwarding`](/docs/sdks/typescript/types/forwarding). It is an [`ApiPromise`](/docs/sdks/typescript/responses): `.withResponse()` gives the same with the `Response` it came in, for its headers.

## Errors

| Status | What it means |
| --- | --- |
| `400` | validation_failed; or destination_is_self / destination_loops / destination_chain_too_long when the destination now routes back to this mailbox; or destination_not_permitted when the account's allowlist no longer permits it; or destination_fans_out when its address now resolves to something we host that reaches more than one party. All five are re-checked here because this is the write that arms the forward, and a route proved as a single mailbox may have been retargeted to a group since; or destination_unverified (carrying the address as `target`) when the destination has not proved a code, or its proof was revoked. A destination_loops found only while the forward is published (a loop closed after the check above) also carries `forwardAll`, the setting as it now stands: the refused write cleared the forward it replaced, so it reads off |
| `401` | unauthorized: the bearer credential is missing, malformed, expired, or revoked. Carries a `WWW-Authenticate: Bearer` challenge |
| `404` | Mailbox or destination not found, or not accessible to this principal |
| `409` | inbound_edge_cap — the destination already receives the most forwards an address may. Carries `forwardAll`, the setting as it now stands: the refused write cleared the forward it replaced, so it reads off |
| `413` | too_large: JSON request body exceeds 1 MiB or 500,000 values (object keys included), checked before parsing |
| `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) |

A failed call rejects with a [`RequestError`](/docs/sdks/typescript/errors): its `status`, and its `code`, the API's `error`. Decide on the code: one status covers several.

## Types

### ForwardingSetForwardAllBody

```ts
/** The body of `forwarding.setForwardAll`. */
type ForwardingSetForwardAllBody = {
  /** A verified destination to receive a copy of all mail */
  destinationId: string
}
```

It names these types of the API, each on a page of its own: [`Forwarding`](/docs/sdks/typescript/types/forwarding).
