# evaluate

URL: /business/nouns/flag/evaluate · Id: `verb:Flag.evaluate` · Call: `await $.Flag.evaluate({ … })` (SDK) or the `do` tool at `https://api.sb/mcp`. Inputs says what to pass, Outputs what returns, When it waits who approves.

> Evaluate returns the Variant a Flag assigns one unit, the same one every time, and records the Exposure with every option and its propensity.

Evaluate returns the [Variant](/business/nouns/variant) a [Flag](/business/nouns/flag) assigns one unit, the same one every time, and records the [Exposure](/business/nouns/exposure) with every option and its propensity.

## Inputs
| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `flag` | [Flag](/business/nouns/flag) | Yes | The Flag to evaluate, by key. |
| `unit` | `string` | Yes | The id of the Visitor, Customer, Contact, Conversation or request being assigned. |
| `default` | `string` | No | The Variant key returned when the Flag is off or the value may not be varied. |

## Outputs
| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `variant` | [Variant](/business/nouns/variant) | Yes | The Variant assigned to the unit. |
| `exposure` | [Exposure](/business/nouns/exposure) | No | The Exposure recorded; none in Mode try. |

## Effects
- Emits [`Flag.evaluated`](/business/events/Flag.evaluated).
- Records no Exposure in Mode try, so a preview never counts toward a Readout.
- Returns the default, and records why, when the value is on the never-randomized list.

## Refuses when
| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | [Flag.evaluate](/business/nouns/flag/evaluate) |

## When it waits
| Gate | Default |
| --- | --- |
| Decision class | Low: two-way, nothing at stake |
| [Delay window](/systems/trust-and-governance/controls/one-way-windows) | None: it runs once review passes. |
| Limit | The call [Limit](/business/nouns/limit) of the [Permission](/business/nouns/permission) it runs under. |
| Over the Limit | It waits `pending` for an [Approval](/business/nouns/approval) from the [Founder](/agents/founding/founder). Approved, it runs; refused, it ends `refused` with [`limit-exceeded`](/code/api/errors/limit-exceeded); unanswered by its deadline, it ends `canceled`. |

## Example

**Ask**

```text
Evaluate the latest flag.
```

**API**

```bash
curl -X POST https://api.sb/routewise.dev/flags/flag_1/evaluate \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"unit":"Example unit"}'
```

```json
{
  "api": "https://api.sb/routewise.dev",
  "variant": {
    "$id": "https://api.sb/routewise.dev/variants/variant_1",
    "$type": "Variant",
    "key": "Example key",
    "value": {}
  },
  "exposure": {
    "$id": "https://api.sb/routewise.dev/exposures/exposure_1",
    "$type": "Exposure",
    "unit": "Example unit",
    "options": {},
    "propensity": 1,
    "at": "2026-10-22T12:00:00Z"
  },
  "action": {
    "$id": "https://api.sb/routewise.dev/actions/action_1",
    "operation": "Flag.evaluate",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/routewise.dev/actions/action_1"
  }
}
```

**SDK**

```ts
import { $ } from 'startup-builder'

const { variant, exposure } = await $.Flag.evaluate({ flag: 'flag_1', unit: 'Example unit' })
```

**CLI**

```bash
npx startup-builder do Flag.evaluate --json '{"flag":"flag_1","unit":"Example unit"}'
```

**MCP**

```json
{
  "name": "do",
  "arguments": {
    "code": "return await $.Flag.evaluate({ flag: 'flag_1', unit: 'Example unit' })"
  }
}
```