Skip to main content

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.

The getWorkspaceSetting() function retrieves a single workspace setting value by key. It is only available in server functions.
import {getWorkspaceSetting} from "attio/server"
For React components and client code, use getWorkspaceSettings() from attio/client to read settings, or useWorkspaceSettings() for real-time updates.

Parameters

key
string
required
The key of the setting to retrieve. Must match a key defined in your workspace settings schema.The key is fully typed, so TypeScript will only allow valid setting keys.

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

check-sync-status.server.ts
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:
app.settings.ts
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
// 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!