---
description: Commands for managing Managed Runtime projects, environments, bundles, and deployments.
---

# MRT Commands

Commands for managing Managed Runtime (MRT) projects, environments, and bundles for PWA Kit storefronts.

## Command Overview

| Topic | Commands | Description |
|-------|----------|-------------|
| `mrt org` | `list`, `b2c` | List organizations and B2C connections |
| `mrt project` | `list`, `create`, `get`, `update`, `delete` | Manage MRT projects |
| `mrt project member` | `list`, `add`, `get`, `update`, `remove` | Manage project members |
| `mrt project notification` | `list`, `create`, `get`, `update`, `delete` | Manage deployment notifications |
| `mrt env` | `list`, `create`, `get`, `update`, `delete`, `invalidate`, `b2c` | Manage environments |
| `mrt env var` | `list`, `set`, `push`, `delete` | Manage environment variables |
| `mrt env redirect` | `list`, `create`, `delete`, `clone` | Manage URL redirects |
| `mrt env access-control` | `list` | Manage access control headers |
| `mrt bundle` | `deploy`, `list`, `history`, `download` | Manage bundles and deployments |
| `mrt tail-logs` | | Tail real-time application logs |
| `mrt save-credentials` | | Save MRT credentials to ~/.mobify |
| `mrt user` | `profile`, `api-key`, `email-prefs` | Manage user settings |

## Global MRT Flags

These flags are available on all MRT commands:

| Flag | Environment Variable | Description |
|------|---------------------|-------------|
| `--api-key` | `MRT_API_KEY` | MRT API key |
| `--project`, `-p` | `MRT_PROJECT` | MRT project slug |
| `--environment`, `-e` | `MRT_ENVIRONMENT` | Target environment (e.g., staging, production). `MRT_TARGET` also supported. |

### Configuration Sources

MRT commands resolve configuration in the following order of precedence:

1. Command-line flags
2. Environment variables
3. `dw.json` file (`mrtProject`, `mrtEnvironment` fields)
4. `~/.mobify` config file (for `api_key`)

## Authentication

MRT commands use API key authentication. The API key is configured in the Managed Runtime dashboard.

### Getting an API Key

1. Log in to the [Managed Runtime dashboard](https://runtime.commercecloud.com/)
2. Navigate to **Account Settings** > **API Keys**
3. Copy your API key (or generate one if you haven't already)

### Configuration

Provide the API key via one of these methods:

1. **Save credentials** (recommended): `b2c mrt save-credentials --user you@example.com --api-key your-api-key`
2. **Command-line flag**: `--api-key your-api-key`
3. **Environment variable**: `export MRT_API_KEY=your-api-key`

For complete setup instructions, see the [Authentication Guide](/guide/authentication#managed-runtime-api-key).

---

## Organization Commands

### b2c mrt org list

List organizations you have access to.

```bash
b2c mrt org list
b2c mrt org list --json
```

### b2c mrt org b2c

Get B2C Commerce instances connected to an organization.

```bash
b2c mrt org b2c my-organization
b2c mrt org b2c my-organization --json
```

---

## Project Commands

### b2c mrt project list

List MRT projects.

```bash
b2c mrt project list
b2c mrt project list --limit 10 --offset 0
b2c mrt project list --json
```

### b2c mrt project create

Create a new MRT project.

```bash
b2c mrt project create "My Storefront" --organization my-org
b2c mrt project create "My Storefront" -o my-org --slug my-storefront
b2c mrt project create "My Storefront" -o my-org --region us-east-1
```

### b2c mrt project get

Get details of an MRT project.

```bash
b2c mrt project get my-storefront
b2c mrt project get my-storefront --json
```

### b2c mrt project update

Update an MRT project. The project slug is provided as a positional argument; at least one of `--name`, `--url`, or `--region` must be supplied.

```bash
b2c mrt project update my-storefront --name "Updated Name"
b2c mrt project update my-storefront --region us-east-1
b2c mrt project update my-storefront --url https://www.example.com
```

### b2c mrt project delete

Delete an MRT project. The project slug is provided as a positional argument.

```bash
b2c mrt project delete my-storefront
b2c mrt project delete my-storefront --force
```

---

## Project Member Commands

### b2c mrt project member list

List members of an MRT project.

```bash
b2c mrt project member list --project my-storefront
b2c mrt project member list -p my-storefront --json
```

### b2c mrt project member add

Add a member to an MRT project. The role is provided as an integer.

```bash
b2c mrt project member add user@example.com --project my-storefront --role 0
b2c mrt project member add user@example.com -p my-storefront --role 1
```

**Roles:**

| Value | Role |
|-------|------|
| `0` | Admin |
| `1` | Developer |
| `2` | Marketer |
| `3` | Read Only |

### b2c mrt project member get

Get details of a project member.

```bash
b2c mrt project member get user@example.com --project my-storefront
```

### b2c mrt project member update

Update a project member's role. See the role table under [b2c mrt project member add](#b2c-mrt-project-member-add).

```bash
b2c mrt project member update user@example.com --project my-storefront --role 3
```

### b2c mrt project member remove

Remove a member from an MRT project.

```bash
b2c mrt project member remove user@example.com --project my-storefront
b2c mrt project member remove user@example.com -p my-storefront --force
```

---

## Project Notification Commands

Configure email notifications for deployment events.

### b2c mrt project notification list

List notifications for an MRT project.

```bash
b2c mrt project notification list --project my-storefront
```

### b2c mrt project notification create

Create a deployment notification.

```bash
# Notify on deployment failures
b2c mrt project notification create -p my-storefront \
  --target staging --target production \
  --recipient ops@example.com \
  --on-failed

# Notify on all deployment events
b2c mrt project notification create -p my-storefront \
  --target production \
  --recipient team@example.com \
  --on-start --on-success --on-failed
```

### b2c mrt project notification get

Get details of a notification.

```bash
b2c mrt project notification get abc-123 --project my-storefront
```

### b2c mrt project notification update

Update a notification.

```bash
b2c mrt project notification update abc-123 -p my-storefront --on-start --no-on-failed
```

### b2c mrt project notification delete

Delete a notification.

```bash
b2c mrt project notification delete abc-123 --project my-storefront
b2c mrt project notification delete abc-123 -p my-storefront --force
```

---

## Environment Commands

### b2c mrt env list

List environments in an MRT project.

```bash
b2c mrt env list --project my-storefront
b2c mrt env list -p my-storefront --json
```

### b2c mrt env create

Create a new environment.

```bash
# Create a staging environment
b2c mrt env create staging --project my-storefront --name "Staging Environment"

# Create a production environment in a specific region
b2c mrt env create production -p my-storefront --name "Production" \
  --production --region eu-west-1

# Create with external hostname
b2c mrt env create prod -p my-storefront --name "Production" \
  --production \
  --external-hostname www.example.com \
  --external-domain example.com
```

**Flags:**
| Flag | Description |
|------|-------------|
| `--name`, `-n` | Display name (required) |
| `--region`, `-r` | AWS region for SSR |
| `--production` | Mark as production |
| `--hostname` | Hostname pattern for V8 Tag |
| `--external-hostname` | Full external hostname |
| `--external-domain` | External domain for SSR |
| `--allow-cookies` | Forward HTTP cookies |
| `--enable-source-maps` | Enable source maps |
| `--proxy` | Proxy configuration in format `path=host` (repeatable) |
| `--wait`, `-w` | Wait for the environment to be ready before returning |
| `--poll-interval` | Polling interval in seconds when using `--wait` | `10` |
| `--timeout` | Maximum time to wait in seconds when using `--wait` (`0` for no timeout) | `600` |

### b2c mrt env get

Get environment details.

```bash
b2c mrt env get --project my-storefront --environment staging
b2c mrt env get -p my-storefront -e production --json
```

### b2c mrt env update

Update an environment.

```bash
b2c mrt env update -p my-storefront -e staging --name "Updated Staging"
b2c mrt env update -p my-storefront -e production --allow-cookies
```

**Flags:**
| Flag | Description |
|------|-------------|
| `--name`, `-n` | Display name for the environment |
| `--production` | Mark as a production environment |
| `--hostname` | Hostname pattern for V8 Tag loading (use empty string to clear) |
| `--external-hostname` | Full external hostname (use empty string to clear) |
| `--external-domain` | External domain for Universal PWA SSR (use empty string to clear) |
| `--allow-cookies` | Forward HTTP cookies to origin |
| `--enable-source-maps` | Enable source map support in the environment |
| `--log-level` | Log level for the environment (`DEBUG`, `INFO`, `WARN`, `ERROR`, `TRACE`, `FATAL`) |
| `--whitelisted-ips` | IP whitelist (CIDR blocks, space-separated; use empty string to clear) |
| `--proxy` | Proxy configuration in format `path=host` (repeatable) |

### b2c mrt env delete

Delete an environment.

```bash
b2c mrt env delete staging --project my-storefront
b2c mrt env delete old-env -p my-storefront --force
```

### b2c mrt env clone

Clone an environment from an existing source environment. The new target receives the source's configuration (excluding proxies and the production flag) and is automatically deployed with the source target's current bundle (if any). Optionally clones redirects, environment variables, and B2C target info.

The source environment is the one selected by `--environment` / `-e` (or `MRT_ENVIRONMENT` / `mrtEnvironment` in `dw.json`). The positional argument is the **new** environment's slug.

```bash
# Clone the configured environment into a new slug
b2c mrt env clone staging-copy -p my-storefront -e staging

# Clone with redirects and environment variables
b2c mrt env clone qa -p my-storefront -e staging --clone-redirects --clone-env-vars

# Clone using a custom domain certificate
b2c mrt env clone qa -p my-storefront -e staging \
  --external-hostname qa.example.com --certificate-id 123 --wait
```

| Flag | Description |
|------|-------------|
| `--environment`, `-e` | Source environment slug (defaults to `mrtEnvironment` / `MRT_ENVIRONMENT`) |
| `--external-hostname` | Full external hostname (required for non-MRT-managed certificates) |
| `--external-domain` | External domain for Universal PWA SSR |
| `--certificate-id` | Certificate ID for custom domain (use `b2c mrt org cert list` to find) |
| `--clone-redirects` | Clone redirects from the source environment |
| `--clone-env-vars` | Clone environment variables from the source environment |
| `--clone-b2c-info` | Clone B2C target info from the source environment |
| `--wait`, `-w` | Wait for the new environment to reach a terminal state |

### b2c mrt env invalidate

Invalidate CDN cache for an environment. The `--pattern` flag is required and accepts a path pattern (use `/*` to invalidate everything).

```bash
# Invalidate all cached content
b2c mrt env invalidate -p my-storefront -e production --pattern "/*"

# Invalidate a specific path
b2c mrt env invalidate -p my-storefront -e production --pattern "/products/*"
```

### b2c mrt env b2c

Get or update B2C Commerce connection for an environment.

```bash
# Get current B2C configuration
b2c mrt env b2c -p my-storefront -e production

# Set B2C instance connection
b2c mrt env b2c -p my-storefront -e production --instance-id aaaa_prd

# Set B2C instance with specific sites
b2c mrt env b2c -p my-storefront -e production --instance-id aaaa_prd --sites RefArch,SiteGenesis
```

---

## Environment Variable Commands

### b2c mrt env var list

List environment variables.

```bash
b2c mrt env var list --project my-storefront --environment production
b2c mrt env var list -p my-storefront -e staging --json
```

### b2c mrt env var set

Set environment variables.

```bash
# Set a single variable
b2c mrt env var set MY_VAR=value -p my-storefront -e production

# Set multiple variables
b2c mrt env var set API_KEY=secret DEBUG=true -p my-storefront -e staging

# Set value with spaces
b2c mrt env var set "MESSAGE=hello world" -p my-storefront -e production
```

### b2c mrt env var push

Push variables from a local `.env` file to the environment. Diffs the local file against the remote state, prints a summary (added / updated / unchanged / remote-only), and prompts for confirmation before applying. Remote-only variables are **not** deleted.

| Flag | Description | Default |
|------|-------------|---------|
| `--file`, `-f` | Path to the `.env` file to push | `.env` |
| `--exclude-prefix` | Exclude variables whose keys start with this prefix (repeatable) | `MRT_` |
| `--yes`, `-y` | Skip confirmation prompt | `false` |

```bash
# Push variables from ./.env, with confirmation prompt
b2c mrt env var push -p my-storefront -e production

# Push from a custom file, skipping the confirmation prompt
b2c mrt env var push -p my-storefront -e staging --file config/.env --yes

# Exclude additional prefixes (MRT_ is always excluded by default)
b2c mrt env var push -p my-storefront -e staging --exclude-prefix INTERNAL_
```

::: tip
The `MRT_` prefix is excluded by default because those variables (`MRT_PROJECT`, `MRT_ENVIRONMENT`, `MRT_API_KEY`) configure the CLI itself rather than the environment.
:::

### b2c mrt env var delete

Delete an environment variable.

```bash
b2c mrt env var delete MY_VAR -p my-storefront -e production
```

---

## URL Redirect Commands

### b2c mrt env redirect list

List URL redirects for an environment.

```bash
b2c mrt env redirect list -p my-storefront -e production
b2c mrt env redirect list -p my-storefront -e production --limit 50
```

### b2c mrt env redirect create

Create a URL redirect.

| Flag | Description | Default |
|------|-------------|---------|
| `--from` | Source path (required) | — |
| `--to` | Destination path (required) | — |
| `--status` | HTTP status code (`301` or `302`) | `301` |
| `--forward-querystring` | Forward query string parameters | `false` |
| `--forward-wildcard` | Forward the wildcard portion of the path | `false` |

```bash
# Permanent redirect (default — 301)
b2c mrt env redirect create -p my-storefront -e production \
  --from "/old-path" --to "/new-path"

# Temporary redirect
b2c mrt env redirect create -p my-storefront -e production \
  --from "/legacy/*" --to "/modern/$1" --status 302 --forward-wildcard
```

### b2c mrt env redirect delete

Delete a URL redirect by its source path.

```bash
b2c mrt env redirect delete "/old-path" -p my-storefront -e production
b2c mrt env redirect delete "/old-path" -p my-storefront -e production --force
```

### b2c mrt env redirect clone

Clone redirects from one environment to another within the same project.

```bash
b2c mrt env redirect clone -p my-storefront --from staging --to production
b2c mrt env redirect clone -p my-storefront --from staging --to production --force
```

---

## Access Control Commands

### b2c mrt env access-control list

List access control headers for an environment.

```bash
b2c mrt env access-control list -p my-storefront -e staging
b2c mrt env access-control list -p my-storefront -e staging --json
```

---

## Bundle Commands

### b2c mrt bundle deploy

Push a local build or deploy an existing bundle.

```bash
# Push local build to project
b2c mrt bundle deploy --project my-storefront

# Push and deploy to staging
b2c mrt bundle deploy -p my-storefront -e staging

# Push with release message
b2c mrt bundle deploy -p my-storefront -e production --message "Release v1.0.0"

# Push from custom build directory
b2c mrt bundle deploy -p my-storefront --build-dir ./dist

# Deploy existing bundle by ID
b2c mrt bundle deploy 12345 -p my-storefront -e production

# Deploy and wait for completion
b2c mrt bundle deploy -p my-storefront -e staging --wait
```

**Flags:**
| Flag | Description | Default |
|------|-------------|---------|
| `--message`, `-m` | Bundle message/description | |
| `--build-dir`, `-b` | Path to build directory | `build` |
| `--ssr-only` | Server-only file patterns | `ssr.js,ssr.mjs,server/**/*` |
| `--ssr-shared` | Shared file patterns | `static/**/*,client/**/*` |
| `--node-version`, `-n` | Node.js version for SSR | `22.x` |
| `--ssr-param` | SSR parameters (key=value) | |
| `--wait`, `-w` | Wait for the deployment to complete before returning | `false` |
| `--poll-interval` | Polling interval in seconds when using `--wait` | `30` |
| `--timeout` | Maximum time to wait in seconds when using `--wait` (`0` for no timeout) | `600` |

### b2c mrt bundle list

List bundles in a project.

```bash
b2c mrt bundle list --project my-storefront
b2c mrt bundle list -p my-storefront --limit 10
b2c mrt bundle list -p my-storefront --json
```

### b2c mrt bundle history

View deployment history for an environment.

```bash
b2c mrt bundle history -p my-storefront -e production
b2c mrt bundle history -p my-storefront -e staging --limit 5
```

### b2c mrt bundle download

Download a bundle artifact.

```bash
# Download to current directory
b2c mrt bundle download 12345 -p my-storefront

# Download to specific path
b2c mrt bundle download 12345 -p my-storefront -o ./artifacts/bundle.tgz

# Get download URL only
b2c mrt bundle download 12345 -p my-storefront --url-only
```

### b2c mrt bundle delete

Delete one or more bundles. Bundles are deleted asynchronously by the server and only project admins can run this command. With more than one bundle ID the CLI uses the bulk-delete endpoint and reports any rejected bundles (e.g. bundles in use by an active deployment).

```bash
# Delete a single bundle
b2c mrt bundle delete 12345 -p my-storefront

# Delete several at once
b2c mrt bundle delete 12345 12346 12347 -p my-storefront

# Skip the confirmation prompt
b2c mrt bundle delete 12345 -p my-storefront --force
```

---

## Organization Member Commands

Organization members are distinct from project members: they hold a role at the organization level and can optionally be granted permission to view all projects and manage custom domain certificates.

### b2c mrt org member list

```bash
b2c mrt org member list --org my-org
b2c mrt org member list --org my-org --search alice
```

### b2c mrt org member add

Roles: `owner` or `member`.

```bash
b2c mrt org member add alice@example.com --org my-org --role member
b2c mrt org member add bob@example.com --org my-org --role owner --view-all-projects
```

### b2c mrt org member get

```bash
b2c mrt org member get alice@example.com --org my-org
```

### b2c mrt org member update

```bash
b2c mrt org member update alice@example.com --org my-org --view-all-projects
b2c mrt org member update alice@example.com --org my-org --no-cert-permission
```

### b2c mrt org member remove

```bash
b2c mrt org member remove alice@example.com --org my-org
```

---

## Organization Certificate Commands

Manage custom domain certificates for environments that use a non-MRT-managed hostname. Certificates are organization-scoped; reference a certificate from `env create`, `env update`, or `env clone` via `--certificate-id`.

### b2c mrt org cert list

```bash
b2c mrt org cert list --org my-org
b2c mrt org cert list --org my-org --custom-only
```

### b2c mrt org cert get

Returns the validation record (the DNS entry the customer must add to validate the certificate).

```bash
b2c mrt org cert get 123 --org my-org
```

### b2c mrt org cert create

```bash
b2c mrt org cert create shop.example.com --org my-org
```

The output includes the validation record. Add it to your DNS to complete validation.

### b2c mrt org cert delete

```bash
b2c mrt org cert delete 123 --org my-org
```

### b2c mrt org cert restart-validation

Restart validation for a certificate that has not yet been validated. The response includes a fresh validation record.

```bash
b2c mrt org cert restart-validation 123 --org my-org
```

---

## Tail Logs

### b2c mrt tail-logs

Tail application logs from a Managed Runtime environment in real time. Connects via WebSocket and streams log entries until interrupted with Ctrl+C.

```bash
# Tail all logs
b2c mrt tail-logs -p my-storefront -e staging

# Filter by log level
b2c mrt tail-logs -p my-storefront -e production --level ERROR --level WARN

# Search with regex pattern
b2c mrt tail-logs -p my-storefront -e staging --search "timeout"

# Search with OR pattern
b2c mrt tail-logs -p my-storefront -e staging --search "GET|POST"

# Output as JSON
b2c mrt tail-logs -p my-storefront -e staging --json
```

**Flags:**
| Flag | Description |
|------|-------------|
| `--level` | Filter by log level (ERROR, WARN, INFO, DEBUG, etc.). Repeatable for multiple levels. |
| `--search`, `-g` | Filter entries matching a regex pattern (case-insensitive) |
| `--no-color` | Disable colored output |

---

## Save Credentials

### b2c mrt save-credentials

Save MRT credentials (username and API key) to the `~/.mobify` file. Prompts for confirmation before overwriting an existing file.

```bash
# Save credentials
b2c mrt save-credentials --user user@example.com --api-key abc123

# Overwrite without confirmation
b2c mrt save-credentials --user user@example.com --api-key abc123 --yes

# Save to a custom credentials file
b2c mrt save-credentials --user user@example.com --api-key abc123 --credentials-file ./my-creds

# Save for a specific cloud origin (writes to ~/.mobify--<hostname>)
b2c mrt save-credentials --user user@example.com --api-key abc123 --cloud-origin https://cloud-staging.example.com
```

**Flags:**
| Flag | Description |
|------|-------------|
| `--user` | MRT username (email). Required. |
| `--api-key` | MRT API key. Required. |
| `--cloud-origin` | MRT cloud origin URL. Determines the credentials file path (e.g., `~/.mobify--<hostname>`). |
| `--credentials-file` | Explicit path to credentials file (overrides default `~/.mobify`). |
| `--yes`, `-y` | Overwrite existing credentials without confirmation. |

---

## User Commands

### b2c mrt user profile

View your MRT user profile.

```bash
b2c mrt user profile
b2c mrt user profile --json
```

### b2c mrt user api-key

Reset your MRT API key. **The current key is invalidated immediately** — running this command without `--yes` prompts for confirmation. The new key is printed once; copy it and update any saved credentials.

```bash
b2c mrt user api-key
b2c mrt user api-key --yes
b2c mrt user api-key --json
```

### b2c mrt user email-prefs

View or update email notification preferences. With no flags the command prints the current preferences; pass `--node-deprecation` to enable Node.js deprecation notifications, or `--no-node-deprecation` to disable them.

```bash
# View current preferences
b2c mrt user email-prefs

# Enable Node.js deprecation notifications
b2c mrt user email-prefs --node-deprecation

# Disable them
b2c mrt user email-prefs --no-node-deprecation
```

---

## Common Workflows

### Deploy to Production

```bash
# 1. Push and deploy to staging for testing
b2c mrt bundle deploy -p my-storefront -e staging -m "v1.0.0-rc1"

# 2. After testing, deploy to production
b2c mrt bundle deploy -p my-storefront -e production -m "v1.0.0"

# 3. Or deploy an existing bundle
b2c mrt bundle deploy 12345 -p my-storefront -e production
```

### Set Up a New Environment

```bash
# 1. Create the environment
b2c mrt env create qa -p my-storefront --name "QA Environment" --region us-east-1

# 2. Configure environment variables
b2c mrt env var set API_URL=https://api.qa.example.com -p my-storefront -e qa

# 3. Deploy a bundle
b2c mrt bundle deploy -p my-storefront -e qa
```

### Invalidate Cache After Content Update

```bash
# Invalidate a specific path pattern
b2c mrt env invalidate -p my-storefront -e production --pattern "/products/*"
```
