> ## Documentation Index
> Fetch the complete documentation index at: https://confidence.spotify.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a Flag

> Learn how to create a flag in Confidence to remotely control the behavior of your application.

export const HowToSchema = ({name, description, steps = []}) => {
  const schema = {
    "@context": "https://schema.org",
    "@type": "HowTo",
    name,
    description
  };
  if (steps.length > 0) {
    schema.step = steps.map((s, i) => ({
      "@type": "HowToStep",
      position: i + 1,
      name: typeof s === "string" ? s : s.name,
      text: typeof s === "string" ? s : s.text || s.name
    }));
  }
  return <script type="application/ld+json" dangerouslySetInnerHTML={{
    __html: JSON.stringify(schema)
  }} />;
};

<HowToSchema
  name="Create a Flag"
  description="Learn how to create a flag in Confidence to remotely control the behavior of your application."
  steps={[
"Go to Confidence and select Flags on the left sidebar",
"Click Create to open the flag creation wizard",
{
  name: "About",
  text: "Enter the Flag key that uniquely identifies your flag. This is the same ID you use in your code. You can't change the flag key after creation. Optionally add a Description to explain what the flag is for and how to use it. Select an Owner for the flag. The owner defaults to the current user.",
},
{
  name: "Type",
  text: "Select the type of flag: - Boolean: A simple on/off flag to enable or disable a feature. Selecting this option takes you through a 4-step wizard. - JSON: A flag with a schema that can store multiple values. Selecting this option takes you through a 6-step wizard with additional steps for defining the schema and creating an initial variant.",
},
{
  name: "Client applications",
  text: "Select which clients can access this flag. You can skip this step and add clients later.",
},
{
  name: "Summary",
  text: "Review your flag configuration. Click Edit next to any section to make changes. When ready, click Create to create the flag.",
},
{
  name: "Properties",
  text: "Define the schema for your flag by adding properties. Each property has a name and a type (String, Integer, Double, or Boolean). These properties define the values your flag can return.",
},
{
  name: "First variant (optional)",
  text: "Create an initial variant with values for your properties. You can modify these values later or skip this step and create variants after the flag is created.",
},
{
  name: "Client applications",
  text: "Select which clients can access this flag. You can skip this step and add clients later.",
},
{
  name: "Summary",
  text: "Review your flag configuration. Click Edit next to any section to make changes. When ready, click Create to create the flag.",
},
"Go to Confidence and select Flags on the left sidebar",
"Select the flag you want to add a client to",
{
  name: "Click the icon next to Clients on the right sidebar",
  text: "This opens the clients dialog.",
},
"Select the clients that should be able to resolve the flag",
"Click Save",
"Go to Confidence and select Flags on the left sidebar",
"Go to the flag you want to preview the code for",
"Click Code snippets on the right sidebar",
{
  name: "Select client and credential",
  text: "Select client and credential that you want to preview the code for.",
},
]}
/>

A [flag](../flags/create-flags) lets you remotely control the behavior in your application.

## Create a Flag

The flag creation wizard guides you through a series of steps. The number of steps depends on the flag type you select.

<Steps>
  <Step title="Go to Confidence and select Flags on the left sidebar" />

  <Step title="Click Create to open the flag creation wizard" />

  <Step title="About">
    Enter the **Flag key** that uniquely identifies your flag. This is the same ID you use in your code. You can't change the flag key after creation.

    Optionally add a **Description** to explain what the flag is for and how to use it.

    Select an **Owner** for the flag. The owner defaults to the current user.
  </Step>

  <Step title="Type">
    Select the type of flag:

    * **Boolean**: A simple on/off flag to enable or disable a feature. Selecting this option takes you through a 4-step wizard.
    * **JSON**: A flag with a schema that can store multiple values. Selecting this option takes you through a 6-step wizard with additional steps for defining the schema and creating an initial variant.
  </Step>
</Steps>

### Boolean Flag Steps

For Boolean flags, the wizard continues with:

<Steps>
  <Step title="Client applications">
    Select which [clients](../flags/clients) can access this flag. You can skip this step and add clients later.
  </Step>

  <Step title="Summary">
    Review your flag configuration. Click **Edit** next to any section to make changes. When ready, click **Create** to create the flag.
  </Step>
</Steps>

When you create a Boolean flag, Confidence automatically creates two variants: **enabled** and **disabled**. You can use these variants in rules to turn features on or off for different users.

### JSON Flag Steps

For JSON flags, the wizard includes additional steps to define the schema and optionally create a first variant:

<Steps>
  <Step title="Properties">
    Define the schema for your flag by adding properties. Each property has a name and a type (String, Integer, Double, or Boolean). These properties define the values your flag can return.
  </Step>

  <Step title="First variant (optional)">
    Create an initial variant with values for your properties. You can modify these values later or skip this step and create variants after the flag is created.
  </Step>

  <Step title="Client applications">
    Select which [clients](../flags/clients) can access this flag. You can skip this step and add clients later.
  </Step>

  <Step title="Summary">
    Review your flag configuration. Click **Edit** next to any section to make changes. When ready, click **Create** to create the flag.
  </Step>
</Steps>

<Tip>
  Use a flag key that is understandable and memorable. For example, `new-navbar`.
  Avoid 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 key.
</Tip>

<Tip>
  Mobile apps and websites batch resolve flags to reduce the number of requests
  made to Confidence. Associate a flag with as few clients as possible to limit
  the number of resolved flags. Doing so also reduces costs.
</Tip>

## Associate a Flag with More Clients

You can associate a flag with more clients by following these steps:

<Steps>
  <Step title="Go to Confidence and select Flags on the left sidebar" />

  <Step title="Select the flag you want to add a client to" />

  <Step title="Click the icon next to Clients on the right sidebar">
    This opens the clients dialog.
  </Step>

  <Step title="Select the clients that should be able to resolve the flag" />

  <Step title="Click Save" />
</Steps>

## View Code Snippets

To find instructions on how to use the SDKs for a particular flag, you can use
Confidence's code snippet feature.

<Steps>
  <Step title="Go to Confidence and select Flags on the left sidebar" />

  <Step title="Go to the flag you want to preview the code for" />

  <Step title="Click Code snippets on the right sidebar" />

  <Step title="Select client and credential">
    Select client and credential that you want to preview the code for.
  </Step>

  <Step title="Pick the SDK you're interested in" />
</Steps>

The code snippet shows you how to install, initialize, and resolve using
the Confidence SDK.

## Related Resources

<CardGroup cols={2}>
  <Card title="Edit Flag Schema" href="/docs/how-to-guides/edit-flag-schema">
    Define the properties and types for your flag
  </Card>

  <Card title="Create Variants" href="/docs/how-to-guides/create-flag-variant">
    Add variants with different values for your flag
  </Card>

  <Card title="Flags Reference" href="/docs/flags/introduction">
    Deep dive into flag concepts and architecture
  </Card>

  <Card title="Create Flag API" href="/docs/api/how-to-guides/flags/create-flag">
    API reference for flags
  </Card>
</CardGroup>
