Walkthrough guide for Gate Management with CLI
Use the Statsig CLI to manage feature gates programmatically, including listing, creating, editing, and archiving gates from your terminal or CI.
Create a new gate
Create a new empty gate with no rules using the create command on gates.
$ siggy gates create my-first-gate
# Response
{
id: 'my-first-gate',
name: 'my-first-gate',
description: '',
idType: 'userID',
lastModifierID: '..',
...
}
Update rules
Update rules by passing a rule object to the update command. This replaces the existing rules entirely.
$ siggy gates update my-first-gate '{
"rules": [
{
"name": "all employees",
"passPercentage": 100,
"conditions": [
{
"type": "email",
"operator": "str_contains_any",
"targetValue": [
"@statsig.com"
]
}
]
}
]
}'
# Response
{
id: 'my-first-gate',
name: 'my-first-gate',
...
rules: [
{
id: '729Qb4MVDs0YrIjNR5aOSm',
name: 'all employees',
passPercentage: 100,
conditions: [
{
type: 'email',
targetValue: [ '@statsig.com' ],
operator: 'str_contains_any'
}
],
}
],
...
}
Check if the gate works
When you have configured the Client API key correctly, you can invoke the gate for different users to validate that it works.
Passing no user object creates an empty user object and evaluates the gate against it.
$ siggy gates check my-first-gate
# Response
{
name: 'my-first-gate',
value: false,
rule_id: 'default',
group_name: null
}
You can also pass a user object crafted as JSON using the --user option
$ siggy gates check my-first-gate --user '{ "email": "siggy@statsig.com" }'
# Response
{
name: 'my-first-gate',
value: true,
rule_id: '729Qb4MVDs0YrIjNR5aOSm',
group_name: null
}
List all gates
$ siggy gates list
# Response
[
{
id: 'my-first-gate',
name: 'my-first-gate',
lastModifiedTime: 1718222637700,
lastModifierName: 'CONSOLE API'
},
{
id: 'from_siggy',
name: 'from_siggy',
lastModifiedTime: 1717807438090,
lastModifierName: 'CONSOLE API'
}
...
]
Delete gate
Delete a gate using the CLI. By default, a confirmation prompt requires your input.
$ siggy gates delete my-first-gate
# Response
Are you sure you want to delete gate (id: my-first-gate)? (y/n):
Use the --force option to skip the confirmation prompt.
$ siggy gates delete my-first-gate --force
# Response
Gate deleted successfully.
Was this helpful?