[**axiom v0.51.1**](../../README.md)

***

[axiom](../../README.md) / [index](../README.md) / createAppScope

# Function: createAppScope()

> **createAppScope**\<`FlagSchema`, `FactSchema`\>(`config`): `AppScope`\<`FlagSchema`, `FactSchema`\>

Create a new application-level evaluation scope.

## Type Parameters

### FlagSchema

`FlagSchema` *extends* `ZodObject`\<`any`, `$strip`\>

### FactSchema

`FactSchema` *extends* `ZodObject`\<`any`, `$strip`\> \| `undefined` = `undefined`

## Parameters

### config

`AllFieldsHaveDefaults`\<`FlagSchema`\> *extends* `true` ? `AppScopeConfig`\<`FlagSchema`, `FactSchema`\> : `object`

## Returns

`AppScope`\<`FlagSchema`, `FactSchema`\>

## Example

```ts
import { z } from 'zod';

const { flag, fact, withFlags, pickFlags, overrideFlags } = createAppScope({
  flagSchema: z.object({
    ui: z.object({
      darkMode: z.boolean().default(false),
      theme:    z.object({
        primary: z.string().default('#00f'),
      }),
    }),
    api: z.object({ 
      endpoint: z.string().default('/api') 
    }),
  }),
  factSchema: z.object({
    userAction: z.string(),
    timing: z.number(),
  }),
});

// Typed flag access
const dark = flag('ui.darkMode'); // inferred boolean
const theme = flag('ui.theme'); // entire object
const primary = flag('ui.theme.primary'); // '#00f'
const endpoint = flag('api.endpoint'); // uses schema default

// Typed fact recording
fact('userAction', 'clicked_button');
fact('timing', 1250);

// Temporarily override flags for a block of code
withFlags({ 'ui.darkMode': true }, () => {
  // code here, `ui.darkMode` will be true in this block and reset after
});

// Override flags globally for the current evaluation run
overrideFlags({ 'api.endpoint': '/custom' });
```
