# Update the risk settings (/docs/api-reference/risk/update-risk-settings)

Changes the fields given. `review_threshold` must not exceed `block_threshold`. Disabled reasons never fire (rules still see the facts behind them). Setting a captcha provider makes assessments verify their `captcha.token` with it; `required` adds `captcha.missing` to assessments without one. `reason_weights` replaces reasons' default weights (for example with calibration's `suggested_weight`); `null` restores a default.

`PATCH https://api.coss.com/v1/risk/settings`

Authenticate with your API key as a bearer token (`Authorization: Bearer coss_test_…`). Responses are JSON with snake_case fields; errors are `{ error: { type, code, message, param?, issues?, request_id } }` (https://coss.com/docs/api-reference/errors.md).

## Request body

- `review_threshold` (number, at most 1): Scores at or above it are `review`.
- `block_threshold` (number, at most 1): Scores at or above it are `block`.
- `disabled_reasons` (string[], at most 100 items): Reasons that never fire in this environment. Replaces the list.
- `captcha` (object | null): `null` turns captcha verification off and deletes the secret.
  - `provider` ("turnstile" | "hcaptcha", required): The captcha provider.
  - `secret` (string, 1-1024 characters): The provider's secret key. Required when setting a provider for the first time or changing it; stored encrypted and never returned.
  - `required` (boolean): Assessments without a `captcha` token get `captcha.missing`. Default false.
- `content_thresholds` (object): Changes the categories given: a score in (0, 1] sets the threshold, `null` removes it.
  - `spam` (number | null, at most 1): The score at which `content.spam` fires. `null` removes it.
  - `phishing` (number | null, at most 1): The score at which `content.phishing` fires. `null` removes it.
  - `malware` (number | null, at most 1): The score at which `content.malware` fires. `null` removes it.
  - `fraud` (number | null, at most 1): The score at which `content.fraud` fires. `null` removes it.
- `reason_weights` (object): Changes the reasons given: a weight in [0, 0.99] replaces the default, `null` goes back to it.
  - `email.invalid` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `email.disposable` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `email.undeliverable` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `email.role_account` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `email.typo` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `email.domain_new` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `ip.tor` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `ip.vpn_network` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `ip.hosting_provider` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `ip.vpn` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `ip.proxy` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `ip.relay` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `ip.private` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `velocity.signups_per_ip_1h` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `velocity.signups_per_ip_24h` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `velocity.signups_per_subnet_1h` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `velocity.signups_per_email_domain_1h` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `velocity.signups_per_mailbox_24h` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `velocity.signups_per_device_24h` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `velocity.checkouts_per_ip_1h` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `velocity.checkouts_per_user_1h` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `velocity.checkouts_per_card_24h` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `velocity.logins_per_ip_1h` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `velocity.logins_per_user_1h` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `velocity.events_per_ip_1h` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `velocity.events_per_user_1h` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `duplicate.canonical_mailbox` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `duplicate.device` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `history.fraud_mailbox` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `history.fraud_user` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `history.fraud_ip` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `history.fraud_subnet` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `history.fraud_card` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `history.fraud_device` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `checkout.card_country_mismatch` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `checkout.billing_country_mismatch` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `checkout.prepaid_card` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `device.automation` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `device.invalid` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `login.new_country` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `login.new_network` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `captcha.failed` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `captcha.missing` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `content.spam` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `content.phishing` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `content.malware` (number | null, 0-0.99): This reason's new weight. `null` restores its default.
  - `content.fraud` (number | null, 0-0.99): This reason's new weight. `null` restores its default.

## Example request

TypeScript (the `coss` package):

```ts
import { Coss } from "coss";

const coss = new Coss({
  apiKey: process.env.COSS_API_KEY,
  baseUrl: "https://api.coss.com",
});

const { data, error } = await coss.risk.settings.update({
  block_threshold: 0.9,
  captcha: {
    provider: "turnstile",
    secret: "0x4AAA…",
    required: true,
  },
});
```

HTTP:

```sh
curl -X PATCH "https://api.coss.com/v1/risk/settings" \
  -H "Authorization: Bearer $COSS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "block_threshold": 0.9,
  "captcha": {
    "provider": "turnstile",
    "secret": "0x4AAA…",
    "required": true
  }
}'
```

Python:

```python
from coss import Coss
from coss.risk.settings import UpdateRiskSettingsRequestCaptcha

client = Coss()  # api_key= or COSS_API_KEY

client.risk.settings.update(
    block_threshold=0.9,
    captcha=UpdateRiskSettingsRequestCaptcha(
        provider="turnstile",
        secret="0x4AAA…",
        required=True,
    ),
)
```

Go:

```go
import (
	"context"

	coss "github.com/cosscom/coss-go"
	cossclient "github.com/cosscom/coss-go/client"
	risk "github.com/cosscom/coss-go/risk"
)

client := cossclient.NewClient() // option.WithAPIKey(…) or COSS_API_KEY

request := &risk.UpdateRiskSettingsRequest{
    BlockThreshold: coss.Float64(
        0.9,
    ),
    Captcha: &risk.UpdateRiskSettingsRequestCaptcha{
        Provider: risk.UpdateRiskSettingsRequestCaptchaProviderTurnstile,
        Secret: coss.String(
            "0x4AAA…",
        ),
        Required: coss.Bool(
            true,
        ),
    },
}
client.Risk.Settings.Update(
    context.TODO(),
    request,
)
```

Ruby:

```ruby
require "coss"

client = Coss::Client.new # api_key: or COSS_API_KEY

client.risk.settings.update(
  block_threshold: 0.9,
  captcha: {
    provider: "turnstile",
    secret: "0x4AAA…",
    required: true
  }
)
```

PHP:

```php
<?php

use Coss\Coss;
use Coss\Risk\Settings\Requests\UpdateRiskSettingsRequest;
use Coss\Risk\Settings\Types\UpdateRiskSettingsRequestCaptcha;
use Coss\Risk\Settings\Types\UpdateRiskSettingsRequestCaptchaProvider;

$client = new Coss(); // apiKey: or COSS_API_KEY

$client->risk->settings->update(
    new UpdateRiskSettingsRequest([
        'blockThreshold' => 0.9,
        'captcha' => new UpdateRiskSettingsRequestCaptcha([
            'provider' => UpdateRiskSettingsRequestCaptchaProvider::Turnstile->value,
            'secret' => '0x4AAA…',
            'required' => true,
        ]),
    ]),
);
```

Java:

```java
import com.coss.Coss;
import com.coss.resources.risk.settings.requests.UpdateRiskSettingsRequest;
import com.coss.resources.risk.settings.types.UpdateRiskSettingsRequestCaptcha;
import com.coss.resources.risk.settings.types.UpdateRiskSettingsRequestCaptchaProvider;

Coss client = Coss.builder().build(); // .apiKey(…) or COSS_API_KEY

client.risk().settings().update(
    UpdateRiskSettingsRequest
        .builder()
        .captcha(
            OptionalNullable.of(
                UpdateRiskSettingsRequestCaptcha
                    .builder()
                    .provider(UpdateRiskSettingsRequestCaptchaProvider.TURNSTILE)
                    .secret("0x4AAA…")
                    .required(true)
                    .build()
            )
        )
        .blockThreshold(0.9)
        .build()
);
```

.NET:

```csharp
using Coss;
using Coss.Risk;

var client = new CossClient(); // apiKey: or COSS_API_KEY

await client.Risk.Settings.UpdateAsync(
    new UpdateRiskSettingsRequest
    {
        BlockThreshold = 0.9,
        Captcha = new UpdateRiskSettingsRequestCaptcha
        {
            Provider = UpdateRiskSettingsRequestCaptchaProvider.Turnstile,
            Secret = "0x4AAA…",
            Required = true,
        },
    }
);
```

## Response 200

The settings, updated.

- `object` ("risk_settings", required)
- `review_threshold` (number, required): Scores at or above it are `review`.
- `block_threshold` (number, required): Scores at or above it are `block`.
- `disabled_reasons` (string[], required): Reasons that never fire in this environment (they don't count in the score).
- `captcha` (object | null, required): The captcha provider assessments verify tokens with (never the secret).
  - `provider` ("turnstile" | "hcaptcha", required): The captcha provider.
  - `required` (boolean, required): Whether assessments without a token get `captcha.missing`.
- `content_thresholds` (object, required): Per content category, the score at which `content.<category>` fires; `null`: never (the score is still in `signals.content` for your rules).
  - `spam` (number | null, required): The score at which `content.spam` fires. `null`: never.
  - `phishing` (number | null, required): The score at which `content.phishing` fires. `null`: never.
  - `malware` (number | null, required): The score at which `content.malware` fires. `null`: never.
  - `fraud` (number | null, required): The score at which `content.fraud` fires. `null`: never.
- `reason_weights` (object, required): Reasons whose weight this environment changed (from calibration or by hand); the rest weigh what the reason catalog says.
  - `email.invalid` (number): This reason's weight in this environment.
  - `email.disposable` (number): This reason's weight in this environment.
  - `email.undeliverable` (number): This reason's weight in this environment.
  - `email.role_account` (number): This reason's weight in this environment.
  - `email.typo` (number): This reason's weight in this environment.
  - `email.domain_new` (number): This reason's weight in this environment.
  - `ip.tor` (number): This reason's weight in this environment.
  - `ip.vpn_network` (number): This reason's weight in this environment.
  - `ip.hosting_provider` (number): This reason's weight in this environment.
  - `ip.vpn` (number): This reason's weight in this environment.
  - `ip.proxy` (number): This reason's weight in this environment.
  - `ip.relay` (number): This reason's weight in this environment.
  - `ip.private` (number): This reason's weight in this environment.
  - `velocity.signups_per_ip_1h` (number): This reason's weight in this environment.
  - `velocity.signups_per_ip_24h` (number): This reason's weight in this environment.
  - `velocity.signups_per_subnet_1h` (number): This reason's weight in this environment.
  - `velocity.signups_per_email_domain_1h` (number): This reason's weight in this environment.
  - `velocity.signups_per_mailbox_24h` (number): This reason's weight in this environment.
  - `velocity.signups_per_device_24h` (number): This reason's weight in this environment.
  - `velocity.checkouts_per_ip_1h` (number): This reason's weight in this environment.
  - `velocity.checkouts_per_user_1h` (number): This reason's weight in this environment.
  - `velocity.checkouts_per_card_24h` (number): This reason's weight in this environment.
  - `velocity.logins_per_ip_1h` (number): This reason's weight in this environment.
  - `velocity.logins_per_user_1h` (number): This reason's weight in this environment.
  - `velocity.events_per_ip_1h` (number): This reason's weight in this environment.
  - `velocity.events_per_user_1h` (number): This reason's weight in this environment.
  - `duplicate.canonical_mailbox` (number): This reason's weight in this environment.
  - `duplicate.device` (number): This reason's weight in this environment.
  - `history.fraud_mailbox` (number): This reason's weight in this environment.
  - `history.fraud_user` (number): This reason's weight in this environment.
  - `history.fraud_ip` (number): This reason's weight in this environment.
  - `history.fraud_subnet` (number): This reason's weight in this environment.
  - `history.fraud_card` (number): This reason's weight in this environment.
  - `history.fraud_device` (number): This reason's weight in this environment.
  - `checkout.card_country_mismatch` (number): This reason's weight in this environment.
  - `checkout.billing_country_mismatch` (number): This reason's weight in this environment.
  - `checkout.prepaid_card` (number): This reason's weight in this environment.
  - `device.automation` (number): This reason's weight in this environment.
  - `device.invalid` (number): This reason's weight in this environment.
  - `login.new_country` (number): This reason's weight in this environment.
  - `login.new_network` (number): This reason's weight in this environment.
  - `captcha.failed` (number): This reason's weight in this environment.
  - `captcha.missing` (number): This reason's weight in this environment.
  - `content.spam` (number): This reason's weight in this environment.
  - `content.phishing` (number): This reason's weight in this environment.
  - `content.malware` (number): This reason's weight in this environment.
  - `content.fraud` (number): This reason's weight in this environment.
- `updated_at` (string | null, required, date-time): `null` while on the defaults.

Example:

```json
{
  "object": "risk_settings",
  "review_threshold": 0.5,
  "block_threshold": 0.85,
  "disabled_reasons": [
    "email.role_account"
  ],
  "captcha": {
    "provider": "turnstile",
    "required": true
  },
  "content_thresholds": {
    "spam": null,
    "phishing": 0.8,
    "malware": 0.8,
    "fraud": 0.9
  },
  "reason_weights": {
    "ip.hosting_provider": 0.1
  },
  "updated_at": "2026-01-15T09:30:00.000Z"
}
```

## Errors

- `400`: The body is not valid JSON (`invalid_json`). Also when the `Coss-Version` header names an unknown API version (`invalid_api_version`).
- `401`: The API key is missing, invalid, revoked or expired (`authentication_error`).
- `403`: The API key lacks the permission this endpoint needs (`permission_error`), or its organization is suspended (`organization_suspended`).
- `413`: The request body is larger than 5 MB (`payload_too_large`).
- `415`: The body is not sent as `application/json` (`unsupported_media_type`).
- `422`: The body failed validation (`validation_error`, see `issues`), the thresholds are out of order, or a new captcha provider has no secret (`invalid_settings`).
- `429`: Too many requests with this API key (`rate_limited`), or too many requests with invalid keys from this address (`too_many_failed_authentications`). Retry after `Retry-After` seconds. Successful responses carry `RateLimit-Limit`, `RateLimit-Remaining` and `RateLimit-Reset` (seconds until the limit is fully restored).
- `500`: Unexpected server error (`api_error` / `internal_error`).
- `503`: The API key could not be verified right now; retry (`service_unavailable`).