---
description: Reference for all Flagship binding evaluation methods, including typed value and details methods for booleans, strings, numbers, and objects.
title: Methods
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/flagship/llms.txt  
> Use this file to discover all available pages before exploring further.

# Methods

Last updated Aug 24, 2026|Copy as Markdown|[View as Markdown](https://mchen-ai-models-sync.previews.developers.cloudflare.com/flagship/binding/methods/index.md)|[Agent setup](https://mchen-ai-models-sync.previews.developers.cloudflare.com/agent-setup/)

The Flagship binding provides the following methods for evaluating feature flags. All methods are asynchronous and return a `Promise`. For known evaluation failures, typed methods return the `defaultValue` you provide.

Refer to the [types reference](https://mchen-ai-models-sync.previews.developers.cloudflare.com/flagship/binding/types/) for the definitions of `FlagshipEvaluationContext` and `FlagshipEvaluationDetails`.

## `get()`

Returns the raw flag value without type checking. Use this method when the flag type is not known at compile time.

If you provide `defaultValue`, `get()` returns that value for known evaluation failures, such as a missing flag. If you omit `defaultValue`, known evaluation failures are thrown.

```ts
get(flagKey: string, defaultValue?: unknown, context?: FlagshipEvaluationContext): Promise<unknown>
```

| Parameter    | Type                      | Required | Description                                                               |
| ------------ | ------------------------- | -------- | ------------------------------------------------------------------------- |
| flagKey      | string                    | Yes      | The key of the flag to evaluate.                                          |
| defaultValue | unknown                   | No       | The fallback value returned if evaluation fails or the flag is not found. |
| context      | FlagshipEvaluationContext | No       | Key-value attributes for targeting rules.                                 |

```ts
const value = await env.FLAGS.get("checkout-flow", "v1", {
	userId: "user-42",
});
```

## `getBooleanValue()`

Returns the flag value as a `boolean`.

```ts
getBooleanValue(flagKey: string, defaultValue: boolean, context?: FlagshipEvaluationContext): Promise<boolean>
```

| Parameter    | Type                      | Required | Description                                                               |
| ------------ | ------------------------- | -------- | ------------------------------------------------------------------------- |
| flagKey      | string                    | Yes      | The key of the flag to evaluate.                                          |
| defaultValue | boolean                   | Yes      | The fallback value returned if evaluation fails or the flag is not found. |
| context      | FlagshipEvaluationContext | No       | Key-value attributes for targeting rules.                                 |

```ts
const enabled = await env.FLAGS.getBooleanValue("dark-mode", false, {
	userId: "user-42",
});
```

## `getStringValue()`

Returns the flag value as a `string`.

```ts
getStringValue(flagKey: string, defaultValue: string, context?: FlagshipEvaluationContext): Promise<string>
```

| Parameter    | Type                      | Required | Description                                                               |
| ------------ | ------------------------- | -------- | ------------------------------------------------------------------------- |
| flagKey      | string                    | Yes      | The key of the flag to evaluate.                                          |
| defaultValue | string                    | Yes      | The fallback value returned if evaluation fails or the flag is not found. |
| context      | FlagshipEvaluationContext | No       | Key-value attributes for targeting rules.                                 |

```ts
const variant = await env.FLAGS.getStringValue("checkout-flow", "v1", {
	userId: "user-42",
	country: "US",
});
```

## `getNumberValue()`

Returns the flag value as a `number`.

```ts
getNumberValue(flagKey: string, defaultValue: number, context?: FlagshipEvaluationContext): Promise<number>
```

| Parameter    | Type                      | Required | Description                                                               |
| ------------ | ------------------------- | -------- | ------------------------------------------------------------------------- |
| flagKey      | string                    | Yes      | The key of the flag to evaluate.                                          |
| defaultValue | number                    | Yes      | The fallback value returned if evaluation fails or the flag is not found. |
| context      | FlagshipEvaluationContext | No       | Key-value attributes for targeting rules.                                 |

```ts
const maxRetries = await env.FLAGS.getNumberValue("max-retries", 3, {
	plan: "enterprise",
});
```

## `getObjectValue()`

Returns the flag value as a typed object. Use the generic parameter `T` to specify the expected shape.

```ts
getObjectValue<T extends object>(flagKey: string, defaultValue: T, context?: FlagshipEvaluationContext): Promise<T>
```

| Parameter    | Type                      | Required | Description                                                               |
| ------------ | ------------------------- | -------- | ------------------------------------------------------------------------- |
| flagKey      | string                    | Yes      | The key of the flag to evaluate.                                          |
| defaultValue | T                         | Yes      | The fallback value returned if evaluation fails or the flag is not found. |
| context      | FlagshipEvaluationContext | No       | Key-value attributes for targeting rules.                                 |

```ts
interface ThemeConfig {
	primaryColor: string;
	fontSize: number;
}

const theme = await env.FLAGS.getObjectValue<ThemeConfig>(
	"theme-config",
	{ primaryColor: "#000", fontSize: 14 },
	{ userId: "user-42" },
);
```

## `getBooleanDetails()`

Returns the flag value as a `boolean` with evaluation metadata.

```ts
getBooleanDetails(flagKey: string, defaultValue: boolean, context?: FlagshipEvaluationContext): Promise<FlagshipEvaluationDetails<boolean>>
```

| Parameter    | Type                      | Required | Description                                                               |
| ------------ | ------------------------- | -------- | ------------------------------------------------------------------------- |
| flagKey      | string                    | Yes      | The key of the flag to evaluate.                                          |
| defaultValue | boolean                   | Yes      | The fallback value returned if evaluation fails or the flag is not found. |
| context      | FlagshipEvaluationContext | No       | Key-value attributes for targeting rules.                                 |

```ts
const details = await env.FLAGS.getBooleanDetails("dark-mode", false, {
	userId: "user-42",
});
console.log(details.value); // true
console.log(details.reason); // "TARGETING_MATCH"
```

## `getStringDetails()`

Returns the flag value as a `string` with evaluation metadata.

```ts
getStringDetails(flagKey: string, defaultValue: string, context?: FlagshipEvaluationContext): Promise<FlagshipEvaluationDetails<string>>
```

| Parameter    | Type                      | Required | Description                                                               |
| ------------ | ------------------------- | -------- | ------------------------------------------------------------------------- |
| flagKey      | string                    | Yes      | The key of the flag to evaluate.                                          |
| defaultValue | string                    | Yes      | The fallback value returned if evaluation fails or the flag is not found. |
| context      | FlagshipEvaluationContext | No       | Key-value attributes for targeting rules.                                 |

```ts
const details = await env.FLAGS.getStringDetails("checkout-flow", "v1", {
	userId: "user-42",
});
console.log(details.value); // "v2"
console.log(details.variant); // "new"
console.log(details.reason); // "TARGETING_MATCH"
```

## `getNumberDetails()`

Returns the flag value as a `number` with evaluation metadata.

```ts
getNumberDetails(flagKey: string, defaultValue: number, context?: FlagshipEvaluationContext): Promise<FlagshipEvaluationDetails<number>>
```

| Parameter    | Type                      | Required | Description                                                               |
| ------------ | ------------------------- | -------- | ------------------------------------------------------------------------- |
| flagKey      | string                    | Yes      | The key of the flag to evaluate.                                          |
| defaultValue | number                    | Yes      | The fallback value returned if evaluation fails or the flag is not found. |
| context      | FlagshipEvaluationContext | No       | Key-value attributes for targeting rules.                                 |

```ts
const details = await env.FLAGS.getNumberDetails("max-retries", 3, {
	plan: "enterprise",
});
console.log(details.value); // 5
console.log(details.reason); // "TARGETING_MATCH"
```

## `getObjectDetails()`

Returns the flag value as a typed object with evaluation metadata. Use the generic parameter `T` to specify the expected shape.

```ts
getObjectDetails<T extends object>(flagKey: string, defaultValue: T, context?: FlagshipEvaluationContext): Promise<FlagshipEvaluationDetails<T>>
```

| Parameter    | Type                      | Required | Description                                                               |
| ------------ | ------------------------- | -------- | ------------------------------------------------------------------------- |
| flagKey      | string                    | Yes      | The key of the flag to evaluate.                                          |
| defaultValue | T                         | Yes      | The fallback value returned if evaluation fails or the flag is not found. |
| context      | FlagshipEvaluationContext | No       | Key-value attributes for targeting rules.                                 |

```ts
interface ThemeConfig {
	primaryColor: string;
	fontSize: number;
}

const details = await env.FLAGS.getObjectDetails<ThemeConfig>(
	"theme-config",
	{ primaryColor: "#000", fontSize: 14 },
	{ userId: "user-42" },
);
console.log(details.value); // { primaryColor: "#0051FF", fontSize: 16 }
console.log(details.variant); // "brand-refresh"
```

## Error handling

Typed evaluation methods return the `defaultValue` you provided for known evaluation failures, such as a missing flag or type mismatch. Unexpected runtime failures can still throw. Use the `*Details` methods to inspect known evaluation failures.

### Type mismatch

If you call a typed method on a flag with a different type (for example, `getBooleanValue` on a string flag), the method returns the default value. The `*Details` methods set `errorCode` to `"TYPE_MISMATCH"`.

```ts
// Flag "checkout-flow" is a string flag, but you call getBooleanDetails.
const details = await env.FLAGS.getBooleanDetails("checkout-flow", false);
console.log(details.value); // false (the default value)
console.log(details.errorCode); // "TYPE_MISMATCH"
```

### Evaluation failure

If evaluation fails for another reason, the method returns the default value. The `*Details` methods include an `errorCode` such as `"FLAG_NOT_FOUND"`, `"INVALID_CONTEXT"`, `"PARSE_ERROR"`, or `"GENERAL"`.

```ts
const details = await env.FLAGS.getStringDetails(
	"nonexistent-flag",
	"fallback",
);
console.log(details.value); // "fallback"
console.log(details.errorCode); // "FLAG_NOT_FOUND"
```

## Parameters reference

The following table summarizes the parameters shared across all evaluation methods.

| Parameter    | Type                      | Required         | Description                                                                                   |
| ------------ | ------------------------- | ---------------- | --------------------------------------------------------------------------------------------- |
| flagKey      | string                    | Yes              | The key of the flag to evaluate.                                                              |
| defaultValue | varies                    | Yes (except get) | The fallback value returned if evaluation fails or the flag is not found.                     |
| context      | FlagshipEvaluationContext | No               | Key-value attributes for targeting rules (for example, { userId: "user-42", country: "US" }). |

Was this helpful?

YesNo

## On this page

[![](https://mchen-ai-models-sync.previews.developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://mchen-ai-models-sync.previews.developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/flagship/binding/methods/#page","headline":"Methods · Cloudflare Flagship docs","description":"Reference for all Flagship binding evaluation methods, including typed value and details methods for booleans, strings, numbers, and objects.","url":"https://developers.cloudflare.com/flagship/binding/methods/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","dateModified":"2026-08-24","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```
