> ## Documentation Index
> Fetch the complete documentation index at: https://docs.omni.co/llms.txt
> Use this file to discover all available pages before exploring further.

# dynamic_shared_extensions

> Dynamically extends the model based on user attribute values, enabling user-specific model customization.

<Note>
  See [Shared extension models](/modeling/develop/shared-extensions/index) for an overview of extension models.
</Note>

Advanced feature for dynamically extending the model based on [user attributes](/administration/users/attributes). Each extension maps user attribute values to model extensions, enabling user-specific model customization. This can be used for localization or other advanced use cases.

This parameter requires enabling the **Shared extensions model** feature for your Omni instance. Reach out to Omni support to have this feature enabled.

## Syntax

Each extension must use either `mappings` (explicit) or `map_pattern` (programmatic), but not both.

<CodeGroup>
  ```yaml Explicit attribute mapping theme={null}
  dynamic_shared_extensions:
    - user_attribute: <user_attribute_reference>
      mappings:
        <extension_model_name>:
          values_for_model: [<user_attribute_value>, ...]
  ```

  ```yaml Programmatic attribute mapping theme={null}
  dynamic_shared_extensions:
    - map_pattern: "<template_with_{{omni_attributes.attribute_name}}>"
  ```
</CodeGroup>

## Properties

<ParamField path="dynamic_shared_extensions" type="object[]" required>
  A list of dynamic extensions to apply to the model. Each extension must specify either `mappings` or `map_pattern`, but not both.

  <Expandable title="dynamic_shared_extensions properties" defaultOpen="true">
    <ParamField path="user_attribute" type="string">
      The reference of the user attribute that determines which extension to apply. Required when using `mappings`. Optional when using `map_pattern` — if omitted, attributes referenced in the pattern are used.
    </ParamField>

    <ParamField path="mappings" type="object">
      A map of extension model names to the user attribute values that trigger them. If a user's `user_attribute` value is included in a mapping's `values_for_model` list, the corresponding extension model (the mapping key) is applied. If no mapping matches, no extension is applied.

      <Expandable title="mappings properties" defaultOpen="true">
        <ParamField path="<extension_model_name>" type="object" required>
          A key whose name matches the name of the extension model to apply.

          <Expandable title="extension_model_name properties" defaultOpen="true">
            <ParamField path="values_for_model" type="string[]" required>
              A list of values for the referenced `user_attribute`. When the user's attribute value matches any value in this list, the extension model is applied.
            </ParamField>
          </Expandable>
        </ParamField>
      </Expandable>
    </ParamField>

    <ParamField path="map_pattern" type="string">
      A Mustache template string that generates extension model names from user attribute values. Use `{{omni_attributes.<attribute_name>}}` placeholders to reference user attributes.

      At query time, the placeholders are substituted with the current user's attribute values to produce one or more extension model names. If the generated name matches an existing extension model, it's applied; otherwise it's silently skipped.

      **Note**: User attributes can have multiple values. In this case, Omni will try all values for the attribute. Multiple matches may occur as a result.

      If the pattern references multiple attributes and the user has multiple values for one or more of them, Omni generates all combinations.
    </ParamField>
  </Expandable>
</ParamField>

## Examples

### Explicit customer extensions

In this example, users with a `customer_id` of `blobs_r_us` have the `blobs_r_us` extension model applied; users with `mega_blobs` have the `mega_blobs` extension model applied.

```yaml title="Apply per-customer extension models" theme={null}
dynamic_shared_extensions:
  - user_attribute: customer_id
    mappings:
      blobs_r_us:
        values_for_model: [blobs_r_us]
      mega_blobs:
        values_for_model: [mega_blobs]
```

### Localize model by language attribute

In this example, each extension model (`model_es`, `model_fr`, `model_de`) overrides view and field labels with translated values for that language.

```yaml title="Localize the model by language" theme={null}
dynamic_shared_extensions:
  - user_attribute: language
    mappings:
      model_es:
        values_for_model: [es, spanish]
      model_fr:
        values_for_model: [fr, french]
      model_de:
        values_for_model: [de, german]
```

Users with the `language` attribute set to `es` or `spanish` have the `model_es` extension applied, and so on. Users whose attribute value doesn't match any entry in a `values_for_model` list have no extension applied.

### Programmatic extensions by department

In this example, the user's `department` attribute value is substituted into the pattern to produce the extension model name.

```yaml title="Programmatically apply per-deparment extension models" theme={null}
dynamic_shared_extensions:
  - user_attribute: department
    map_pattern: "{{omni_attributes.department}}_extension"
```

A user with `department: marketing` has the `marketing_extension` model applied; a user with `department: sales` has `sales_extension` applied. This avoids enumerating each department explicitly, but requires extension model names to follow a set pattern.

### Create a pattern with multiple user attributes

In this example, both `department` and `region` are combined to generate the extension model name.

```yaml title="Combine multiple attributes in the pattern" theme={null}
dynamic_shared_extensions:
  - map_pattern: "{{omni_attributes.department}}_{{omni_attributes.region}}_model"
```

A user with `department: marketing` and `region: us` has the `marketing_us_model` extension applied. If a user has multiple values for either attribute, all combinations are generated and any matching extension models are applied.
