Skip to main content
After creating a flag, define its schema to specify what fields the flag value can contain.

Define the Schema

Set the schema on your flag:
curl -X PATCH "https://api.confidence.dev/v1/flags/example-flag?updateMask=schema" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "schema": {
      "schema": {
        "enabled": {
          "boolSchema": {}
        },
        "color": {
          "stringSchema": {}
        },
        "size": {
          "intSchema": {}
        }
      }
    }
  }'
Available schema types: boolSchema, stringSchema, intSchema, doubleSchema, listSchema, structSchema. See Variants for details on how schemas work.

Add Fields to an Existing Schema

To add new fields, include them in the schema:
curl -X PATCH "https://api.confidence.dev/v1/flags/example-flag?updateMask=schema" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "schema": {
      "schema": {
        "enabled": {
          "boolSchema": {}
        },
        "color": {
          "stringSchema": {}
        },
        "size": {
          "intSchema": {}
        },
        "opacity": {
          "doubleSchema": {}
        }
      }
    }
  }'

Define a Nested Schema

Use structSchema for nested fields:
curl -X PATCH "https://api.confidence.dev/v1/flags/example-flag?updateMask=schema" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "schema": {
      "schema": {
        "button": {
          "structSchema": {
            "schema": {
              "color": {
                "stringSchema": {}
              },
              "size": {
                "intSchema": {}
              }
            }
          }
        }
      }
    }
  }'

Define a List Schema

Use listSchema for array fields:
curl -X PATCH "https://api.confidence.dev/v1/flags/example-flag?updateMask=schema" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "schema": {
      "schema": {
        "colors": {
          "listSchema": {
            "elementSchema": {
              "stringSchema": {}
            }
          }
        }
      }
    }
  }'

Remove a Field

To remove a field, first update all variants to remove that field, then update the schema:
curl -X PATCH "https://api.confidence.dev/v1/flags/example-flag?updateMask=schema" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "schema": {
      "schema": {
        "enabled": {
          "boolSchema": {}
        },
        "color": {
          "stringSchema": {}
        }
      }
    }
  }'
The request will fail if any variant still uses the field you’re trying to remove.

Next Steps

After defining your schema:
  1. Create variants with values matching the schema
  2. Create segments to target audiences
  3. Create rules to assign variants