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

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

# Function: createBundleV2()

> **createBundleV2**(`options`): `Promise`\<[`BundleV2`](../interfaces/BundleV2.md)\>

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

Creates a v2-format bundle archive from a build directory.

Produces a gzip-compressed tar archive whose entries sit directly under
`{rootDir}/` (no project-slug prefix, unlike v1), with the SSR configuration
written into the archive at `{rootDir}/{configPath}` (default
`bld/.mrt/config.json`). The returned object carries the archive bytes plus
the `rootDir`/`configPath`/`matchMode` values to send as multipart request
fields, so the builder and the request stay consistent.

The SSR configuration is resolved as follows: if the build emitted an on-disk
v2 config file at `{buildDirectory}/{configPath}`, it is used; otherwise the
project's `config.server.{ts,js}` is read and used to build the config that
goes into the bundle; explicit options override either, merged per key. When
the build already emitted the v2 config file, it is excluded from the archive
walk and replaced by the resolved config so there is exactly one copy.

## Parameters

### options

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

v2 bundle creation options

## Returns

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

v2 bundle object ready for multipart upload

## Throws

Error if the build directory doesn't exist or ssr patterns are empty

## Example

```typescript
const bundle = await createBundleV2({
  ssrOnly: ['ssr.js'],
  ssrShared: ['static/**/*'],
  buildDirectory: './build',
  message: 'Release v1.0.0'
});
```
