# Replace an access policy

Canonical page: https://docs.ovok.com/api/access-policies/replace-an-access-policy

`PUT /v1/access-policies/{id}`

Replaces an access policy's name and rules, and keeps its other fields. Members who hold the policy gain or lose that access at once. Its copies in child projects follow.

**Scope:** the caller's project (from the token).

## Behaviour

- `If-Match: W/"<versionId>"` is required. A missing header answers `428`, and one that is not an entity tag answers `400`. `If-Match: *` writes over the version Ovok reads just before it. A policy that changed since the version you named answers `412`: read it again and retry.
- Send every rule. A rule you leave out stops applying.
- The rules are checked as on create. Ovok's own policies and copies of a parent project's policies are refused with `POLICY_READ_ONLY`.

## Example

```bash
curl -X PUT 'https://api.sandbox.ovok.com/v1/access-policies/POLICY_ID' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NjcyNjg4MDAsImV4cCI6MTc2NzI3MjQwMH0.Ql3B_ztDvctlyZ2z0vp4sl3ExXRQGkzmxdmTAqxNzZk' \
  -H 'If-Match: W/"3"' \
  -H 'Content-Type: application/json' \
  -d '{"name":"Ward nurse","rules":[{"resourceType":"Patient","interaction":["read","search"],"criteria":"Patient?organization=%organization"}]}'
```

**Who can call it:** a project admin. See [roles](/access-policies#who-can-call-a-route).