---
title: Evaluate Agent REST APIs
slug: feature-experimentation/docs/evaluate-rest-apis
docTags: 
createdAt: 2026-08-05T20:39:58.000Z
---

:::hint{type="info"}
**Note**
The Agent REST API documentation is defined through an OpenAPI (Swagger) spec file and is viewable in the [Agent API reference documentation](docId:70orYTjk-9148MF1hp0KK).
:::

## Start an HTTP session

Each request made into Optimizely Agent is in the context of an Optimizely SDK Key. SDK Keys map API requests to a specific Optimizely Feature Experimentation Project and Environment.

:::hint{type="info"}
**Note**
You can find your SDK key in [app.optimizely.com](https://app.optimizely.com) under **Settings > Environments > SDK Key**. Remember there are different SDK keys for each environment.
:::

You can configure a global request header by using the `requests.Session` object.

```python
import requests

s = requests.Session()
s.headers.update({'X-Optimizely-SDK-Key': 'YOUR-SDK-KEY'})
```

:::hint{type="warning"}
**Important**
You must create an HTTP session. The following examples will assume this session is being maintained.
:::

## Get current environment configuration

The [\`/v1/config\`](docId:70orYTjk-9148MF1hp0KK) endpoint returns a manifest of the current working environment.

```python
resp = s.get('http://localhost:8080/v1/config')
env = resp.json()

for key in env['featuresMap']:
    print(key)
```

## Run a feature flag rule

The [Decide endpoint](docId\:xMaNHICTvsYdQIJDZ8cg7) buckets a user into a feature flag variation (choosing between multiple enabled variations or one disabled variation) as part of a [flag rule](docId:-yq2-thNRv7-SgwCXpG90). Flag rules let you

- Deliver your flag to users that match a specific audience using targeted deliveries.
- Test multiple variations of your flag to find the best one using A/B tests.
- Use machine learning to allocate traffic to the best-performing variation dynamically using Multi-armed bandit optimizations.

To run a flag rule, use

```python
# decide 1 flag. 
params = { "keys": "my-feature-flag" }
payload = {
    "userId": "test-user",
    "userAttributes": {
        "attr1": "sample-attribute-1",
        "attr2": "sample-attribute-2"
    }
}

resp = s.post(url = 'http://localhost:8080/v1/decide', params=params, json=payload)

print(resp.json())


# multiple (bulk) feature flag decisions for specified flags.
# To decide ALL flags, simply omit keys params
payload = { "userId": "test-user" }
params = [("keys", "flag_1"), ("keys", "flag_2")]
resp2 = s.post(url = 'http://localhost:8080/v1/decide', params=params, json=payload)
print(json.dumps(resp2.json(), indent=4, sort_keys=True))
```

The [decide API](docId\:xMaNHICTvsYdQIJDZ8cg7) is a POST to signal to the caller that there are side effects. This endpoint results in a [decision event](docId\:SzVcfUMHk3IKycnEjgjbq) sent to Optimizely to analyze the A/B test results on the [Optimizely Experiment Results page](docId\:mrUblIuNVOZc1dvjWdsbw). By default, a decision is not sent if the feature flag is part of a targeted delivery.
