Access policies

Create an access policy

  • Sandbox: available
  • On your own host? Choose https://{host} in the playground.
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

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.

Authorization

bearer
headerAuthorizationBearer <JWT>

Request Body

application/json
  1. body
name*string

Unique in the project: child copies follow by name.

Match^[^,\\]+$
Length1 <= length <= 255
rules*array<>
Itemsitems <= 300

Response Body

The policy; Location names it.

application/json
  1. response
id*string
reference*string
name*string
versionId*string

Send it back as If-Match: W/"<versionId>" to change the policy.

managed*boolean

Ovok provisions the policy (a Signals role), so it is read-only.

copyOf*string

The parent project's policy this one copies; read-only here.

rules*array<>

Each row with what it grants spelled out in interaction.

Example Request
curl -X POST 'https://api.sandbox.ovok.com/v1/access-policies' \  -H 'Content-Type: application/json' \  -d '{  "name": "string",  "rules": [    {      "resourceType": "string",      "interaction": [        "read"      ]    }  ]}'
Example Response
{  "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).