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

[@salesforce/b2c-tooling-sdk](../../modules.md) / [cli](../index.md) / MrtCommand

# Abstract Class: MrtCommand\<T\>

Defined in: [packages/b2c-tooling-sdk/src/cli/mrt-command.ts:60](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/1dedfc1ffefa01c3d5bff62c8f7e7e682a1a91cd/packages/b2c-tooling-sdk/src/cli/mrt-command.ts#L60)

Base command for Managed Runtime (MRT) operations.

MRT has two backends:
- **legacy** — the MRT Cloud API (`cloud.mobify.com`), authenticated with a
  per-user API key (`--api-key` / `~/.mobify`).
- **scapi** — the SCAPI MRT backend, authenticated with a stateless OAuth flow
  (client-credentials or JWT Bearer) via Account Manager, reusing the same
  shortCode + tenant setup as other SCAPI commands. Each supported command maps
  to its own SCAPI API (bundle history/deploy use Storefront Deployments today;
  more MRT surfaces will be added over time).

Because SCAPI MRT reuses the SCAPI auth stack, this base extends
[OAuthCommand](OAuthCommand.md) to inherit `--client-id`/`--client-secret`/`--short-code`/
`--tenant-id`/JWT flags plus `getOAuthStrategy()`, `requireTenantId()`, and
`getOrganizationId()`. The legacy API-key path is preserved via
getMrtAuth.

API key resolution order (legacy):
1. --api-key flag
2. MRT_API_KEY environment variable (SFCC_MRT_API_KEY also supported)
3. ~/.mobify config file (api_key field), or ~/.mobify--[hostname] if --cloud-origin is set

Project/environment resolution order:
1. --project (alias: --storefront) / --environment flags
2. MRT_PROJECT / MRT_ENVIRONMENT environment variables (SFCC_-prefixed, MRT_STOREFRONT / SFCC_MRT_STOREFRONT, and MRT_TARGET also supported)
3. dw.json (mrtProject / mrtEnvironment fields)

Cloud origin resolution:
1. --cloud-origin flag
2. MRT_CLOUD_ORIGIN environment variable (SFCC_MRT_CLOUD_ORIGIN also supported)
3. dw.json (mrtOrigin field)
4. Default: https://cloud.mobify.com

Backend selection:
- `--mrt-backend` flag > `MRT_BACKEND` env (`SFCC_MRT_BACKEND` also supported) > `mrtBackend` dw.json > `auto`.

## Extends

- [`OAuthCommand`](OAuthCommand.md)\<`T`\>

## Type Parameters

### T

`T` *extends* *typeof* `Command`

## Constructors

### Constructor

> **new MrtCommand**\<`T`\>(`argv`, `config`): `MrtCommand`\<`T`\>

Defined in: [packages/b2c-tooling-sdk/src/cli/oauth-command.ts:51](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/1dedfc1ffefa01c3d5bff62c8f7e7e682a1a91cd/packages/b2c-tooling-sdk/src/cli/oauth-command.ts#L51)

#### Parameters

##### argv

`string`[]

##### config

`Config`

#### Returns

`MrtCommand`\<`T`\>

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`constructor`](OAuthCommand.md#constructor)

## Properties

### argv

> **argv**: `string`[]

Defined in: node\_modules/@oclif/core/lib/command.d.ts:12

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`argv`](OAuthCommand.md#argv)

***

### config

> **config**: `Config`

Defined in: node\_modules/@oclif/core/lib/command.d.ts:13

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`config`](OAuthCommand.md#config)

***

### id

> **id**: `string` \| `undefined`

Defined in: node\_modules/@oclif/core/lib/command.d.ts:75

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`id`](OAuthCommand.md#id)

***

### parsed

> **parsed**: `boolean`

Defined in: node\_modules/@oclif/core/lib/command.d.ts:76

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`parsed`](OAuthCommand.md#parsed)

***

### aliases

> `static` **aliases**: `string`[]

Defined in: node\_modules/@oclif/core/lib/command.d.ts:16

An array of aliases for this command.

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`aliases`](OAuthCommand.md#aliases)

***

### args

> `static` **args**: `ArgInput`

Defined in: node\_modules/@oclif/core/lib/command.d.ts:18

An order-dependent object of arguments for the command

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`args`](OAuthCommand.md#args)

***

### baseFlags

> `static` **baseFlags**: `object`

Defined in: [packages/b2c-tooling-sdk/src/cli/mrt-command.ts:61](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/1dedfc1ffefa01c3d5bff62c8f7e7e682a1a91cd/packages/b2c-tooling-sdk/src/cli/mrt-command.ts#L61)

#### account-manager-host

> **account-manager-host**: `OptionFlag`\<`string`, `CustomOptions`\>

#### api-key

> **api-key**: `OptionFlag`\<`string`, `CustomOptions`\>

#### auth-methods

> **auth-methods**: `OptionFlag`\<`string`[] \| `undefined`, `CustomOptions`\>

#### auth-scope

> **auth-scope**: `OptionFlag`\<`string`[] \| `undefined`, `CustomOptions`\>

#### client-id

> **client-id**: `OptionFlag`\<`string`, `CustomOptions`\>

#### client-secret

> **client-secret**: `OptionFlag`\<`string`, `CustomOptions`\>

#### cloud-origin

> **cloud-origin**: `OptionFlag`\<`string`, `CustomOptions`\>

#### config

> **config**: `OptionFlag`\<`string` \| `undefined`, `CustomOptions`\>

#### credentials-file

> **credentials-file**: `OptionFlag`\<`string` \| `undefined`, `CustomOptions`\>

#### debug

> **debug**: `BooleanFlag`\<`boolean`\>

#### environment

> **environment**: `OptionFlag`\<`string`, `CustomOptions`\>

#### extra-body

> **extra-body**: `OptionFlag`\<`string` \| `undefined`, `CustomOptions`\>

#### extra-headers

> **extra-headers**: `OptionFlag`\<`string` \| `undefined`, `CustomOptions`\>

#### extra-query

> **extra-query**: `OptionFlag`\<`string` \| `undefined`, `CustomOptions`\>

#### instance

> **instance**: `OptionFlag`\<`string` \| `undefined`, `CustomOptions`\>

#### json

> **json**: `BooleanFlag`\<`boolean`\>

#### jsonl

> **jsonl**: `BooleanFlag`\<`boolean`\>

#### jwt-cert

> **jwt-cert**: `OptionFlag`\<`string` \| `undefined`, `CustomOptions`\>

#### jwt-key

> **jwt-key**: `OptionFlag`\<`string` \| `undefined`, `CustomOptions`\>

#### jwt-passphrase

> **jwt-passphrase**: `OptionFlag`\<`string` \| `undefined`, `CustomOptions`\>

#### lang

> **lang**: `OptionFlag`\<`string` \| `undefined`, `CustomOptions`\>

#### log-level

> **log-level**: `OptionFlag`\<`"trace"` \| `"debug"` \| `"info"` \| `"warn"` \| `"error"` \| `"silent"` \| `undefined`, `CustomOptions`\>

#### mrt-backend

> **mrt-backend**: `OptionFlag`\<`"scapi"` \| `"auto"` \| `"legacy"`, `CustomOptions`\>

#### project

> **project**: `OptionFlag`\<`string`, `CustomOptions`\>

#### project-directory

> **project-directory**: `OptionFlag`\<`string`, `CustomOptions`\>

#### short-code

> **short-code**: `OptionFlag`\<`string`, `CustomOptions`\>

#### tenant-id

> **tenant-id**: `OptionFlag`\<`string` \| `undefined`, `CustomOptions`\>

#### user-auth

> **user-auth**: `BooleanFlag`\<`boolean`\>

#### Overrides

[`OAuthCommand`](OAuthCommand.md).[`baseFlags`](OAuthCommand.md#baseflags)

***

### deprecateAliases?

> `static` `optional` **deprecateAliases**: `boolean`

Defined in: node\_modules/@oclif/core/lib/command.d.ts:23

Emit deprecation warning when a command alias is used

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`deprecateAliases`](OAuthCommand.md#deprecatealiases)

***

### deprecationOptions?

> `static` `optional` **deprecationOptions**: `Deprecation`

Defined in: node\_modules/@oclif/core/lib/command.d.ts:24

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`deprecationOptions`](OAuthCommand.md#deprecationoptions)

***

### description

> `static` **description**: `string` \| `undefined`

Defined in: node\_modules/@oclif/core/lib/command.d.ts:30

A full description of how to use the command.

If no summary, the first line of the description will be used as the summary.

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`description`](OAuthCommand.md#description)

***

### enableJsonFlag

> `static` **enableJsonFlag**: `boolean`

Defined in: node\_modules/@oclif/core/lib/command.d.ts:31

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`enableJsonFlag`](OAuthCommand.md#enablejsonflag)

***

### examples

> `static` **examples**: `Example`[]

Defined in: node\_modules/@oclif/core/lib/command.d.ts:46

An array of examples to show at the end of the command's help.

IF only a string is provided, it will try to look for a line that starts
with the cmd.bin as the example command and the rest as the description.
If found, the command will be formatted appropriately.

```
EXAMPLES:
  A description of a particular use case.

    $ <%= config.bin => command flags
```

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`examples`](OAuthCommand.md#examples)

***

### flags

> `static` **flags**: `FlagInput`

Defined in: node\_modules/@oclif/core/lib/command.d.ts:48

A hash of flags for the command

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`flags`](OAuthCommand.md#flags)

***

### hasDynamicHelp

> `static` **hasDynamicHelp**: `boolean`

Defined in: node\_modules/@oclif/core/lib/command.d.ts:49

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`hasDynamicHelp`](OAuthCommand.md#hasdynamichelp)

***

### help

> `static` **help**: `string` \| `undefined`

Defined in: node\_modules/@oclif/core/lib/command.d.ts:50

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`help`](OAuthCommand.md#help)

***

### hidden

> `static` **hidden**: `boolean`

Defined in: node\_modules/@oclif/core/lib/command.d.ts:52

Hide the command from help

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`hidden`](OAuthCommand.md#hidden)

***

### hiddenAliases

> `static` **hiddenAliases**: `string`[]

Defined in: node\_modules/@oclif/core/lib/command.d.ts:54

An array of aliases for this command that are hidden from help.

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`hiddenAliases`](OAuthCommand.md#hiddenaliases)

***

### id

> `static` **id**: `string`

Defined in: node\_modules/@oclif/core/lib/command.d.ts:56

A command ID, used mostly in error or verbose reporting.

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`id`](OAuthCommand.md#id-1)

***

### plugin

> `static` **plugin**: `Plugin` \| `undefined`

Defined in: node\_modules/@oclif/core/lib/command.d.ts:57

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`plugin`](OAuthCommand.md#plugin)

***

### pluginAlias?

> `readonly` `static` `optional` **pluginAlias**: `string`

Defined in: node\_modules/@oclif/core/lib/command.d.ts:58

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`pluginAlias`](OAuthCommand.md#pluginalias)

***

### pluginName?

> `readonly` `static` `optional` **pluginName**: `string`

Defined in: node\_modules/@oclif/core/lib/command.d.ts:59

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`pluginName`](OAuthCommand.md#pluginname)

***

### pluginType?

> `readonly` `static` `optional` **pluginType**: `string`

Defined in: node\_modules/@oclif/core/lib/command.d.ts:60

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`pluginType`](OAuthCommand.md#plugintype)

***

### state?

> `static` `optional` **state**: `string`

Defined in: node\_modules/@oclif/core/lib/command.d.ts:62

Mark the command as a given state (e.g. beta or deprecated) in help

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`state`](OAuthCommand.md#state)

***

### strict

> `static` **strict**: `boolean`

Defined in: node\_modules/@oclif/core/lib/command.d.ts:64

When set to false, allows a variable amount of arguments

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`strict`](OAuthCommand.md#strict)

***

### summary?

> `static` `optional` **summary**: `string`

Defined in: node\_modules/@oclif/core/lib/command.d.ts:69

The tweet-sized description for your class, used in a parent-commands
sub-command listing and as the header for the command help.

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`summary`](OAuthCommand.md#summary)

***

### usage

> `static` **usage**: `string` \| `string`[] \| `undefined`

Defined in: node\_modules/@oclif/core/lib/command.d.ts:73

An override string (or strings) for the default usage documentation.

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`usage`](OAuthCommand.md#usage)

## Methods

### \_run()

> **\_run**\<`R`\>(): `Promise`\<`R`\>

Defined in: [packages/b2c-tooling-sdk/src/cli/mrt-command.ts:115](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/1dedfc1ffefa01c3d5bff62c8f7e7e682a1a91cd/packages/b2c-tooling-sdk/src/cli/mrt-command.ts#L115)

Warn once if any read is served while Managed Runtime is in read-only mode.

#### Type Parameters

##### R

`R`

#### Returns

`Promise`\<`R`\>

#### Overrides

`OAuthCommand._run`

***

### baseCommandTest()

> **baseCommandTest**(): `void`

Defined in: [packages/b2c-tooling-sdk/src/cli/base-command.ts:736](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/1dedfc1ffefa01c3d5bff62c8f7e7e682a1a91cd/packages/b2c-tooling-sdk/src/cli/base-command.ts#L736)

#### Returns

`void`

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`baseCommandTest`](OAuthCommand.md#basecommandtest)

***

### error()

#### Call Signature

> **error**(`input`, `options`): `void`

Defined in: node\_modules/@oclif/core/lib/command.d.ts:90

##### Parameters

###### input

`string` | `Error`

###### options

`object` & `PrettyPrintableError`

##### Returns

`void`

##### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`error`](OAuthCommand.md#error)

#### Call Signature

> **error**(`input`, `options?`): `never`

Defined in: node\_modules/@oclif/core/lib/command.d.ts:94

##### Parameters

###### input

`string` | `Error`

###### options?

`object` & `PrettyPrintableError`

##### Returns

`never`

##### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`error`](OAuthCommand.md#error)

***

### exit()

> **exit**(`code?`): `never`

Defined in: node\_modules/@oclif/core/lib/command.d.ts:98

#### Parameters

##### code?

`number`

#### Returns

`never`

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`exit`](OAuthCommand.md#exit)

***

### init()

> **init**(): `Promise`\<`void`\>

Defined in: [packages/b2c-tooling-sdk/src/cli/mrt-command.ts:277](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/1dedfc1ffefa01c3d5bff62c8f7e7e682a1a91cd/packages/b2c-tooling-sdk/src/cli/mrt-command.ts#L277)

#### Returns

`Promise`\<`void`\>

#### Overrides

[`OAuthCommand`](OAuthCommand.md).[`init`](OAuthCommand.md#init)

***

### jsonEnabled()

> **jsonEnabled**(): `boolean`

Defined in: node\_modules/@oclif/core/lib/command.d.ts:106

Determine if the command is being run with the --json flag in a command that supports it.

#### Returns

`boolean`

true if the command supports json and the --json flag is present

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`jsonEnabled`](OAuthCommand.md#jsonenabled)

***

### log()

> **log**(`message?`, ...`args?`): `void`

Defined in: [packages/b2c-tooling-sdk/src/cli/base-command.ts:401](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/1dedfc1ffefa01c3d5bff62c8f7e7e682a1a91cd/packages/b2c-tooling-sdk/src/cli/base-command.ts#L401)

Override oclif's log() to use pino.

#### Parameters

##### message?

`string`

##### args?

...`unknown`[]

#### Returns

`void`

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`log`](OAuthCommand.md#log)

***

### logToStderr()

> **logToStderr**(`message?`, ...`args?`): `void`

Defined in: node\_modules/@oclif/core/lib/command.d.ts:109

#### Parameters

##### message?

`string`

##### args?

...`any`[]

#### Returns

`void`

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`logToStderr`](OAuthCommand.md#logtostderr)

***

### run()

> `abstract` **run**(): `Promise`\<`any`\>

Defined in: node\_modules/@oclif/core/lib/command.d.ts:114

actual command run code goes here

#### Returns

`Promise`\<`any`\>

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`run`](OAuthCommand.md#run)

***

### warn()

> **warn**(`input`): `string` \| `Error`

Defined in: [packages/b2c-tooling-sdk/src/cli/base-command.ts:410](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/1dedfc1ffefa01c3d5bff62c8f7e7e682a1a91cd/packages/b2c-tooling-sdk/src/cli/base-command.ts#L410)

Override oclif's warn() to use pino.

#### Parameters

##### input

`string` | `Error`

#### Returns

`string` \| `Error`

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`warn`](OAuthCommand.md#warn)

***

### run()

> `static` **run**\<`T`\>(`this`, `argv?`, `opts?`): `Promise`\<`ReturnType`\<`T`\[`"run"`\]\>\>

Defined in: node\_modules/@oclif/core/lib/command.d.ts:86

instantiate and run the command

#### Type Parameters

##### T

`T` *extends* `Command`

#### Parameters

##### this

(`argv`, `config`) => `T`

the command class

##### argv?

`string`[]

argv

##### opts?

`LoadOptions`

options

#### Returns

`Promise`\<`ReturnType`\<`T`\[`"run"`\]\>\>

result

#### Inherited from

[`OAuthCommand`](OAuthCommand.md).[`run`](OAuthCommand.md#run-2)
