Files and documents

Store, list, download, replace, update and delete files with the document routes, and choose between the private and public download.

The document routes store files in your project. Each file has a document record, a FHIR DocumentReference, that holds its name, type and author. You list, change and delete files through that record.

Ovok never receives the file bytes. You create the document, Ovok returns a short-lived signed form, and you upload the file straight to file storage with it.

Use https://api.sandbox.ovok.com for the examples. The paths start with /v1/document. The bare /document paths keep working for existing clients. Send a bearer token on every route except the public download. Each route runs with your token, so the project and the AccessPolicy in the token decide what you can reach. See Authentication and Access policies.

How a file moves

  1. Create the document. POST /v1/document with the file name and type. The answer holds the document id and uploadOptions: an upload url and the form fields.
  2. Upload the file. Send a multipart/form-data POST to uploadOptions.url with every entry of uploadOptions.fields as a form field, then the file as the last part, named file. The form is valid for 10 minutes and accepts files up to 5 GB.
  3. Use the document. List documents with GET /v1/document. Download one with GET /v1/document/:id, which answers with a redirect to a signed file URL. For a public document, anyone with its publicToken can download it with GET /v1/document/public/:token.
  4. Change it. PATCH /v1/document/:id renames it, changes its type, or makes it public or private. POST /v1/document/:id replaces the file and returns a new upload form. DELETE /v1/document/:id removes the file and the document.

The document exists as soon as step 1 returns, even if you never complete step 2.

Which route to use

I want to…RoutePage
Add a new filePOST /v1/document, then upload to uploadOptions.urlCreate document
Put a new file in an existing documentPOST /v1/document/:id, then uploadReplace document file
List the documents I can readGET /v1/documentSearch documents
Download a file as a signed-in userGET /v1/document/:idDownload document
Embed or share a file without a tokenGET /v1/document/public/:tokenDownload public document
Rename a file, change its type, or make it public or privatePATCH /v1/document/:idUpdate document metadata
Remove a fileDELETE /v1/document/:idDelete document

Routes

What the AccessPolicy must allow

RouteNeeds
POST /v1/documentBinary:create and DocumentReference:create
POST /v1/document/:idDocumentReference:read and DocumentReference:update
GET /v1/documentDocumentReference:search and DocumentReference:read
GET /v1/document/:idDocumentReference:read
GET /v1/document/public/:tokenNothing. No bearer token is needed.
PATCH /v1/document/:idDocumentReference:read and DocumentReference:update
DELETE /v1/document/:idDocumentReference:read and DocumentReference:delete

A document belongs to the project of the token that created it. A document you cannot see answers 404 or 403, depending on the policy.

Allowed file types

contentType must be one of these values, matched exactly:

  • Images: image/jpeg, image/jpg, image/png, image/gif, image/webp
  • Documents: application/pdf, application/json, application/xml, text/plain, text/csv
  • Video: video/mp4, video/webm
  • Audio: audio/mpeg, audio/wav

Any other value is rejected with 422. The upload form limits the size of the file only. It does not check that the bytes match contentType.

Errors

Validation failures on these routes answer 422. errors then lists each invalid field with its field, a machine code such as FIELD_REQUIRED, and params; message lists the same problems as path and message pairs. Every error body has statusCode, error, timestamp, path, message and requestId.

Deprecated file routes

The older /binary routes are deprecated and still answer. The document routes replace them: they cover uploads through the signed form, and downloads by document id or public token. Use the document routes for new work.

Last updated on

On this page