Resolving flags means getting the value of a flag for a given evaluation context. The evaluation context contains information about the user, device, or other contextual data that Confidence uses to determine which variant to return.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.
Before You Begin
Before resolving flags, you need:- A flag client with credentials
- Flags associated with the client
- Rules defined on your flags
Authentication
Resolve operations use client secrets for authentication, not Bearer tokens:Evaluation Context
The evaluation context specifies contextual data that Confidence uses to evaluate rules. It’s a schema-less key-value map (JSON object) containing any data needed for rule evaluation, such as:- User identifiers
- User attributes (country, age, plan level)
- Device information (OS, model, browser)
- Session data (URL, referrer, timestamp)
Batch Resolve (Recommended)
The recommended approach is to batch resolve all flags for a client. This returns values for all flags associated with the client:Resolve Specific Flags
You can limit the resolve operation to specific flags using theflags parameter:
Understand Resolve Reasons
Each resolved flag includes areason field explaining why it resolved the way it did:
| Reason | Description |
|---|---|
RESOLVE_REASON_MATCH | A rule matched and assigned a variant |
RESOLVE_REASON_NO_SEGMENT_MATCH | No rule matched the evaluation context |
RESOLVE_REASON_FLAG_ARCHIVED | The flag is archived |
RESOLVE_REASON_ERROR | An error occurred during resolution |
Test Resolve Logic
To test your resolve logic with different evaluation contexts:- Vary the context: Try different user IDs, countries, device types
- Check reasons: Look at the
reasonfield to understand why each flag resolved as it did - Verify variants: Ensure the returned variants match your expectations
- Test edge cases: Try missing fields, null values, unexpected data types
Handle No Match
When no rule matches, the flag returns withRESOLVE_REASON_NO_SEGMENT_MATCH and empty values:
- Using a default value specified in your code
- Falling back to the original behavior
- Logging the no-match event for debugging
Best Practices
- Batch resolve: Always resolve all flags in one call to minimize network overhead
- Cache locally: Cache resolved values to avoid repeated API calls
- Provide complete context: Include all relevant fields that your targeting rules might use
- Handle failures gracefully: Have fallback values if the resolve call fails
- Use consistent keys: Ensure the
targeting_key(or custom field) is stable for each user
Next Steps
After resolving flags:- Use the variant values in your application
- Apply the flags to track usage and enable experiment analysis
- Monitor resolve patterns and optimize your rules as needed

