When you need to retrieve or create feature flags in an application, use these Flags API examples. They demonstrate how to call the list and create endpoints with curl
and interpret the JSON responses, so you can automate flag management in your CI/CD workflows.
Example: Retrieve all flags in an application
Request
curl -L 'https://api.cloudbees.io/v2/applications/<application_id>/flags' \ --header 'Authorization: Bearer <personal_access_token>'
Response
{ "flags": [ { "id": "flag123", "name": "exampleFlag", "flagType": "Boolean", "variants": ["true", "false"], "description": "Example flag description", "isPermanent": true } ] }
Example: Create a flag in an application
Create a new feature flag under an application. Flags are available across all environments linked to the application.
Request
curl -X POST 'https://api.cloudbees.io/v2/applications/<application_id>/flags' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer <personal_access_token>' \ --data '{ "name": "default.followingView", "flagType": "Boolean" }'
Response
{ "flag": { "id": "flag123", "name": "default.followingView", "flagType": "Boolean", "variants": ["true", "false"], "description": "A new feature flag", "isPermanent": false } }