You identify flags by a string called the flag key. This key is unique within the account. All you have to do to create a new flag is specify the flag key using the flagId query parameter.
Create a Basic Flag
To create a flag with just a flag key:
curl -X POST "https://api.confidence.dev/v1/flags?flagId=example-flag" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json"
Use a name that is understandable and memorable. For example, new-navbar. Avoid too long names, and don’t include the configuration in the name itself. For example, don’t use new-navbar-mobile-experience or new-navbar-enabled as the flag name.
Create a Flag with Clients
You can associate the flag with clients when creating it to control which applications can resolve it:
curl -X POST "https://api.confidence.dev/v1/flags?flagId=example-flag" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"clients": ["clients/my-client"]
}'
Not all clients should have access to all flags. Associate a flag with as few clients as possible to:
- Limit the number of resolved flags in batch operations
- Reduce network payload and costs
- Prevent sensitive flags from being available in untrusted environments (like mobile apps)
Retrieve a Flag
To retrieve an existing flag and see its configuration:
curl -X GET "https://api.confidence.dev/v1/flags/example-flag" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Associate with Additional Clients
You can add more clients to a flag after creation using the addFlagClient operation:
curl -X POST "https://api.confidence.dev/v1/flags/example-flag:addFlagClient" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"client": "clients/another-client"
}'
Or update the entire list of clients using the PATCH operation:
curl -X PATCH "https://api.confidence.dev/v1/flags/example-flag?updateMask=clients" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"clients": ["clients/my-client", "clients/another-client"]
}'
Next Steps
After creating a flag:
- Define the flag schema
- Create variants
- Set up flag clients if you haven’t already
- Create segments and rules to control who sees what
- Resolve the flag in your application