Feature Flags Reference#

SDK parameters, API endpoints, environment variables, and external documentation.

External documentation#

GitLab Feature Flags#

Unleash (Open Source)#

Client SDKs#

Note

Use SDK v5.0 — GitLab does not yet support v6.

GitLab API endpoints#

Use these endpoints for programmatic flag management (e.g., via CI/CD):

Environment variables#

Unleash Python SDK#

Variable

Description

Default

UNLEASH_URL

Unleash API server URL

Required

UNLEASH_APP_NAME

Application identifier

Required

UNLEASH_INSTANCE_ID

Unique instance identifier

Required

UNLEASH_ENVIRONMENT

Runtime environment

development

UNLEASH_REFRESH_INTERVAL

Flag refresh interval (seconds)

15

UNLEASH_METRICS_INTERVAL

Metrics send interval (seconds)

60

UNLEASH_INACTIVE

Disable client entirely

Not set

Unleash Proxy#

Variable

Description

UNLEASH_PROXY_SECRETS

Shared secret for Unleash Proxy client

UNLEASH_URL

Project’s API URL

UNLEASH_INSTANCE_ID

Project’s Instance ID

UNLEASH_APP_NAME

Application environment name

UNLEASH_API_TOKEN

Starts the Proxy (GitLab accepts any value)

React Proxy Client#

Variable

Description

Default

REACT_APP_UNLEASH_PROXY_URL

Unleash Proxy URL

Required

REACT_APP_UNLEASH_APP_NAME

Application name

Required

REACT_APP_UNLEASH_ENVIRONMENT

Runtime environment

development

REACT_APP_UNLEASH_CLIENT_KEY

Proxy client key (if required)

Empty

REACT_APP_UNLEASH_REFRESH_INTERVAL

Refresh interval (seconds)

30

REACT_APP_UNLEASH_DISABLE_METRICS

Disable metrics

false

Python SDK reference#

Installation#

pip install UnleashClient

Initialisation#

from UnleashClient import UnleashClient

client = UnleashClient(
    url="http://gitlab.com/api/v4/feature_flags/unleash/<PROJECT_ID>",
    app_name="my-python-app",
    custom_headers={'Authorization': '<API token>'}
)

client.initialize_client()

Parameters#

Parameter

Description

url

Unleash server URL

app_name

Application identifier

custom_headers

Headers for authentication

environment

Runtime environment

instance_id

Unique instance identifier

refresh_interval

Toggle refresh timing (seconds)

metrics_interval

Metrics sending timing (seconds)

disable_metrics

Turn off metrics

disable_registration

Skip server registration

cache_directory

Local cache location

Check flag status#

# Simple check
is_enabled = client.is_enabled("my_toggle")

# With context
context = {"userId": "user@example.com"}
is_enabled = client.is_enabled("user_toggle", context)

# With fallback
is_enabled = client.is_enabled(
    "my_toggle",
    fallback_function=lambda: False
)

Get variant#

context = {'userId': '2'}
variant = client.get_variant("variant_toggle", context)

Context fields#

  • userId — User identifier

  • sessionId — Session identifier

  • remoteAddress — IP address

  • properties — Custom properties dictionary

Supported strategies#

  • Default

  • UserID

  • IP

  • Gradual Rollout

  • Flexible Rollout

React Proxy Client reference#

Warning

Use only with the Unleash Proxy, not the Unleash client directly. This protects server-side API tokens.

Installation#

npm install @unleash/proxy-client-react

Initialisation#

import { UnleashClient } from 'unleash-proxy-client';

const unleash = new UnleashClient({
  url: 'https://YOUR-PROXY/api/frontend',
  clientKey: '<your-client-side-token>',
  appName: 'my-webapp'
});

unleash.start();

Parameters#

Parameter

Description

url

Front-end API or Edge URL

clientKey

Client-side API token

appName

Application identifier

context

Initial Unleash context

refreshInterval

Toggle refresh timing (seconds)

disableRefresh

Turn off auto-refresh

metricsInterval

Metrics sending timing (seconds)

disableMetrics

Turn off metrics

storageProvider

Custom storage implementation

bootstrap

Initial toggle configuration

environment

Context environment property

React hooks#

import { useFlag, useVariant, useFlags, useUnleashContext } from '@unleash/proxy-client-react';

// Check single flag
const isEnabled = useFlag('my-flag');

// Get variant
const variant = useVariant('my-flag');

// Check multiple flags
const flags = useFlags(['flag-one', 'flag-two']);

// Update context
const updateContext = useUnleashContext();
updateContext({ userId: '123' });

Events#

unleash.on('ready', () => {
  // Client connected to API
});

unleash.on('update', () => {
  // New toggle configuration received
});

unleash.on('error', (error) => {
  // Handle error
});

Available events:

  • initialized — SDK reads local cached data

  • ready — SDK connects to Unleash API

  • update — SDK receives new toggle configuration

  • error — SDK encounters an error

  • recovered — SDK recovers from error

  • sent — SDK sends metrics

Cleanup#

unleash.stop();