Flags API examples

Use the Flags API to retrieve and create feature flags in a Cloudbees Unify application. This page provides example `curl` requests and JSON responses for the list and create endpoints. Use these examples to automate flag management in your CI/CD workflows.

Reference1 minute read

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.

All requests require a personal access token in the Authorization: Bearer header. To generate one, refer to Manage personal access tokens.

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 } }
▼