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

# Policy

> Read the KYC policy your calls run under, save a new version, list the history, and what an API key can and cannot change.

The KYC policy decides what a verdict does with a document or a party: thresholds, actions, required documents and locks. It is the same policy the console edits (**Settings, KYC policy**) and that `/v1/kyc/*` applies. The parameters are described on [KYC policy and document integrity](https://docs.sahlfinancial.com/guides/kyc-policy.md). These routes let a key read it and save new versions.

| Endpoint | Scope | Does |
| - | - | - |
| `GET /v1/partner/policy` | `policy:read` | The effective policy for individuals and companies. |
| `PUT /v1/partner/policy` | `policy:write` | Saves a new version of one client type's policy. |
| `GET /v1/partner/policy/versions` | `policy:read` | The saved history, newest first. |

The environment is `X-Sahl-Environment` or `environment` (`sandbox` by default). A Sandbox policy and a Production policy are separate. Production calls need your workspace to be approved for Production API calls (see [Go live](https://docs.sahlfinancial.com/go-live.md#partner-document-apis)). Each key is limited to 60 calls a minute on these routes.

## Read the policy

```bash cURL theme={"dark"}
curl https://app.sahlfinancial.com/api/v1/partner/policy \
  -H "Authorization: Bearer $SAHL_API_KEY"
```

```javascript JavaScript theme={"dark"}
const res = await fetch("https://app.sahlfinancial.com/api/v1/partner/policy", {
  headers: { Authorization: `Bearer ${process.env.SAHL_API_KEY}` },
});
const { regulation, policies } = await res.json();
```

```python Python theme={"dark"}
import os, requests

body = requests.get(
    "https://app.sahlfinancial.com/api/v1/partner/policy",
    headers={"Authorization": f"Bearer {os.environ['SAHL_API_KEY']}"},
).json()
for p in body["policies"]:
    print(p["client_type"], p["source"], p["version"], p["locked"])
```

```json theme={"dark"}
{
  "environment": "sandbox",
  "regulation": {
    "key": "ma_anrf",
    "label": "Morocco, Law 43-05",
    "regulator": "ANRF",
    "law": "Law 43-05",
    "locked": ["id_verification", "sanctions_screening"],
    "retention_days": 3650,
    "assumed": false
  },
  "policies": [
    {
      "client_type": "individual",
      "kind": "kyc",
      "environment": "sandbox",
      "source": "tenant",
      "policy_id": "5d2f0000-0000-4000-8000-000000000009",
      "version": 3,
      "managed_by_flow": false,
      "created_at": "2026-11-23T09:00:00Z",
      "parameters": {
        "duplicate_document_action": "flag",
        "duplicate_hamming_threshold": 6,
        "name_match_threshold": 0.5,
        "max_document_age_days_by_type": {},
        "min_applicant_age_years": 0,
        "max_id_age_years": 0,
        "liveness_strictness": "standard",
        "fake_image_action": "flag",
        "sanctions_pep_action": "refuse",
        "sanctions_name_match_threshold": 0.88
      },
      "locked": ["id_verification", "sanctions_screening"],
      "regulator_locked": ["id_verification", "sanctions_screening"],
      "config": {"...": "the full policy"}
    }
  ]
}
```

The values above are illustrative. There is one entry per client type: `individual` (stored kind `kyc`) and `company` (`kyb`). `source` is `tenant` (a saved version), `preset` (the regime's default), `legacy` (the unregulated default) or `fallback` (a saved version that no longer validated, replaced by the default). `version` is 0 and `policy_id` is `null` for a default. `managed_by_flow` is true when the version was compiled from a dashboard flow: saving one here detaches it from the flow. `parameters` repeats the main tunable values; `config` is the complete policy, in the shape `PUT` accepts. `regulation.locked` is what the regulator mandates, and `assumed` is true when the regime is assumed from the country.

## Save a new version

`PUT /v1/partner/policy` takes:

| Field | Rules |
| - | - |
| `client_type` | `individual` or `company`. |
| `environment` | Optional. Must agree with `X-Sahl-Environment` if both are sent. |
| `config` | The **whole** policy, as `GET` returns it in `config`. Fields you leave out take their defaults, not their current values: send the full config back with your changes. |

```bash cURL theme={"dark"}
curl https://app.sahlfinancial.com/api/v1/partner/policy -s \
  -H "Authorization: Bearer $SAHL_API_KEY" |
jq '.policies[] | select(.client_type == "individual") | .config
    | .thresholds.duplicate_document_action = "review"
    | {client_type: "individual", config: .}' |
curl -X PUT https://app.sahlfinancial.com/api/v1/partner/policy \
  -H "Authorization: Bearer $SAHL_API_KEY" -H "Content-Type: application/json" -d @-
```

```javascript JavaScript theme={"dark"}
const base = "https://app.sahlfinancial.com/api/v1/partner/policy";
const headers = { Authorization: `Bearer ${process.env.SAHL_API_KEY}`, "Content-Type": "application/json" };

const { policies } = await (await fetch(base, { headers })).json();
const config = policies.find((p) => p.client_type === "individual").config;
config.thresholds.duplicate_document_action = "review";

const saved = await (
  await fetch(base, { method: "PUT", headers, body: JSON.stringify({ client_type: "individual", config }) })
).json();
console.log(saved.version, saved.source);
```

```python Python theme={"dark"}
import os, requests

base = "https://app.sahlfinancial.com/api/v1/partner/policy"
headers = {"Authorization": f"Bearer {os.environ['SAHL_API_KEY']}"}

policies = requests.get(base, headers=headers).json()["policies"]
config = next(p for p in policies if p["client_type"] == "individual")["config"]
config["thresholds"]["duplicate_document_action"] = "review"

saved = requests.put(base, headers=headers, json={"client_type": "individual", "config": config}).json()
print(saved["version"], saved["source"])
```

The answer is the saved `ClientPolicy` (the same object as an entry of `policies`, with the new `version`). Every save is audited, with the difference, and detaches the policy from any flow that compiled it.

### What an API key cannot do

A key may add locks and tighten values. It cannot remove **any** item that is locked in the policy in force, the workspace's own locks included, and it cannot drop what the regulator mandates or go below the regime's floors (for example the record-keeping days). Unlocking is a decision for a workspace admin in the console. These saves are refused with 422 `kyc_policy_lock_required` and a `locked` list naming the items. Other rules of the policy still hold: `sanctions_pep_action` must stay `refuse` while sanctions screening is locked, `sanctions_name_match_threshold` cannot rise above 0.88 then, and `liveness_strictness: "lenient"` is refused while identity verification is locked.

If another save landed at the same time the call answers 409 `policy_conflict`: read the policy again and save again.

## List the versions

```bash theme={"dark"}
curl "https://app.sahlfinancial.com/api/v1/partner/policy/versions?client_type=company&limit=20" \
  -H "Authorization: Bearer $SAHL_API_KEY"
```

| Query | Rules |
| - | - |
| `client_type` | `individual` or `company`. Both when omitted. |
| `limit` | 1 to 100. Default 20. |
| `offset` | Default 0. |

```json theme={"dark"}
{
  "items": [
    {
      "id": "5d2f0000-0000-4000-8000-000000000009",
      "client_type": "company",
      "kind": "kyb",
      "environment": "sandbox",
      "version": 2,
      "is_active": true,
      "managed_by_flow": false,
      "created_at": "2026-11-23T09:00:00Z",
      "config": {"...": "the policy as saved"}
    }
  ],
  "limit": 20,
  "offset": 0,
  "next_offset": null
}
```

The list holds every version saved in the environment (from the console, a flow or the API), newest first. A default is not a version and is not listed. `next_offset` is `null` on the last page.

## Errors

| Status | `detail.code` | Cause |
| - | - | - |
| 422 | `kyc_policy_lock_required` | The config drops a locked item, goes below a regime floor or unlocks something locked. |
| 422 | (field list) | The config does not validate (a value out of range, an unknown document type). |
| 409 | `policy_conflict` | Another save landed at the same time. Retry after reading. |
| 403 | `production_api_not_approved` and the other Production gates | See [Go live](https://docs.sahlfinancial.com/go-live.md#partner-document-apis). |
| 403 | `insufficient_scope` | Missing `policy:read` or `policy:write`. |
| 429 | `rate_limit_exceeded` | More than 60 calls a minute with one key. |


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