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

# Settings and managed settings

> Use ServerRpc in Laravel Copilot SDK to work with contentExclusion, managed settings, settings files, and provider configuration.

## Settings and managed settings

Scope: ServerRpc (server-wide operations tied to the Client)

For an overview of RPC and the list of all RPC pages, see [RPC](https://kawax.biz/en/packages/laravel-copilot-sdk/rpc.md).

```php theme={null}
// user settings
// The current CLI has no user.settings.reload RPC. get() targets settings.json.
Copilot::client()->rpc()->userSettings()->set(['settings' => ['theme' => 'dark']]); // No return value
```

## contentExclusion

You can validate content exclusion policy JSON before creating a session.

```php theme={null}
use Revolution\Copilot\Types\Rpc\ContentExclusionValidatePoliciesRequest;

$result = Copilot::client()->rpc()->contentExclusion()->validatePolicies(
    new ContentExclusionValidatePoliciesRequest(policiesJson: $policiesJson),
);
// $result->policies holds the validated, normalized policies
```

`policiesJson` is passed to the CLI as an unparsed JSON string. If JSON parsing or schema validation fails, the CLI raises an RPC error (`JsonRpcException`).

This is a server-scoped RPC that validates the policies themselves. To check paths in the session's working directory against the actual exclusion policies, use the session-scoped `contentExclusion()->checkPaths()`.

## managedSettings (experimental: managed settings)

Read managed settings, resolve policies, get the schema, validate, preview composition, and clear the cache.

```php theme={null}
$managedSettings = $client->rpc()->managedSettings()->read();
$effective = $client->rpc()->managedSettings()->resolve([
    'selectionId' => 'selection-id',
    'workingDirectory' => '/path/to/project',
]);
$schema = $client->rpc()->managedSettings()->schema();
$validation = $client->rpc()->managedSettings()->validate(['content' => ['permissions' => []]]);
$preview = $client->rpc()->managedSettings()->compose(['layers' => [
    ['source' => 'device', 'settings' => ['permissions' => []]],
]]);
$client->rpc()->managedSettings()->clearCache();
```

## settings (experimental: settings file operations)

Remove a specific key from a settings file and redact secret values for display. `removeRawKey()` removes keys as-is, including keys that aren't canonical settings paths, such as keys that failed to load. If the file can't be parsed, the CLI doesn't overwrite it and `status` is `invalid`. `redactValueForDisplay()` replaces secret values with placeholders based on the position in the settings tree given by `basePath`, so you can safely show the value to users or write it to logs.

```php theme={null}
$result = $client->rpc()->settings()->removeRawKey([
    'filePath' => '/path/to/settings.json',
    'rawKey' => 'misspelledKey',
]);
// $result->status is 'ok' or 'invalid'

$redacted = $client->rpc()->settings()->redactValueForDisplay([
    'value' => ['apiKey' => 'secret-value', 'name' => 'visible'],
    'basePath' => ['providers', 'openai'],
]);
// Secret values in $redacted->value are replaced with placeholders
```

## providersConfig (experimental: provider configuration)

`providersConfig()->addModel()` is an experimental RPC that adds a model to the server's saved provider configuration. If the provider isn't saved yet, the CLI creates it, and `providerAdded` tells you so. The change is persistent, but it doesn't modify running sessions.

```php theme={null}
use Revolution\Copilot\Facades\Copilot;

$result = Copilot::client()->rpc()->providersConfig()->addModel([
    'provider' => ['name' => 'my-provider', 'baseUrl' => 'https://example.com/v1'],
    'model' => ['id' => 'my-model', 'provider' => 'my-provider'],
    // 'credential' => $apiKey,
]);

// $result->providerAdded
```

You can pass a `ProvidersConfigAddModelRequest` instead of an array. The CLI stores the optional `credential` in the OS keychain and never returns it in the result.

The same `providersConfig()` group reads, updates, and removes the saved configuration. These are also experimental APIs, and they don't modify running sessions.

```php theme={null}
$config = Copilot::client()->rpc()->providersConfig();
$saved = $config->read(); // $saved->providers and $saved->models

$provider = $config->updateProvider([
    'provider' => ['name' => 'my-provider', 'baseUrl' => 'https://example.com/v2'],
    // 'credential' => $apiKey,
]); // $provider->providerName

$model = $config->updateModel([
    'model' => ['id' => 'my-model', 'provider' => 'my-provider', 'maxOutputTokens' => 4096],
]); // $model->providerName and $model->modelId

$removed = $config->removeModel([
    'providerName' => 'my-provider',
    'modelId' => 'my-model',
]); // $removed->providerRemoved
```

`read()` returns the configuration in saved order, without secrets such as credentials, headers, or commands. Each provider's `credentialStatus` is `present`, `absent`, or `unavailable`. `updateProvider()` replaces the shared settings and keeps any credential, custom headers, and local model settings you omit. `updateModel()` replaces the model definition for the given provider name and model ID. When `removeModel()` removes the last model of a provider, it also removes the provider and its managed credential, and `providerRemoved` is `true`. Each update and removal also accepts the matching `ProvidersConfigUpdateProviderRequest`, `ProvidersConfigUpdateModelRequest`, or `ProvidersConfigRemoveModelRequest`.


## Related topics

- [SessionConfig](https://kawax.biz/en/packages/laravel-copilot-sdk/session-config.md)
- [RPC (Remote Procedure Call)](https://kawax.biz/en/packages/laravel-copilot-sdk/rpc.md)
- [Session hooks](https://kawax.biz/en/packages/laravel-copilot-sdk/hooks.md)
- [ServerRpc overview](https://kawax.biz/en/packages/laravel-copilot-sdk/rpc/server-overview.md)
- [Managed settings, debug, and history](https://kawax.biz/en/packages/laravel-copilot-sdk/rpc/session-settings.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.