# Create an access policy

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

`POST /v1/access-policies`

Creates an access policy. Its copies in child projects follow.

**Scope:** the caller's project (from the token). Medplum writes it on behalf of the caller.

## Behaviour

- `name` must be unique in the project, with no commas or backslashes, because child projects find their copy by name.
- Each rule must be one that Medplum applies as written. Otherwise the request is refused with `422`, and the message says which rule fails and why:
  - `criteria` searches the rule's own resource type;
  - the only modifiers are `:not`, `:missing` and `:present`;
  - there are no chained searches and no `_has`;
  - a Signals row such as `signals_alerts` has no `criteria`;
  - every `writeConstraint` is a FHIRPath expression.
- `%parameters` such as `%patient` or `%organization` are left for each member's `access` entry to fill in.
- The answer is `201`, and `Location` names the new policy.

## Example

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

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