Change public resource token
- Sandbox: available
- Staging: available
- Production: unknown
Gives a resource a new public token, so it can be read with GET /public/{token}. If the resource already has a token, the old one is replaced and stops working.
Auth: bearer token of a project admin.
Behaviour
- The resource must be in the caller's project or one of its sub-projects. A resource of any other project, the parent project included, answers
403and is left unchanged; an unknown id answers404. - The token is written to the resource's
meta.extensionwith the URLhttps://api.ovok.com/fhir/StructureDefinition/public-resource-token. Other extensions are kept. - The response is
{ token, resource }: the new token and the updated resource.
Example
curl -X PATCH 'https://api.sandbox.ovok.com/public/DocumentReference/87ea5dfc-8b8e-384d-8489-79496e706390' \ -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NjcyNjg4MDAsImV4cCI6MTc2NzI3MjQwMH0.Ql3B_ztDvctlyZ2z0vp4sl3ExXRQGkzmxdmTAqxNzZk'{ "token": "...", "resource": { "resourceType": "DocumentReference", "id": "87ea5dfc-8b8e-384d-8489-79496e706390", "meta": { "extension": [ { "url": "https://api.ovok.com/fhir/StructureDefinition/public-resource-token", "valueString": "..." } ] }, ... }}resourceType*stringid*stringThe new token and the updated resource.
application/json- response
token*stringThe new public access token. Earlier tokens for the resource stop working.
resource*The FHIR resource as stored in Medplum.
curl -X PATCH 'https://api.sandbox.ovok.com/public/string/string'{ "token": "string", "resource": { "resourceType": "string", "id": "string" }}Get a public resource GET
Reads a FHIR resource through its public token, without a bearer token. Use it to share one resource, such as a form or a document, with people who have no Ovok account. **Auth:** none. The public token in the path is the credential: anyone with it can read the resource. ## Behaviour - A resource becomes public when it gets a token in `meta.extension`, with the URL `https://api.ovok.com/fhir/StructureDefinition/public-resource-token`. Use `PATCH /public/{resourceType}/{id}` to give a resource a token. - The token names exactly one resource. The response is that resource as stored, including its `meta.extension`. - A token stops working when the resource's token is replaced or deleted, or when the resource is deleted. ## Example ```bash curl 'https://api.sandbox.ovok.com/public/example.jwt.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NjcyNjg4MDAsImV4cCI6MTc2NzI3MjQwMH0.Ql3B_ztDvctlyZ2z0vp4sl3ExXRQGkzmxdmTAqxNzZk' ```
Delete public resource token DELETE
Removes the public token from a resource, so it can no longer be read with `GET /public/{token}`. The resource itself is kept. **Auth:** bearer token of a project admin. ## Behaviour - The resource must be in the caller's project or one of its sub-projects. A resource of any other project, the parent project included, answers `403` and is left unchanged; an unknown id answers `404`. - Removes the `meta.extension` entry with the URL `https://api.ovok.com/fhir/StructureDefinition/public-resource-token`. Other extensions are kept. - Calling it on a resource without a token succeeds. - The response is `{ token: null, resource }` with the updated resource. ## Example ```bash curl -X DELETE 'https://api.sandbox.ovok.com/public/DocumentReference/87ea5dfc-8b8e-384d-8489-79496e706390' \ -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NjcyNjg4MDAsImV4cCI6MTc2NzI3MjQwMH0.Ql3B_ztDvctlyZ2z0vp4sl3ExXRQGkzmxdmTAqxNzZk' ```