> ## 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.

# required_access_grants - Composite topics

> Defines a list of access grants for the composite topic itself, in addition to its member topics' grants.

Defines a list of access grants for the composite topic, which are used to control access. These grants apply in addition to the grants on each member topic. The values of this parameter must match the name of an access grant in the model file's [`access_grants`](/modeling/models/access-grants) parameter.

Refer to the [Controlling data access guide](/modeling/develop/data-access-control) for more information and examples.

## Syntax

```yaml theme={null}
required_access_grants: [<grant_name>]

# OR condition
required_access_grants: [<grant_one>|<grant_two>]

# AND/OR conditions
required_access_grants: [<grant_one>|<grant_two>&<grant_three>]

# Opt out of the model's default_topic_required_access_grants.
# Access is controlled by the member topics' grants only.
required_access_grants: []
```

## Properties

<ParamField path="required_access_grants" type="string[]">
  An array of access grant names that control access to the composite topic. Each value must match an access grant defined in the model file. Use `|` for `OR` conditions and `&` for `AND` conditions within the same array element.
</ParamField>

## Behavior

These grants apply in addition to each member topic's grants. They can restrict access to the composite topic, but they can't grant access to member topic data a user is otherwise denied.

If omitted, the model's [`default_topic_required_access_grants`](/modeling/models/default-topic-required-access-grants) applies, even when every member topic opts out of it. Set `required_access_grants: []` to exclude the composite topic from the default.

## Examples

The examples in this section use the following model and topics. In each table, the columns are user groups, where **Both** is a user in Finance and Marketing.

```yaml title="Model file" theme={null}
access_grants:
  finance:
    user_attribute: omni_user_groups
    allowed_values: [Finance]
  marketing:
    user_attribute: omni_user_groups
    allowed_values: [Marketing]
```

`campaigns` requires the `marketing` grant. `orders` has no grants.

```yaml title="campaigns.topic" theme={null}
required_access_grants: [marketing]
```

### Restrict the composite topic

The composite topic requires `finance`.

```yaml title="orders_and_marketing.composite_topic" highlight={2} theme={null}
topics: [orders, campaigns]
required_access_grants: [finance]
```

With the `marketing` grant from `campaigns`, a user needs both `finance` and `marketing` to query it.

<table style={{ display: "table", width: "100%" }}>
  <colgroup>
    <col style={{ width: "40%" }} />

    <col style={{ width: "20%" }} />

    <col style={{ width: "20%" }} />

    <col style={{ width: "20%" }} />
  </colgroup>

  <thead>
    <tr>
      <th>Topic</th>
      <th style={{ textAlign: "center" }}>Finance</th>
      <th style={{ textAlign: "center" }}>Marketing</th>
      <th style={{ textAlign: "center" }}>Both</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td><code>orders</code></td>
      <td style={{ textAlign: "center" }}>✅</td>
      <td style={{ textAlign: "center" }}>✅</td>
      <td style={{ textAlign: "center" }}>✅</td>
    </tr>

    <tr>
      <td><code>campaigns</code></td>
      <td style={{ textAlign: "center" }}>❌</td>
      <td style={{ textAlign: "center" }}>✅</td>
      <td style={{ textAlign: "center" }}>✅</td>
    </tr>

    <tr>
      <td><strong><code>orders\_and\_marketing</code></strong></td>
      <td style={{ textAlign: "center" }}>❌</td>
      <td style={{ textAlign: "center" }}>❌</td>
      <td style={{ textAlign: "center" }}>✅</td>
    </tr>
  </tbody>
</table>

### Grant access if either condition is met

Use a pipe (`|`) to require one of several grants. The composite topic requires `finance` or `marketing`.

```yaml title="orders_and_marketing.composite_topic" highlight={2} theme={null}
topics: [orders, campaigns]
required_access_grants: [finance|marketing]
```

With the `marketing` grant from `campaigns`, a user needs `marketing` to query it.

<table style={{ display: "table", width: "100%" }}>
  <colgroup>
    <col style={{ width: "40%" }} />

    <col style={{ width: "20%" }} />

    <col style={{ width: "20%" }} />

    <col style={{ width: "20%" }} />
  </colgroup>

  <thead>
    <tr>
      <th>Topic</th>
      <th style={{ textAlign: "center" }}>Finance</th>
      <th style={{ textAlign: "center" }}>Marketing</th>
      <th style={{ textAlign: "center" }}>Both</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td><code>orders</code></td>
      <td style={{ textAlign: "center" }}>✅</td>
      <td style={{ textAlign: "center" }}>✅</td>
      <td style={{ textAlign: "center" }}>✅</td>
    </tr>

    <tr>
      <td><code>campaigns</code></td>
      <td style={{ textAlign: "center" }}>❌</td>
      <td style={{ textAlign: "center" }}>✅</td>
      <td style={{ textAlign: "center" }}>✅</td>
    </tr>

    <tr>
      <td><strong><code>orders\_and\_marketing</code></strong></td>
      <td style={{ textAlign: "center" }}>❌</td>
      <td style={{ textAlign: "center" }}>✅</td>
      <td style={{ textAlign: "center" }}>✅</td>
    </tr>
  </tbody>
</table>

### Opt out of the model default

The model default is `finance`, and both member topics opt out of it.

```yaml title="Model file" theme={null}
default_topic_required_access_grants: [finance]
```

```yaml title="orders.topic" theme={null}
required_access_grants: []
```

```yaml title="campaigns.topic" theme={null}
required_access_grants: [marketing]
```

Two composite topics use the same member topics. `orders_and_marketing` sets `required_access_grants: []`, so it requires only `marketing`.

```yaml title="orders_and_marketing.composite_topic" highlight={2} theme={null}
topics: [orders, campaigns]
required_access_grants: []
```

`campaign_performance` does not set `required_access_grants`, so the model default applies and it requires `finance` and `marketing`.

```yaml title="campaign_performance.composite_topic" theme={null}
topics: [orders, campaigns]
```

<table style={{ display: "table", width: "100%" }}>
  <colgroup>
    <col style={{ width: "40%" }} />

    <col style={{ width: "20%" }} />

    <col style={{ width: "20%" }} />

    <col style={{ width: "20%" }} />
  </colgroup>

  <thead>
    <tr>
      <th>Topic</th>
      <th style={{ textAlign: "center" }}>Finance</th>
      <th style={{ textAlign: "center" }}>Marketing</th>
      <th style={{ textAlign: "center" }}>Both</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td><code>orders</code></td>
      <td style={{ textAlign: "center" }}>✅</td>
      <td style={{ textAlign: "center" }}>✅</td>
      <td style={{ textAlign: "center" }}>✅</td>
    </tr>

    <tr>
      <td><code>campaigns</code></td>
      <td style={{ textAlign: "center" }}>❌</td>
      <td style={{ textAlign: "center" }}>✅</td>
      <td style={{ textAlign: "center" }}>✅</td>
    </tr>

    <tr>
      <td><strong><code>orders\_and\_marketing</code></strong></td>
      <td style={{ textAlign: "center" }}>❌</td>
      <td style={{ textAlign: "center" }}>✅</td>
      <td style={{ textAlign: "center" }}>✅</td>
    </tr>

    <tr>
      <td><strong><code>campaign\_performance</code></strong></td>
      <td style={{ textAlign: "center" }}>❌</td>
      <td style={{ textAlign: "center" }}>❌</td>
      <td style={{ textAlign: "center" }}>✅</td>
    </tr>
  </tbody>
</table>
