---
editLink: false
lastUpdated: false
outline: [2, 3]
---

<!-- Generated by python/b2c-tooling-sdk/scripts/generate_api_docs.py. Do not edit. -->

# b2c_tooling_sdk.instance

B2C instance management.

Mirrors `src/instance/index.ts`. The [`B2CInstance`](/python/api/instance#b2cinstance) class represents a
connection to a specific B2C Commerce instance, combining instance configuration
with authentication to provide lazy, typed API clients (WebDAV, OCAPI).

Typically an instance is built from resolved configuration
(`resolve_config(...).create_b2c_instance()`) rather than constructed directly.

## Classes

### B2CInstance {#b2cinstance}

```python
class B2CInstance
```

Represents a connection to a B2C Commerce instance.

Provides lazy, typed API clients for WebDAV and OCAPI. Authentication is
handled automatically based on the configured credentials: WebDAV prefers
Basic auth when configured and allowed, otherwise falls back to OAuth; OCAPI
always uses OAuth.

**Fields**

| Name | Type | Description |
| --- | --- | --- |
| `webdav_hostname` | `str` | The hostname used for WebDAV operations (falls back to the main hostname). |
| `api_backend` | `ApiBackend` | Backend preference for dual-backend operations (defaults to `"auto"`). |
| `scapi_client_config` | `ScapiClientConfig \| None` | SCAPI coordinates + a scope-flexible auth strategy, or `None` if unavailable. Returns `None` unless `short_code` and `tenant_id` are configured **and** the configured OAuth flow is stateless (client-credentials or JWT Bearer). Browser user-auth and fixed-token sessions are excluded because SCAPI Admin APIs require system authentication that can request `sfcc.*` scopes per request. |
| `webdav` | `WebDavClient` | Lazy WebDAV client for file operations. |
| `ocapi` | `OcapiClient` | Lazy OCAPI Data API client (always uses OAuth). |

### B2CInstanceOptions {#b2cinstanceoptions}

```python
class B2CInstanceOptions
```

Optional runtime dependencies for a [`B2CInstance`](/python/api/instance#b2cinstance).

`oauth_strategy` lets callers reuse their own session-aware auth resolution
(PKCE refresh, implicit fallback) without eagerly starting browser auth for
Basic-only WebDAV work. It may be a strategy instance or a zero-arg factory.

**Fields**

| Name | Type | Default |
| --- | --- | --- |
| `oauth_strategy` | `AuthStrategy \| Callable[[], AuthStrategy] \| None` | `None` |

### InstanceConfig {#instanceconfig}

```python
class InstanceConfig
```

Instance configuration (hostname, code version, SCAPI coordinates, TLS).

**Fields**

| Name | Type | Default |
| --- | --- | --- |
| `hostname` | `str` |  |
| `code_version` | `str \| None` | `None` |
| `webdav_hostname` | `str \| None` | `None` |
| `tls_options` | `TlsOptions \| None` | `None` |
| `short_code` | `str \| None` | `None` |
| `tenant_id` | `str \| None` | `None` |
| `api_backend` | `ApiBackend \| None` | `None` |

### ScapiClientConfig {#scapiclientconfig}

```python
class ScapiClientConfig
```

SCAPI connection coordinates plus a scope-flexible auth strategy.

Returned by `B2CInstance.scapi_client_config` only when the instance
carries both a `short_code` and `tenant_id` and is configured with a
stateless OAuth flow (client-credentials or JWT Bearer) able to request
arbitrary `sfcc.*` scopes per request.

**Fields**

| Name | Type |
| --- | --- |
| `short_code` | `str` |
| `tenant_id` | `str` |
| `auth` | `AuthStrategy` |

## Attributes

### ApiBackend {#apibackend}

```python
ApiBackend = Literal['ocapi', 'scapi', 'auto']
```
