# Batch evaluate an Unleash context against a set of environments and projects. POST https://app.unleash-instance.example.com/api/admin/playground/advanced Content-Type: application/json Use the provided `context`, `environments`, and `projects` to evaluate toggles on this Unleash instance. You can use comma-separated values to provide multiple values to each context field. Returns a combinatorial list of all toggles that match the parameters and what they evaluate to. The response also contains the input parameters that were provided. Reference: https://docs.getunleash.io/api/get-advanced-playground ## OpenAPI Specification ```yaml openapi: 3.1.1 info: title: >- Batch evaluate an Unleash context against a set of environments and projects. version: endpoint_playground.getAdvancedPlayground paths: /api/admin/playground/advanced: post: operationId: get-advanced-playground summary: >- Batch evaluate an Unleash context against a set of environments and projects. description: >- Use the provided `context`, `environments`, and `projects` to evaluate toggles on this Unleash instance. You can use comma-separated values to provide multiple values to each context field. Returns a combinatorial list of all toggles that match the parameters and what they evaluate to. The response also contains the input parameters that were provided. tags: - - subpackage_playground parameters: - name: Authorization in: header description: Header authentication of the form `undefined ` required: true schema: type: string responses: '200': description: advancedPlaygroundResponseSchema content: application/json: schema: $ref: '#/components/schemas/advancedPlaygroundResponseSchema' '400': description: The request data does not match what we expect. content: {} '401': description: >- Authorization information is missing or invalid. Provide a valid API token as the `authorization` header, e.g. `authorization:*.*.my-admin-token`. content: {} requestBody: description: advancedPlaygroundRequestSchema content: application/json: schema: $ref: '#/components/schemas/advancedPlaygroundRequestSchema' components: schemas: AdvancedPlaygroundRequestSchemaProjects1: type: string enum: - value: '*' AdvancedPlaygroundRequestSchemaProjects: oneOf: - type: array items: type: string - $ref: '#/components/schemas/AdvancedPlaygroundRequestSchemaProjects1' sdkContextSchema: type: object properties: appName: type: string description: The name of the application. currentTime: type: string format: date-time description: >- A DateTime (or similar) data class instance or a string in an RFC3339-compatible format. Defaults to the current time if not set by the user. environment: type: string description: The environment the app is running in. properties: type: object additionalProperties: type: string description: Additional Unleash context properties remoteAddress: type: string description: The app's IP address sessionId: type: string description: An identifier for the current session userId: type: string description: An identifier for the current user required: - appName advancedPlaygroundRequestSchema: type: object properties: environments: type: array items: type: string description: The environments to evaluate toggles in. projects: $ref: '#/components/schemas/AdvancedPlaygroundRequestSchemaProjects' description: A list of projects to check for toggles in. context: $ref: '#/components/schemas/sdkContextSchema' required: - environments - context sdkFlatContextSchema: type: object properties: appName: type: string description: The name of the application. currentTime: type: string format: date-time description: >- A DateTime (or similar) data class instance or a string in an RFC3339-compatible format. Defaults to the current time if not set by the user. environment: type: string description: The environment the app is running in. remoteAddress: type: string description: The app's IP address sessionId: type: string description: An identifier for the current session userId: type: string description: An identifier for the current user required: - appName AdvancedPlaygroundEnvironmentFeatureSchemaStrategiesResult1: type: string enum: - value: unknown AdvancedPlaygroundEnvironmentFeatureSchemaStrategiesResult: oneOf: - type: boolean - $ref: >- #/components/schemas/AdvancedPlaygroundEnvironmentFeatureSchemaStrategiesResult1 PlaygroundStrategySchemaResultOneOf0EvaluationStatus: type: string enum: - value: incomplete - value: unevaluated PlaygroundStrategySchemaResultOneOf0Enabled1: type: string enum: - value: unknown PlaygroundStrategySchemaResultOneOf0Enabled: oneOf: - type: boolean - $ref: '#/components/schemas/PlaygroundStrategySchemaResultOneOf0Enabled1' PlaygroundStrategySchemaResult0: type: object properties: evaluationStatus: $ref: >- #/components/schemas/PlaygroundStrategySchemaResultOneOf0EvaluationStatus description: >- Signals that this strategy could not be evaluated. This is most likely because you're using a custom strategy that Unleash doesn't know about. The `unevaluated` result is also returned if the strategy is disabled. enabled: $ref: '#/components/schemas/PlaygroundStrategySchemaResultOneOf0Enabled' description: >- Whether this strategy resolves to `false` or if it might resolve to `true`. Because Unleash can't evaluate the strategy, it can't say for certain whether it will be `true`, but if you have failing constraints or segments, it _can_ determine that your strategy would be `false`. required: - evaluationStatus - enabled PlaygroundStrategySchemaResultOneOf1EvaluationStatus: type: string enum: - value: complete PlaygroundStrategySchemaResultOneOf1VariantPayloadType: type: string enum: - value: json - value: csv - value: string - value: number PlaygroundStrategySchemaResultOneOf1VariantPayload: type: object properties: type: $ref: >- #/components/schemas/PlaygroundStrategySchemaResultOneOf1VariantPayloadType description: The format of the payload. value: type: string description: The payload value stringified. required: - type - value PlaygroundStrategySchemaResultOneOf1Variant: type: object properties: name: type: string description: >- The variant's name. If there is no variant or if the toggle is disabled, this will be `disabled` enabled: type: boolean description: >- Whether the variant is enabled or not. If the feature is disabled or if it doesn't have variants, this property will be `false` payload: $ref: >- #/components/schemas/PlaygroundStrategySchemaResultOneOf1VariantPayload description: An optional payload attached to the variant. required: - name - enabled VariantSchemaWeightType: type: string enum: - value: variable - value: fix VariantSchemaPayloadType: type: string enum: - value: json - value: csv - value: string - value: number VariantSchemaPayload: type: object properties: type: $ref: '#/components/schemas/VariantSchemaPayloadType' description: >- The type of the value. Commonly used types are string, number, json and csv. value: type: string description: The actual value of payload required: - type - value overrideSchema: type: object properties: contextName: type: string description: The name of the context field used to determine overrides values: type: array items: type: string description: Which values that should be overriden required: - contextName - values variantSchema: type: object properties: name: type: string description: The variants name. Is unique for this feature flag weight: type: number format: double description: >- The weight is the likelihood of any one user getting this variant. It is a number between 0 and 1000. See the section on [variant weights](https://docs.getunleash.io/concepts/feature-flag-variants#variant-weight) for more information weightType: $ref: '#/components/schemas/VariantSchemaWeightType' description: >- Set to fix if this variant must have exactly the weight allocated to it. If the type is variable, the weight will adjust so that the total weight of all variants adds up to 1000 stickiness: type: string description: >- [Stickiness](https://docs.getunleash.io/concepts/feature-flag-variants#variant-stickiness) is how Unleash guarantees that the same user gets the same variant every time payload: $ref: '#/components/schemas/VariantSchemaPayload' description: Extra data configured for this variant overrides: type: array items: $ref: '#/components/schemas/overrideSchema' description: >- Overrides assigning specific variants to specific users. The weighting system automatically assigns users to specific groups for you, but any overrides in this list will take precedence. required: - name - weight PlaygroundStrategySchemaResult1: type: object properties: evaluationStatus: $ref: >- #/components/schemas/PlaygroundStrategySchemaResultOneOf1EvaluationStatus description: Signals that this strategy was evaluated successfully. enabled: type: boolean description: Whether this strategy evaluates to true or not. variant: oneOf: - $ref: '#/components/schemas/PlaygroundStrategySchemaResultOneOf1Variant' - type: 'null' description: >- The feature variant you receive based on the provided context or the _disabled variant_. If a feature is disabled or doesn't have any variants, you would get the _disabled variant_. Otherwise, you'll get one of the feature's defined variants. variants: type: array items: $ref: '#/components/schemas/variantSchema' description: The feature variants. required: - evaluationStatus - enabled PlaygroundStrategySchemaResult: oneOf: - $ref: '#/components/schemas/PlaygroundStrategySchemaResult0' - $ref: '#/components/schemas/PlaygroundStrategySchemaResult1' PlaygroundConstraintSchemaOperator: type: string enum: - value: NOT_IN - value: IN - value: STR_ENDS_WITH - value: STR_STARTS_WITH - value: STR_CONTAINS - value: NUM_EQ - value: NUM_GT - value: NUM_GTE - value: NUM_LT - value: NUM_LTE - value: DATE_AFTER - value: DATE_BEFORE - value: SEMVER_EQ - value: SEMVER_GT - value: SEMVER_LT playgroundConstraintSchema: type: object properties: contextName: type: string description: The name of the context field that this constraint should apply to. operator: $ref: '#/components/schemas/PlaygroundConstraintSchemaOperator' description: >- The operator to use when evaluating this constraint. For more information about the various operators, refer to [the strategy constraint operator documentation](https://docs.getunleash.io/concepts/activation-strategies#constraint-operators). caseInsensitive: type: boolean default: false description: >- Whether the operator should be case sensitive or not. Defaults to `false` (being case sensitive). inverted: type: boolean default: false description: >- Whether the result should be negated or not. If `true`, will turn a `true` result into a `false` result and vice versa. values: type: array items: type: string description: >- The context values that should be used for constraint evaluation. Use this property instead of `value` for properties that accept multiple values. value: type: string description: >- The context value that should be used for constraint evaluation. Use this property instead of `values` for properties that only accept single values. result: type: boolean description: Whether this was evaluated as true or false. required: - contextName - operator - result playgroundSegmentSchema: type: object properties: id: type: integer description: The segment's id. name: type: string description: The name of the segment. result: type: boolean description: Whether this was evaluated as true or false. constraints: type: array items: $ref: '#/components/schemas/playgroundConstraintSchema' description: The list of constraints in this segment. required: - id - name - result - constraints parametersSchema: type: object additionalProperties: type: string PlaygroundStrategySchemaLinks: type: object properties: edit: type: string required: - edit playgroundStrategySchema: type: object properties: name: type: string description: The strategy's name. title: type: string description: Description of the feature's purpose. id: type: string description: The strategy's id. result: $ref: '#/components/schemas/PlaygroundStrategySchemaResult' description: >- The strategy's evaluation result. If the strategy is a custom strategy that Unleash can't evaluate, `evaluationStatus` will be `unknown`. Otherwise, it will be `true` or `false` disabled: type: - boolean - 'null' description: The strategy's status. Disabled strategies are not evaluated segments: type: array items: $ref: '#/components/schemas/playgroundSegmentSchema' description: The strategy's segments and their evaluation results. constraints: type: array items: $ref: '#/components/schemas/playgroundConstraintSchema' description: The strategy's constraints and their evaluation results. parameters: $ref: '#/components/schemas/parametersSchema' description: The strategy's constraints and their evaluation results. links: $ref: '#/components/schemas/PlaygroundStrategySchemaLinks' description: A set of links to actions you can perform on this strategy required: - name - id - result - disabled - segments - constraints - parameters - links AdvancedPlaygroundEnvironmentFeatureSchemaStrategies: type: object properties: result: $ref: >- #/components/schemas/AdvancedPlaygroundEnvironmentFeatureSchemaStrategiesResult description: >- The cumulative results of all the feature's strategies. Can be `true`, `false`, or `unknown`. This property will only be `unknown` if one or more of the strategies can't be fully evaluated and the rest of the strategies all resolve to `false`. data: type: array items: $ref: '#/components/schemas/playgroundStrategySchema' description: The strategies that apply to this feature. required: - result - data AdvancedPlaygroundEnvironmentFeatureSchemaVariantPayload: type: object properties: type: type: string description: The format of the payload. value: type: string description: The payload value stringified. required: - type - value AdvancedPlaygroundEnvironmentFeatureSchemaVariant: type: object properties: name: type: string description: >- The variant's name. If there is no variant or if the flag is disabled, this will be `disabled` enabled: type: boolean description: >- Whether the variant is enabled or not. If the feature is disabled or if it doesn't have variants, this property will be `false` payload: $ref: >- #/components/schemas/AdvancedPlaygroundEnvironmentFeatureSchemaVariantPayload description: An optional payload attached to the variant. feature_enabled: type: boolean description: >- Whether the feature is enabled or not. If the feature is disabled, this property will be `false` required: - name - enabled advancedPlaygroundEnvironmentFeatureSchema: type: object properties: name: type: string description: The feature's name. environment: type: string description: The feature's environment. context: $ref: '#/components/schemas/sdkFlatContextSchema' description: The context to use when evaluating flags projectId: type: string description: The ID of the project that contains this feature. strategies: $ref: >- #/components/schemas/AdvancedPlaygroundEnvironmentFeatureSchemaStrategies description: >- Feature's applicable strategies and cumulative results of the strategies isEnabledInCurrentEnvironment: type: boolean description: >- Whether the feature is active and would be evaluated in the provided environment in a normal SDK context. isEnabled: type: boolean description: |- Whether this feature is enabled or not in the current environment. If a feature can't be fully evaluated (that is, `strategies.result` is `unknown`), this will be `false` to align with how client SDKs treat unresolved feature states. variant: oneOf: - $ref: >- #/components/schemas/AdvancedPlaygroundEnvironmentFeatureSchemaVariant - type: 'null' description: >- The feature variant you receive based on the provided context or the _disabled variant_. If a feature is disabled or doesn't have any variants, you would get the _disabled variant_. Otherwise, you'll get one of the feature's defined variants. variants: type: array items: $ref: '#/components/schemas/variantSchema' description: The feature variants. required: - name - environment - context - projectId - strategies - isEnabledInCurrentEnvironment - isEnabled - variant - variants advancedPlaygroundFeatureSchema: type: object properties: name: type: string description: The feature's name. projectId: type: string description: The ID of the project that contains this feature. environments: type: object additionalProperties: type: array items: $ref: '#/components/schemas/advancedPlaygroundEnvironmentFeatureSchema' description: >- The lists of features that have been evaluated grouped by environment. required: - name - projectId - environments AdvancedPlaygroundResponseSchemaWarnings: type: object properties: invalidContextProperties: type: array items: type: string description: >- A list of top-level context properties that were provided as input that are not valid due to being the wrong type. advancedPlaygroundResponseSchema: type: object properties: input: $ref: '#/components/schemas/advancedPlaygroundRequestSchema' description: The given input used to evaluate the features. features: type: array items: $ref: '#/components/schemas/advancedPlaygroundFeatureSchema' description: The list of features that have been evaluated. warnings: $ref: '#/components/schemas/AdvancedPlaygroundResponseSchemaWarnings' description: Warnings that occurred during evaluation. required: - input - features ``` ## SDK Code Examples ```python import requests url = "https://app.unleash-instance.example.com/api/admin/playground/advanced" payload = { "environments": ["development", "production"], "context": { "appName": "My cool application." } } headers = { "Authorization": "", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://app.unleash-instance.example.com/api/admin/playground/advanced'; const options = { method: 'POST', headers: {Authorization: '', 'Content-Type': 'application/json'}, body: '{"environments":["development","production"],"context":{"appName":"My cool application."}}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://app.unleash-instance.example.com/api/admin/playground/advanced" payload := strings.NewReader("{\n \"environments\": [\n \"development\",\n \"production\"\n ],\n \"context\": {\n \"appName\": \"My cool application.\"\n }\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://app.unleash-instance.example.com/api/admin/playground/advanced") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"environments\": [\n \"development\",\n \"production\"\n ],\n \"context\": {\n \"appName\": \"My cool application.\"\n }\n}" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://app.unleash-instance.example.com/api/admin/playground/advanced") .header("Authorization", "") .header("Content-Type", "application/json") .body("{\n \"environments\": [\n \"development\",\n \"production\"\n ],\n \"context\": {\n \"appName\": \"My cool application.\"\n }\n}") .asString(); ``` ```php request('POST', 'https://app.unleash-instance.example.com/api/admin/playground/advanced', [ 'body' => '{ "environments": [ "development", "production" ], "context": { "appName": "My cool application." } }', 'headers' => [ 'Authorization' => '', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://app.unleash-instance.example.com/api/admin/playground/advanced"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"environments\": [\n \"development\",\n \"production\"\n ],\n \"context\": {\n \"appName\": \"My cool application.\"\n }\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "", "Content-Type": "application/json" ] let parameters = [ "environments": ["development", "production"], "context": ["appName": "My cool application."] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://app.unleash-instance.example.com/api/admin/playground/advanced")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```