# Set a patient vital threshold

Canonical page: https://docs.ovok.com/slim-apis/threshold/set-a-patient-vital-threshold

| Method | Path |
| --- | --- |
| `PUT` | `/v1/slim/threshold/patient/:patientId/vitals/:code` |

[Authentication](/authentication) · [Access policies](/access-policies)

Sets one resident's threshold for a single vital code, replacing any threshold already held for that code. The threshold is written to Signals, which evaluates it. Ovok stores and forwards the limits and never evaluates readings.

**Auth:** Bearer token. The caller must be a practitioner, an admin, a super admin, or hold the "System Owner" access policy. The access policy must grant `Goal:update` (admins and super admins skip this check).
**Scope:** The resident must be in the caller's project (from the token) or one of its sub-projects; otherwise 404. The threshold is filed under the resident's own project.

## Request [#request]

### Path parameters [#path-parameters]

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `patientId` | `string (uuid)` | Yes | The resident's Patient id. |
| `code` | `string` | Yes | The vital code, as the device sends it (for example `8480-6`). 1 to 64 characters from letters, digits, `.`, `_` and `-`. Codes the threshold routes own answer 400. |

### Body [#body]

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `min` | `number \| null` | Yes | Alert when a reading falls below this value. `null` for no lower bound. Must be finite. |
| `max` | `number \| null` | Yes | Alert when a reading rises above this value. `null` for no upper bound. Must be finite. |

At least one of `min` and `max` must be a number. When both are numbers, `min` must be less than `max`.

## Behaviour [#behaviour]

- The body needs `min`, `max`, or both; a missing bound is `null`. When both are set, `min` must be less than `max`. To remove a threshold, use [Remove a patient vital threshold](/slim-apis/threshold/remove-a-patient-vital-threshold).
- `code` must be 1 to 64 characters from letters, digits, `.`, `_` and `-`.
- Codes the threshold routes own (for example SpO₂ and pulse rate) are refused with 400. Set those on [`PUT /v2/slim/threshold/patient/{patientId}`](/slim-apis/threshold/update-patient-threshold-v2).
- The write waits for Signals to confirm. A 2xx means Signals holds the threshold; a 502 means it does not, so nothing changed and the call is safe to repeat.
- The response is the saved `code`, `min` and `max`.

## Example [#example]

```bash
curl -X PUT 'https://api.sandbox.ovok.com/v1/slim/threshold/patient/3f1c2b7e-8d4a-4c1e-9b2f-6a7d5e4c3b21/vitals/8480-6' \
  -H "Authorization: Bearer ${OVOK_TOKEN}" \
  -H 'Content-Type: application/json' \
  -d '{ "min": 90, "max": null }'
```

## Successful response [#successful-response]

`200` — Signals confirmed the threshold.

```json
{
  "code": "8480-6",
  "min": 90,
  "max": null
}
```

| Field | Type | Description |
| --- | --- | --- |
| `code` | `string` | The vital code the threshold applies to. |
| `min` | `number \| null` | The lower bound as saved, or `null` for none. |
| `max` | `number \| null` | The upper bound as saved, or `null` for none. |

## Errors [#errors]

| Status | Meaning |
| --- | --- |
| [`400`](/errors/malformed-request) | `code` is not a vital code, or it is a code the `/v1/slim/threshold` and `/v2/slim/threshold` routes own. |
| [`401`](/errors/unauthenticated) | Bearer token is missing, invalid or expired. |
| [`403`](/errors/forbidden) | You are not a practitioner, admin or System Owner, or you lack `Goal:update`. |
| [`404`](/errors/not-found) | No patient with this id exists, or the patient is outside your project and its sub-projects or carries no project. |
| [`422`](/errors/validation-failed) | The body fails validation: `min` or `max` is missing or not a finite number or `null`, both are `null`, or `min` is not less than `max`. |
| [`502`](/errors/upstream-error) | Signals did not confirm the threshold. Nothing changed; send it again. |
| [`503`](/errors/service-unavailable) | The access policy could not be read right now. Retry. |
