---
title: Quickstart for Agent
slug: feature-experimentation/docs/quickstart-for-agent
docTags: 
createdAt: 2026-08-05T20:39:54.000Z
---

::embed[::embed[Watch this [4-minute video](https://www.youtube.com/watch?v=kwNVdSXMGX8&t=20s) on implementing Optimizely Agent with example microservices or follow the instructions to [Configure Optimizely Agent](docId:Wp8H75lwLpqk9b-c7MxPg) on your preferred operating system.]{url="https://www.youtube.com/watch?v=kwNVdSXMGX8&t=20s"}]{url="https://www.youtube.com/watch?v=kwNVdSXMGX8&t=20s"}

## Agent REST APIs

The Agent REST APIs are defined through [OpenAPI (formerly known as Swagger)](https://www.openapis.org) and can be found on [localhost](http://localhost:8080/openapi.yaml) or in the [developer documentation](docId\:qb3u3WT3ZvjC_yx3j3tHx).

:::hint{type="info"}
**Note**
The following examples use Python code for brevity, but can be expanded for any programming language.
:::

### Start an HTTP session

Each request made to Optimizely Agent is in the context of an Optimizely SDK key. SDK keys map API requests to a specific Optimizely Feature Experimentation [project](docId\:CJ_gRdV_YXUtXuKsUbJFH) and [environment](docId\:XEmj8NpfZYHZ_On3RATkY). 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>'})
```

To authenticate, pass your SDK key as a header named `X-Optimizely-SDK-Key` in your API calls to Optimizely Agent. You can find your SDK key in [app.optimizely.com](https://app.optimizely.com) under **Settings > Environments > SDK Key**. Remember you have a different SDK key for each environment.

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

### Get the current environment configuration

The [/config](docId\:qb3u3WT3ZvjC_yx3j3tHx) 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?keys=](docId\:WhHGW7K-ZQC1WcaEfSH8y) endpoint decides whether to enable a feature flag or flags for a given user. You can decide on multiple flags with this syntax. `/v1/decide?keys=flagA&keys=flagB`. Optimizely provides a `userId` through the request body. The API evaluates the `userId` to determine which flag rule and flag variation the user buckets into.

Rule types include the following:

- [A/B tests](docId\:raDQAUQpQJywODzUkXKhZ) – Flag variations are measured against one another.
- [Targeted delivery](docId\:TBgf8jFkx9EEfY4hxZBON) – Progressively make the flag available to the selected [audience](docId\:jN_RcpFNKYfDDqZLpoPWI).

This endpoint returns an array of [\`OptimizelyDecision objects\`](docId:9JyGU-dSPPub09f8lsl7H), which contains information about the flag and rule the user was [bucketed](docId\:eH-UMm_rOn_GdGDGLV6__) into.

```python
params = { "keys": "flagA" }
payload = {
    "userId": "test-user",
    "decideOptions": [
        "ENABLED_FLAGS_ONLY",
        "INCLUDE_REASONS"
    ],
    "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())
```

The [decide API](docId\:WhHGW7K-ZQC1WcaEfSH8y) is a POST to signal to the caller that there are side-effects. This endpoint results in a [decision event](docId\:aRWQl1CvmQlxTciHZ4kJE) 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.
