# routes.list

List routing rules.

Returns email routing rules. Filter with type=group for group listings (includes posting and member counts), type=webhook for destination webhooks and webhook taps, or type=remote for destination forwards and forward taps.

```ts
openemail.routes.list(
  options?: RoutesListOptions,
): PagePromise<RoutesListResult, Route>
```

It calls `GET /routes`: [List routing rules](/docs/api/routing/get_RouteList) in the API reference.

## Example

```ts
for await (const route of openemail.routes.list()) {
  // every item of every page (await the call instead for one page)
}
```

## Options

The last argument, `options`, a `RoutesListOptions`, takes:

| Option | Type | Sent as | Description |
| --- | --- | --- | --- |
| `domain` | `string` | query `domain` | Only routes on this domain |
| `mailboxId` | `string` | query `mailboxId` | Only routes delivering to this mailbox |
| `type` | `('mailbox' \| 'webhook' \| 'remote' \| 'group')` | query `type` | Only routes with this destination type |
| `memberOf` | `string` | query `memberOf` | Only the GROUPS this address is a member of: every group whose member list holds the address, or a +tag form of it where its domain splits tags (subaddressing), and whose membership is in effect. A system key sees every account's groups and the platform's; an account key its own account's (a domain-scoped key, those on its domains). Each row is the group as type=group presents it, in address order. Matched as written: an alias-domain spelling is its own address. Not combinable with domain, mailboxId or type, and an address is required (400 validation_failed either way). The answer echoes the normalized address as memberOf; a core that predates this filter ignores it and answers the unfiltered listing without the echo |
| `limit` | `number` | query `limit` | Page size (default 100) |
| `cursor` | `string` | query `cursor` | Opaque page cursor from a previous response |

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

It is a listing, a [`PagePromise`](/docs/sdks/typescript/listings). Awaited, it is one page as the API answers it, [`RoutesListResult`](#routeslistresult). Iterated with `for await`, it is every [`Route`](/docs/sdks/typescript/types/route) of every page, each page fetched as the loop reaches it.

## Errors

| Status | What it means |
| --- | --- |
| `400` | validation_failed |
| `401` | unauthorized: the bearer credential is missing, malformed, expired, or revoked. Carries a `WWW-Authenticate: Bearer` challenge |
| `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

### RoutesListResult

```ts
/** What `routes.list` answers. */
type RoutesListResult = {
  /** With memberOf: the address as core normalized it. A client checks it, since a core without the filter ignores the parameter */
  memberOf?: string
  /** Opaque cursor for the next page; absent on the last page */
  nextCursor?: string
  routes: Route[]
  /** With memberOf: true when a matching-candidate read exhausted its 1,000-row bound. Missing groups can fall anywhere in address order; paging alone does not prove completeness. For account keys this describes only their own in-scope active memberships */
  truncated?: boolean
}
```

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