The setWorkspaceSetting() function updates a single workspace setting value programmatically.
// In client code (React components, actions, etc.)
import {setWorkspaceSetting} from "attio/client"
// In server functions
import {setWorkspaceSetting} from "attio/server"
Parameters
The key of the setting to update. Must match a key defined in your workspace settings schema.The key is fully typed, so TypeScript will only allow valid setting keys.
value
string | boolean | number
required
The new value for the setting. The type must match the setting type defined in your schema.TypeScript will enforce that the value type matches the setting type.
Returns
A promise that resolves when the setting has been updated.
Example
toggle-auto-sync.server.ts
import {setWorkspaceSetting} from "attio/server"
export default async function toggleAutoSync() {
// Set a boolean setting
await setWorkspaceSetting("auto_sync_enabled", true)
// Set a number setting
await setWorkspaceSetting("sync_interval_minutes", 30)
// Set a string setting
await setWorkspaceSetting("team_name", "Engineering Team")
return {success: true}
}
In Client Code
import {setWorkspaceSetting} from "attio/client"
import type {App} from "attio"
export const enableSyncAction: App.Record.Action = {
id: "enable-sync",
label: "Enable Sync",
icon: "Check",
onTrigger: async ({recordId}) => {
// Update settings from a record action
await setWorkspaceSetting("auto_sync_enabled", true)
await setWorkspaceSetting("sync_interval_minutes", 30)
},
}
Type Safety
The function enforces type safety for both keys and values:
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 matching value types
await setWorkspaceSetting("team_name", "Team A") // ✓ Valid
await setWorkspaceSetting("auto_sync_enabled", true) // ✓ Valid
await setWorkspaceSetting("sync_interval_minutes", 60) // ✓ Valid
await setWorkspaceSetting("nonexistent", "value") // ✗ TypeScript error!
await setWorkspaceSetting("auto_sync_enabled", "yes") // ✗ TypeScript error! (wrong type)
await setWorkspaceSetting("sync_interval_minutes", "30") // ✗ TypeScript error! (wrong type)