# Check patient name exists

Canonical page: https://docs.ovok.com/slim-apis/patient/check-patient-name-exists

| Method | Path |
| --- | --- |
| `POST` | `/v1/slim/patient/check-name-exists` |

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

Checks whether a Resident ID (the resident's nickname) is already used in your project. Use it to validate the Resident ID field before you create or rename a resident.

**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 `Patient:read` (admins and super admins skip this check).
**Scope:** Residents in the caller's project (from the token).

## Request [#request]

### Body [#body]

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | `object[]` | Yes | The names to check. At least 1 entry. Only the entry with `use: "nickname"` is compared. |
| `name[].use` | `"official"` \| `"nickname"` \| `"maiden"` | Yes | Kind of name. |
| `name[].given` | `string[]` | No | Given names, in order. At least 1 entry when sent. Each entry is a non-empty string. |
| `name[].family` | `string` | No | Family name. Non-empty when sent. |
| `excludePatientId` | `string` | No | Id of a resident to ignore, usually the resident you are editing. |

## Behaviour [#behaviour]

- Read-only.
- Only the `name` entry with `use: "nickname"` is compared. Official and maiden names are ignored. Without a nickname entry the answer is `exists: false`.
- A match needs the same `given` tokens in the same order and the same `family` (or no `family` on both sides). Tokens are trimmed and compared case-insensitively.
- When you edit an existing resident, pass their id as `excludePatientId` so their own record does not count as a match.
- The create and update routes run the same check, so a `true` here means those requests would be refused with a 422.

## Example [#example]

```bash
curl -X POST 'https://api.sandbox.ovok.com/v1/slim/patient/check-name-exists' \
  -H "Authorization: Bearer ${OVOK_TOKEN}" \
  -H 'Content-Type: application/json' \
  -d '{
    "name": [{ "use": "nickname", "given": ["demo-resident"] }],
    "excludePatientId": "3f1c2b7e-8d4a-4c1e-9b2f-6a7d5e4c3b21"
  }'
```

| Field | Type | Meaning |
| --- | --- | --- |
| `exists` | boolean | `true` when a matching Resident ID is already used in the project. |

## Successful response [#successful-response]

`201` — Result of the name existence check.

```json
{ "exists": false }
```

| Field | Type | Description |
| --- | --- | --- |
| `exists` | `boolean` | `true` when another resident in the project already has this Resident ID. |

## Errors [#errors]

| Status | Meaning |
| --- | --- |
| [`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 `Patient:read`. |
| [`422`](/errors/validation-failed) | The body fails validation. |
