# Flag programs: evaluate

URL: /code/mcp/flag/verbs · Id: `page:code/mcp/flag/verbs`

> The Flag Verbs evaluate as MCP do programs, with inputs, result, refusals and an example.

Reference for [Flag](/business/nouns/flag), one group of [Flag programs](/code/mcp/flag).

### Flag.evaluate
Evaluate returns the Variant a Flag assigns one unit, the same one every time, and records the Exposure with every option and its propensity. [Verb page](/business/nouns/flag/evaluate?interface=mcp).

```text
do: return await $.Flag.evaluate(input)
```

Emits [`Flag.evaluated`](/business/events/Flag.evaluated).

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

**Returns**

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

**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. | None. |

**Example**

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