> For the complete documentation index, see [llms.txt](https://docs.optibase.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.optibase.io/integrations/custom-integrations/active-variants-api.md).

# Active Variants API

If you wish to determine programmatically what variant Optibase has shown to the user, you can use the following global variable and function exposed by the Optibase Custom Script.

## window\.optibaseActiveVariants

Optibase Custom Script sets a global variable `window.optibaseActiveVariants` when all the tests have been loaded, and the variants have been chosen and displayed.

The variable is an array of active variants with a type of:

```typescript
type ActiveVariants = {
    userFriendlyTestId: string
    userFriendlyVariantId: string
}[]
```

The variable will only be set once the variants have been chosen and displayed. Before, the variable will be `undefined`.

*Note: Only Variants for Active and non-restricted Tests will be included. If the Main Variant is shown by default for a Test because the Test it is restricted or inactive, it will not be included in the* optibaseActiveVariants.

## window\.optibaseAddActiveVariantsListener

Optibase Custom Script sets a global function `window.optibaseAddActiveVariantsListener` that accepts a callback that will be triggered once the `window.optibaseActiveVariants` have been set.

The function is of type:

```typescript
type OptibaseAddActiveVariantsListener = (
  callback: (optibaseActiveVariants: ShownVariant[]) => void
) => void
```

You can use this to set a listener that will be triggered once the optibaseActiveVariants have been set.
