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

# Apply Flags

> Learn how to track flag usage by applying flags.

**Apply Flags**

Learn how to track flag usage by applying flags.

Report when your application uses flags by applying them.

> [!TIP]
>
> See [Apply a Flag](/docs/reference/api/flags/resolution-reference.md#apply-a-flag) in the reference for details on why applies matter, when to apply, batching strategies, and best practices.

## Before You Begin

Before applying flags, you must:

1. [Resolve flags](/docs/reference/api/how-to-guides/flags/resolve-flags.md) to get variant values and a resolve token
2. Save the `resolveToken` from the resolve response
3. Use the flag value in your application

## Apply a Single Flag

Report that a flag was applied:

```bash theme={null}
curl -X POST "https://flags.confidence.dev/v1/flags:apply" \
  -H "Content-Type: application/json" \
  -d '{
    "clientSecret": "YOUR_CLIENT_SECRET",
    "resolveToken": "<resolve token from resolve call>",
    "flags": [
      {
        "flag": "flags/image-size",
        "appliedTime": "2023-03-06T19:45:07.436Z",
        "sentTime": "2023-03-06T19:45:08.002Z"
      }
    ]
  }'
```

## Apply Multiple Flags

Batch multiple applies together (recommended):

```bash theme={null}
curl -X POST "https://flags.confidence.dev/v1/flags:apply" \
  -H "Content-Type: application/json" \
  -d '{
    "clientSecret": "YOUR_CLIENT_SECRET",
    "resolveToken": "<resolve token>",
    "flags": [
      {
        "flag": "flags/image-size",
        "appliedTime": "2023-03-06T19:45:07.436Z",
        "sentTime": "2023-03-06T19:45:08.002Z"
      },
      {
        "flag": "flags/button-colors",
        "appliedTime": "2023-03-06T19:45:09.123Z",
        "sentTime": "2023-03-06T19:45:10.002Z"
      }
    ]
  }'
```

## Complete Workflow

Here's the full workflow from resolve to apply:

```bash theme={null}
# Step 1: Resolve flags
RESPONSE=$(curl -X POST "https://flags.confidence.dev/v1/flags:resolve" \
  -H "Content-Type: application/json" \
  -d '{
    "clientSecret": "YOUR_CLIENT_SECRET",
    "evaluationContext": {
      "user_id": "user123"
    }
  }')

# Step 2: Extract resolve token
RESOLVE_TOKEN=$(echo $RESPONSE | jq -r '.resolveToken')

# Step 3: Use flag values in your application
# (Your application code here)

# Step 4: Report that flags were applied
curl -X POST "https://flags.confidence.dev/v1/flags:apply" \
  -H "Content-Type: application/json" \
  -d "{
    \"clientSecret\": \"YOUR_CLIENT_SECRET\",
    \"resolveToken\": \"$RESOLVE_TOKEN\",
    \"flags\": [
      {
        \"flag\": \"flags/my-flag\",
        \"appliedTime\": \"$(date -u +"%Y-%m-%dT%H:%M:%S.%3NZ")\",
        \"sentTime\": \"$(date -u +"%Y-%m-%dT%H:%M:%S.%3NZ")\"
      }
    ]
  }"
```

## Next Steps

After applying flags:

1. Monitor flag applied data in your data warehouse
2. Use the data to analyze experiments
3. Review apply patterns to optimize flag usage
