> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.getunleash.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.getunleash.io/_mcp/server.

# [BETA] Evaluate a single feature flag against an Unleash context in an environment.

POST https://app.unleash-instance.example.com/api/admin/playground/features/{featureName}
Content-Type: application/json

**[BETA]** This API is in beta state, which means it may change or be removed in the future.

Use the provided `context` and `environment` to evaluate a single feature flag on this Unleash instance. The project is resolved from the flag name. Returns what the flag evaluates to, together with the input parameters that were provided.

Reference: https://docs.getunleash.io/api/evaluate-feature

## Authentication

- `Authorization` header (required) — API key needed to access this API
- `Authorization` header (bearer token, required) — API key needed to access this API, in Bearer token format

## Request

### Path parameters

- `featureName` (string, required)

### Body (application/json)

This endpoint expects a playgroundFeatureRequestSchema.

- `environment` (string, required) — The environment to evaluate the feature flag in.
- `context` (sdkContextSchema, required) — The Unleash context as modeled in client SDKs

## Response

### 200

playgroundFeatureResponseSchema

- `input` (playgroundFeatureRequestSchema, required) — The given input used to evaluate the feature.
- `feature` (playgroundFeatureSchema, required) — The evaluated feature.

## Errors

### 400 Bad Request Error

The request data does not match what we expect.

- `id` (string, optional) — The ID of the error instance
- `name` (string, optional) — The name of the error kind
- `message` (string, optional) — A description of what went wrong.

### 401 Unauthorized Error

Authorization information is missing or invalid. Provide a valid API token as the `authorization` header, e.g. `authorization:*.*.my-admin-token`.

- `id` (string, optional) — The ID of the error instance
- `name` (string, optional) — The name of the error kind
- `message` (string, optional) — A description of what went wrong.

### 404 Not Found Error

The requested resource was not found.

- `id` (string, optional) — The ID of the error instance
- `name` (string, optional) — The name of the error kind
- `message` (string, optional) — A description of what went wrong.

## Types

### sdkContextSchema

The Unleash context as modeled in client SDKs

- `appName` (string, required) — The name of the application.
- `currentTime` (string, optional) — 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.
- `properties` (map from string to string, optional) — Additional Unleash context properties
- `remoteAddress` (string, optional) — The app's IP address
- `sessionId` (string, optional) — An identifier for the current session
- `userId` (string, optional) — An identifier for the current user
- `environment` (string, optional, deprecated) — The environment the app is running in.

### playgroundFeatureRequestSchema

Data for the playground API to evaluate a single feature flag

- `environment` (string, required) — The environment to evaluate the feature flag in.
- `context` (sdkContextSchema, required) — The Unleash context as modeled in client SDKs

### playgroundFeatureSchema

A simplified feature flag model intended for the Unleash playground.

- `name` (string, required) — The feature's name.
- `projectId` (string, required) — The ID of the project that contains this feature.
- `strategies` (PlaygroundFeatureSchemaStrategies, required) — The feature's applicable strategies and cumulative results of the strategies
- `isEnabledInCurrentEnvironment` (boolean, required) — Whether the feature is active and would be evaluated in the provided environment in a normal SDK context.
- `isEnabled` (boolean, required) — 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` (PlaygroundFeatureSchemaVariant, required, nullable) — 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 thefeature's defined variants.
- `variants` (list of variantSchema, required) — The feature variants.
- `hasUnsatisfiedDependency` (boolean, optional) — Whether the feature has a parent dependency that is not satisfied

### PlaygroundFeatureSchemaStrategies

The feature's applicable strategies and cumulative results of the strategies

- `result` (PlaygroundFeatureSchemaStrategiesResult, required) — 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` (list of playgroundStrategySchema, required) — The strategies that apply to this feature.

### PlaygroundFeatureSchemaVariant

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 thefeature's defined variants.

- `name` (string, required) — The variant's name. If there is no variant or if the flag is disabled, this will be `disabled`
- `enabled` (boolean, required) — 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` (PlaygroundFeatureSchemaVariantPayload, optional) — An optional payload attached to the variant.
- `feature_enabled` (boolean, optional) — Use `featureEnabled` instead.
- `featureEnabled` (boolean, optional, deprecated) — Whether the feature is enabled or not.

### variantSchema

A variant allows for further separation of users into segments. See [our excellent documentation](https://docs.getunleash.io/concepts/feature-flag-variants#what-are-variants) for a more detailed description

- `name` (string, required) — The variants name. Is unique for this feature flag
- `weight` (double, required) — 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` (enum, optional) — 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
  - Allowed values: `variable`, `fix`
- `stickiness` (string, optional) — [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` (VariantSchemaPayload, optional) — Extra data configured for this variant
- `overrides` (list of overrideSchema, optional) — 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.

### PlaygroundFeatureSchemaStrategiesResult

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`.

- boolean
- enum
  - Allowed values: `unknown`

### playgroundStrategySchema

An evaluated feature flag strategy as used by the Playground

- `name` (string, required) — The strategy's name.
- `id` (string, required) — The strategy's id.
- `result` (PlaygroundStrategySchemaResult, required) — 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` (boolean, required, nullable) — The strategy's status. Disabled strategies are not evaluated
- `segments` (list of playgroundSegmentSchema, required) — The strategy's segments and their evaluation results.
- `constraints` (list of playgroundConstraintSchema, required) — The strategy's constraints and their evaluation results.
- `parameters` (map from string to string, required) — The strategy's constraints and their evaluation results.
- `links` (PlaygroundStrategySchemaLinks, required) — A set of links to actions you can perform on this strategy
- `title` (string, optional) — Description of the feature's purpose.

### PlaygroundFeatureSchemaVariantPayload

An optional payload attached to the variant.

- `type` (string, required) — The format of the payload.
- `value` (string, required) — The payload value stringified.

### VariantSchemaPayload

Extra data configured for this variant

- `type` (enum, required) — The type of the value. Commonly used types are string, number, json and csv.
  - Allowed values: `json`, `csv`, `string`, `number`
- `value` (string, required) — The actual value of payload

### overrideSchema

An override for deciding which variant should be assigned to a user based on the context name

- `contextName` (string, required) — The name of the context field used to determine overrides
- `values` (list of string, required) — Which values that should be overriden

### PlaygroundStrategySchemaResult

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`

- PlaygroundStrategySchemaResult0
- PlaygroundStrategySchemaResult1

### playgroundSegmentSchema

The evaluated result of a segment as used by the Playground.

- `id` (integer, required) — The segment's id.
- `name` (string, required) — The name of the segment.
- `result` (boolean, required) — Whether this was evaluated as true or false.
- `constraints` (list of playgroundConstraintSchema, required) — The list of constraints in this segment.

### playgroundConstraintSchema

A strategy constraint. For more information, refer to [the strategy constraint reference documentation](https://docs.getunleash.io/concepts/activation-strategies#constraints)

- `contextName` (string, required) — The name of the context field that this constraint should apply to.
- `operator` (enum, required) — 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).
  - Allowed values: `NOT_IN`, `IN`, `STR_ENDS_WITH`, `STR_STARTS_WITH`, `STR_CONTAINS`, `NUM_EQ`, `NUM_GT`, `NUM_GTE`, `NUM_LT`, `NUM_LTE`, `DATE_AFTER`, `DATE_BEFORE`, `SEMVER_EQ`, `SEMVER_GT`, `SEMVER_LT`, `SEMVER_GTE`, `SEMVER_LTE`, `REGEX`, `IN_CIDR`
- `result` (boolean, required) — Whether this was evaluated as true or false.
- `caseInsensitive` (boolean, optional, default: false) — Whether the operator should be case sensitive or not. Defaults to `false` (being case sensitive).
- `inverted` (boolean, optional, default: false) — Whether the result should be negated or not. If `true`, will turn a `true` result into a `false` result and vice versa.
- `values` (list of string, optional) — The context values that should be used for constraint evaluation. Use this property instead of `value` for properties that accept multiple values.
- `value` (string, optional) — The context value that should be used for constraint evaluation. Use this property instead of `values` for properties that only accept single values.

### PlaygroundStrategySchemaLinks

A set of links to actions you can perform on this strategy

- `edit` (string, required)

### PlaygroundStrategySchemaResult0

- `evaluationStatus` (enum, required) — 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.
  - Allowed values: `incomplete`, `unevaluated`
- `enabled` (PlaygroundStrategySchemaResultOneOf0Enabled, required) — 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`.

### PlaygroundStrategySchemaResult1

- `evaluationStatus` (enum, required) — Signals that this strategy was evaluated successfully.
  - Allowed values: `complete`
- `enabled` (boolean, required) — Whether this strategy evaluates to true or not.
- `variant` (PlaygroundStrategySchemaResultOneOf1Variant, optional, nullable) — 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` (list of variantSchema, optional) — The feature variants.

### PlaygroundStrategySchemaResultOneOf0Enabled

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`.

- boolean
- enum
  - Allowed values: `unknown`

### PlaygroundStrategySchemaResultOneOf1Variant

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.

- `name` (string, required) — The variant's name. If there is no variant or if the toggle is disabled, this will be `disabled`
- `enabled` (boolean, required) — 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` (PlaygroundStrategySchemaResultOneOf1VariantPayload, optional) — An optional payload attached to the variant.

### PlaygroundStrategySchemaResultOneOf1VariantPayload

An optional payload attached to the variant.

- `type` (enum, required) — The format of the payload.
  - Allowed values: `json`, `csv`, `string`, `number`
- `value` (string, required) — The payload value stringified.

## Examples

**Request**

```json
{
  "environment": "development",
  "context": {
    "appName": "My cool application."
  }
}
```

**Response**

```json
{
  "input": {
    "environment": "development",
    "context": {
      "appName": "My cool application.",
      "currentTime": "2022-07-05T12:56:41+02:00",
      "properties": {
        "customContextField": "this is one!",
        "otherCustomField": "3"
      },
      "remoteAddress": "192.168.1.1",
      "sessionId": "b65e7b23-fec0-4814-a129-0e9861ef18fc",
      "userId": "username@provider.com",
      "environment": "string"
    }
  },
  "feature": {
    "name": "my-feature",
    "projectId": "my-project",
    "strategies": {
      "result": "unknown",
      "data": [
        {
          "name": "string",
          "id": "3AECCF7E-FF82-4174-8287-8EBE06079A50",
          "result": {
            "enabled": false,
            "evaluationStatus": "incomplete"
          },
          "disabled": false,
          "segments": [
            {
              "id": 1,
              "name": "segment A",
              "result": true,
              "constraints": [
                {
                  "contextName": "appName",
                  "operator": "IN",
                  "result": true,
                  "caseInsensitive": false,
                  "inverted": false,
                  "values": [
                    "my-app",
                    "my-other-app"
                  ],
                  "value": "my-app"
                }
              ]
            }
          ],
          "constraints": [
            {
              "contextName": "appName",
              "operator": "IN",
              "result": true,
              "caseInsensitive": false,
              "inverted": false,
              "values": [
                "my-app",
                "my-other-app"
              ],
              "value": "my-app"
            }
          ],
          "parameters": {
            "myParam1": "param value"
          },
          "links": {
            "edit": "/projects/some-project/features/some-feature/strategies/edit?environmentId=some-env&strategyId= 3AECCF7E-FF82-4174-8287-8EBE06079A50"
          },
          "title": "Beta rollout"
        }
      ]
    },
    "isEnabledInCurrentEnvironment": true,
    "isEnabled": true,
    "variant": {
      "name": "green",
      "enabled": true
    },
    "variants": [
      {
        "name": "blue_group",
        "weight": 1.1,
        "weightType": "variable",
        "stickiness": "custom.context.field",
        "payload": {
          "type": "json",
          "value": "{\"color\": \"red\"}"
        },
        "overrides": [
          {
            "contextName": "userId",
            "values": [
              "red",
              "blue"
            ]
          }
        ]
      }
    ],
    "hasUnsatisfiedDependency": true
  }
}
```

**SDK Code**

```python
import requests

url = "https://app.unleash-instance.example.com/api/admin/playground/features/featureName"

payload = {
    "environment": "development",
    "context": { "appName": "My cool application." }
}
headers = {
    "Authorization": "<apiKey>",
    "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/features/featureName';
const options = {
  method: 'POST',
  headers: {Authorization: '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"environment":"development","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/features/featureName"

	payload := strings.NewReader("{\n  \"environment\": \"development\",\n  \"context\": {\n    \"appName\": \"My cool application.\"\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "<apiKey>")
	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/features/featureName")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"environment\": \"development\",\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<String> response = Unirest.post("https://app.unleash-instance.example.com/api/admin/playground/features/featureName")
  .header("Authorization", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"environment\": \"development\",\n  \"context\": {\n    \"appName\": \"My cool application.\"\n  }\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://app.unleash-instance.example.com/api/admin/playground/features/featureName', [
  'body' => '{
  "environment": "development",
  "context": {
    "appName": "My cool application."
  }
}',
  'headers' => [
    'Authorization' => '<apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://app.unleash-instance.example.com/api/admin/playground/features/featureName");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"environment\": \"development\",\n  \"context\": {\n    \"appName\": \"My cool application.\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "environment": "development",
  "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/features/featureName")! 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()
```