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

# getWorkspaceSetting()

> Get a single workspace setting value

The `getWorkspaceSetting()` function retrieves a single workspace setting value by key. It is only available in **server functions**.

```tsx theme={"system"}
import {getWorkspaceSetting} from "attio/server"
```

<Note>
  For React components and client code, use [`getWorkspaceSettings()`](./get-workspace-settings) from `attio/client` to read settings, or [`useWorkspaceSettings()`](./use-workspace-settings) for real-time updates.
</Note>

## Parameters

<ParamField path="key" type="string" required>
  The key of the setting to retrieve. Must match a key defined in your [workspace settings schema](./app-settings-schema).

  The key is fully typed, so TypeScript will only allow valid setting keys.
</ParamField>

## Returns

A promise that resolves to the value of the requested setting. The return type is automatically inferred based on the setting type in your schema.

## Example

```tsx check-sync-status.server.ts theme={"system"}
import {getWorkspaceSetting} from "attio/server"

export default async function checkSyncStatus() {
  // Get a single setting value
  const autoSyncEnabled = await getWorkspaceSetting("auto_sync_enabled")

  // TypeScript knows this is a boolean
  if (autoSyncEnabled) {
    const syncInterval = await getWorkspaceSetting("sync_interval_minutes")

    // TypeScript knows this is a number
    return {
      status: "enabled",
      interval: syncInterval,
    }
  }

  return {status: "disabled"}
}
```

## Type Safety

The function's parameter and return type are automatically inferred from your schema:

```typescript app.settings.ts theme={"system"}
import {Settings, type SettingsSchema} from "attio"

const appSettingsSchema = {
  workspace: {
    team_name: Settings.string(),
    auto_sync_enabled: Settings.boolean(),
    sync_interval_minutes: Settings.number(),
  },
} satisfies SettingsSchema

export default appSettingsSchema
```

```tsx theme={"system"}
// TypeScript enforces valid keys and infers return types
await getWorkspaceSetting("team_name") // string
await getWorkspaceSetting("auto_sync_enabled") // boolean
await getWorkspaceSetting("sync_interval_minutes") // number
await getWorkspaceSetting("nonexistent") // TypeScript error!
```
