Create an access policy
- Sandbox: available
- On your own host? Choose https://{host} in the playground.
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
namemust 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:criteriasearches the rule's own resource type;- the only modifiers are
:not,:missingand:present; - there are no chained searches and no
_has; - a Signals row such as
signals_alertshas nocriteria; - every
writeConstraintis a FHIRPath expression.
%parameterssuch as%patientor%organizationare left for each member'saccessentry to fill in.- The answer is
201, andLocationnames the new policy.
Example
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.
bearerAuthorizationBearer <JWT>application/json- body
name*stringUnique in the project: child copies follow by name.
^[^,\\]+$1 <= length <= 255rules*array<>items <= 300The policy; Location names it.
application/json- response
id*stringreference*stringname*stringversionId*stringSend it back as If-Match: W/"<versionId>" to change the policy.
managed*booleanOvok provisions the policy (a Signals role), so it is read-only.
copyOf*stringThe parent project's policy this one copies; read-only here.
rules*array<>Each row with what it grants spelled out in interaction.
curl -X POST 'https://api.sandbox.ovok.com/v1/access-policies' \ -H 'Content-Type: application/json' \ -d '{ "name": "string", "rules": [ { "resourceType": "string", "interaction": [ "read" ] } ]}'{ "id": "string", "reference": "string", "name": "string", "versionId": "string", "managed": true, "copyOf": "string", "rules": [ { "resourceType": "string", "interaction": [ "read" ], "criteria": "string", "hiddenFields": [ "string" ], "readonlyFields": [ "string" ] } ]}List the project's access policies GET
Lists the project's access policies by name, one page at a time. **Scope:** the caller's project (from the token). Medplum reads them on behalf of the caller, so the caller's own rights apply. ## Behaviour - `page` (from 0) and `count` (1–100, default 20) select the page. `hasMore` says whether another page follows. - Each rule names a resource type, `*`, or a Signals row such as `signals_alerts`. Its `interaction` lists what it grants, spelled out even when the stored rule says `readonly`. Any `criteria`, `hiddenFields` and `readonlyFields` are listed with it. - `managed` marks a policy that Ovok provisions, and `copyOf` marks a copy of a parent project's policy. Both are read-only here. ## Example ```bash curl 'https://api.sandbox.ovok.com/v1/access-policies?count=50' -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NjcyNjg4MDAsImV4cCI6MTc2NzI3MjQwMH0.Ql3B_ztDvctlyZ2z0vp4sl3ExXRQGkzmxdmTAqxNzZk' ``` **Who can call it:** a project admin. See [roles](/access-policies#who-can-call-a-route).
Get an access policy GET
Reads one access policy of the project. **Scope:** the caller's project (from the token). ## Behaviour - `versionId` is what `If-Match` takes when you change the policy. - A policy of another project is refused with `POLICY_NOT_IN_PROJECT`, even when Medplum lets the caller read it through a linked project. ## Example ```bash curl 'https://api.sandbox.ovok.com/v1/access-policies/POLICY_ID' -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NjcyNjg4MDAsImV4cCI6MTc2NzI3MjQwMH0.Ql3B_ztDvctlyZ2z0vp4sl3ExXRQGkzmxdmTAqxNzZk' ``` **Who can call it:** a project admin. See [roles](/access-policies#who-can-call-a-route).