# Update Setting - Change Bot Configuration via API

> Update a single project setting by its key. Change bot behavior or feature configuration.

Source: https://docs.botsubscription.com/api/settings/update/

Change a single configuration value by specifying its key. This endpoint replaces the current value with your new value. Use it for targeted configuration changes without affecting other settings in your project.

<ApiEndpoint method="PATCH" endpoint="/v2/projects/{project_id}/settings/{key}" />

<ApiAuthorization type="Bearer API Key" />

**API key access:** Unrestricted project API key required. Restricted keys cannot call this endpoint.

Project keys can change only supported settings. Notification-destination changes can return `403 BACKOFFICE_DESTINATION_PERMISSION_REQUIRED`; unsupported AI-model selections can return `422 VALIDATION_ERROR`. An unrestricted key does not bypass these setting-specific restrictions.

<ApiSection title="Path Parameters">
  <ApiParameter name="project_id" type="string" required description="The unique identifier of the project." />
  <ApiParameter name="key" type="string" required description="The setting key to update." />
</ApiSection>

<ApiSection title="Request Body">
  <ApiParameter name="value" type="any" required description="The new value for the setting." />
</ApiSection>

<ApiSamplePane>

<ApiRequestSample title="Request">

```bash
curl -X PATCH "https://api.botsubscription.com/v2/projects/YOUR_PROJECT_ID/settings/default_language" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "value": "es"
  }'
```

```javascript
const project_id = 'YOUR_PROJECT_ID';
const key = 'default_language';
const response = await fetch(`https://api.botsubscription.com/v2/projects/${project_id}/settings/${key}`, {
  method: 'PATCH',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    value: 'es'
  })
});
// 204 No Content on success
```

```python
import requests

project_id = 'YOUR_PROJECT_ID'
key = 'default_language'
response = requests.patch(
    f'https://api.botsubscription.com/v2/projects/{project_id}/settings/{key}',
    headers={
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json'
    },
    json={
        'value': 'es'
    }
)
# 204 No Content on success
```

```php
$project_id = 'YOUR_PROJECT_ID';
$key = 'default_language';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.botsubscription.com/v2/projects/{$project_id}/settings/{$key}");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer YOUR_API_KEY',
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'value' => 'es'
]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
// 204 No Content on success
```

</ApiRequestSample>

<ApiResponseTabs>
  <ApiResponse status={204} description="Setting updated">

No response body is returned on successful update.

  </ApiResponse>
  <ApiResponse status={400} description="Invalid value">

```json
{
  "ok": false,
  "request_id": "11111111-1111-1111-1111-111111111111",
  "method": "PATCH",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/settings/default_language",
  "code": 400,
  "error": {
    "error_code": "BAD_REQUEST",
    "message": "Invalid value for setting"
  }
}
```

  </ApiResponse>
  <ApiResponse status={403} description="Notification destination change refused">

```json
{
  "ok": false,
  "request_id": "44444444-4444-4444-8444-444444444444",
  "method": "PATCH",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/settings/SETTING_KEY",
  "code": 403,
  "error": {
    "error_code": "BACKOFFICE_DESTINATION_PERMISSION_REQUIRED",
    "message": "The supplied API key cannot change this notification destination."
  }
}
```

  </ApiResponse>
  <ApiResponse status={422} description="Unsupported model selection">

```json
{
  "ok": false,
  "request_id": "44444444-4444-4444-8444-444444444444",
  "method": "PATCH",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/settings/SETTING_KEY",
  "code": 422,
  "errors": [
    {
      "error_code": "VALIDATION_ERROR",
      "message": "Unsupported AI-model selection."
    }
  ]
}
```

  </ApiResponse>
  <ApiResponse status={401} description="Invalid or expired API key">

```json
{
  "ok": false,
  "request_id": "44444444-4444-4444-8444-444444444444",
  "method": "PATCH",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/settings/language",
  "code": 401,
  "error": {
    "message": "Invalid or expired authentication token.",
    "error_code": "UNAUTHORIZED"
  }
}
```

  </ApiResponse>
</ApiResponseTabs>

</ApiSamplePane>
