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

[@salesforce/b2c-tooling-sdk](../../modules.md) / [clients](../index.md) / tenantIdFromSandboxHostname

# Function: tenantIdFromSandboxHostname()

> **tenantIdFromSandboxHostname**(`hostname`): `string` \| `undefined`

Defined in: [packages/b2c-tooling-sdk/src/clients/custom-apis.ts:209](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/bceb8da43dd8bc63d57932bbd905d36a1b40c949/packages/b2c-tooling-sdk/src/clients/custom-apis.ts#L209)

Derives a tenant ID from a sandbox hostname.

Returns `undefined` for any hostname that doesn't follow the sandbox naming
convention, so callers never infer a tenant from an ambiguous hostname such as
a primary instance group host.

## Parameters

### hostname

`string`

Instance hostname

## Returns

`string` \| `undefined`

The tenant ID in canonical underscore format, or undefined

## Example

```ts
tenantIdFromSandboxHostname('zzpq-013.dx.commercecloud.salesforce.com') // Returns 'zzpq_013'
tenantIdFromSandboxHostname('staging-realm-customer.demandware.net')  // Returns undefined
```
