> ## 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.setSettings()

> Set a workspace setting value from client or server code

`Settings.setSettings()` updates a single workspace setting value programmatically. Pass `null` to clear a value.

It is available from both `attio/client` and `attio/server`:

```tsx theme={"system"}
// In client code (extensions, dialogs, etc.)
import {Settings} from "attio/client"
```

```tsx theme={"system"}
// In server functions, webhook handlers, and event handlers
import {Settings} from "attio/server"
```

## Parameters

<ParamField path="schema" type="WorkspaceSettingsSchema" required>
  The schema built with [`Settings.defineWorkspaceSchema`](./define-workspace-schema), imported
  from your schema file.
</ParamField>

<ParamField path="key" type="string" required>
  The key of the setting to update. Must match a key defined in your schema; the key is fully
  typed, so TypeScript will only allow valid setting keys.
</ParamField>

<ParamField path="value" type="string | number | boolean | null" required>
  The new value for the setting. The type must match the setting type defined in your schema;
  TypeScript will enforce this. Pass `null` to clear the setting.
</ParamField>

## Returns

A promise that resolves when the setting has been updated.

## Example

```ts src/toggle-auto-sync.server.ts theme={"system"}
import {Settings} from "attio/server"

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

export default async function toggleAutoSync() {
  // Set a boolean setting
  await Settings.setSettings(schema, "auto_sync_enabled", true)

  // Set a number setting
  await Settings.setSettings(schema, "sync_interval_minutes", 30)

  // Clear a string setting
  await Settings.setSettings(schema, "team_name", null)

  return {success: true}
}
```

## Type safety

The function enforces type safety for both keys and values:

```ts theme={"system"}
// TypeScript enforces valid keys and matching value types
await Settings.setSettings(schema, "team_name", "Team A") // ✓ Valid
await Settings.setSettings(schema, "auto_sync_enabled", true) // ✓ Valid
await Settings.setSettings(schema, "sync_interval_minutes", 60) // ✓ Valid

await Settings.setSettings(schema, "nonexistent", "value") // ✗ TypeScript error!
await Settings.setSettings(schema, "auto_sync_enabled", "yes") // ✗ TypeScript error! (wrong type)
```

## Related

* [`Settings.getSettings()`](./get-settings) - Read setting values
* [`Settings.useSettings()`](./use-settings) - Read settings reactively in React components
