---
editLink: false
lastUpdated: false
---

[@salesforce/b2c-tooling-sdk](../../../modules.md) / [operations/mrt](../index.md) / runMrtWithFallback

# Function: runMrtWithFallback()

> **runMrtWithFallback**\<`T`\>(`options`, `branches`): `Promise`\<[`MrtBackendRun`](../interfaces/MrtBackendRun.md)\<`T`\>\>

Defined in: [packages/b2c-tooling-sdk/src/operations/mrt/mrt-backend.ts:152](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/1dedfc1ffefa01c3d5bff62c8f7e7e682a1a91cd/packages/b2c-tooling-sdk/src/operations/mrt/mrt-backend.ts#L152)

Resolves the backend and runs the matching branch.

- `legacy` (explicit or `auto` with no SCAPI config): runs the legacy branch.
- `scapi` (explicit): runs the SCAPI branch with **no** fallback — every
  error surfaces, including 409 Conflict.
- `auto` with a SCAPI connection: runs SCAPI optimistically; on a
  [safe](../../../clients/functions/isFallbackTrigger.md) rejection (a definite pre-execution client
  error or `invalid_scope`) it warns and retries on legacy — but only when a
  legacy target exists ([RunMrtWithFallbackOptions.canFallbackToLegacy](../interfaces/RunMrtWithFallbackOptions.md#canfallbacktolegacy)).
  With no legacy credentials, the original SCAPI error is rethrown so the user
  sees the real failure rather than a "provide an API key" message. Ambiguous
  failures (429, 5xx, network) and 409 Conflict never fall back — a mutating
  deploy must not cross backends after the request may have reached SCAPI.

## Type Parameters

### T

`T`

## Parameters

### options

[`RunMrtWithFallbackOptions`](../interfaces/RunMrtWithFallbackOptions.md)

### branches

[`MrtBackendBranches`](../interfaces/MrtBackendBranches.md)\<`T`\>

## Returns

`Promise`\<[`MrtBackendRun`](../interfaces/MrtBackendRun.md)\<`T`\>\>

the backend that served the call and its result.
