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

# Settings.defineWorkspaceSchema()

> Define the structure and types of your workspace settings

`Settings.defineWorkspaceSchema()` declares the workspace-scoped settings of your app: the setting names and their types. The schema is the source of type safety for every other settings API: [`Settings.useForm`](./use-form), [`Settings.useSettings`](./use-settings), [`Settings.getSettings`](./get-settings), and [`Settings.setSettings`](./set-settings) all take the schema and infer their types from it.

## File location

The schema must be the **default export** of a file in `src/app/settings/`, conventionally `src/app/settings/schema.ts`, so the CLI can discover it.

```ts src/app/settings/schema.ts theme={"system"}
import {Settings} from "attio"

export default Settings.defineWorkspaceSchema({
  team_name: Settings.Schema.string(),
  auto_sync_enabled: Settings.Schema.boolean(),
  sync_interval_minutes: Settings.Schema.number(),
})
```

Note the import from `"attio"` (not `attio/client` or `attio/server`): the schema file is imported by both client and server code, so it must not depend on either runtime.

## Setting types

The `Settings.Schema` namespace provides the following node builders:

<ParamField path="Settings.Schema.string()" type="SettingsStringNode">
  A setting holding a string value. Use this for text values like names, URLs, or identifiers.
</ParamField>

<ParamField path="Settings.Schema.number()" type="SettingsNumberNode">
  A setting holding a number value. Use this for numeric values like intervals, limits, or
  thresholds.
</ParamField>

<ParamField path="Settings.Schema.boolean()" type="SettingsBooleanNode">
  A setting holding a boolean value. Use this for toggles, checkboxes, or on/off configurations.
</ParamField>

## Values are `null` until set

Every setting value is `null` until a user (or your code) has set it. When you read settings, handle the `null` case:

```ts theme={"system"}
import {Settings} from "attio/server"

import schema from "../app/settings/schema"

export default async function syncRecords() {
  const interval = await Settings.getSettings(schema, "sync_interval_minutes")
  // interval: number | null
  if (interval === null) {
    return {success: false, message: "Sync interval is not configured"}
  }
  return {success: true, interval}
}
```
