Files and documents
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. These routes are not versioned: the paths start with /document, with no /v1. 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
- Create the document.
POST /documentwith the file name and type. The answer holds the documentidanduploadOptions: an uploadurland the formfields. - Upload the file. Send a
multipart/form-dataPOSTtouploadOptions.urlwith every entry ofuploadOptions.fieldsas a form field, then the file as the last part, namedfile. The form is valid for 10 minutes and accepts files up to 5 GB. - Use the document. List documents with
GET /document. Download one withGET /document/:id, which answers with a redirect to a signed file URL. For a public document, anyone with itspublicTokencan download it withGET /document/public/:token. - Change it.
PATCH /document/:idrenames it, changes its type, or makes it public or private.POST /document/:idreplaces the file and returns a new upload form.DELETE /document/:idremoves 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… | Route | Page |
|---|---|---|
| Add a new file | POST /document, then upload to uploadOptions.url | Create document |
| Put a new file in an existing document | POST /document/:id, then upload | Replace document file |
| List the documents I can read | GET /document | Search documents |
| Download a file as a signed-in user | GET /document/:id | Download document |
| Embed or share a file without a token | GET /document/public/:token | Download public document |
| Rename a file, change its type, or make it public or private | PATCH /document/:id | Update document metadata |
| Remove a file | DELETE /document/:id | Delete document |
Routes
POST /document— Create documentPOST /document/:id— Replace document fileGET /document— Search documentsGET /document/:id— Download documentGET /document/public/:token— Download public documentPATCH /document/:id— Update document metadataDELETE /document/:id— Delete document
What the AccessPolicy must allow
| Route | Needs |
|---|---|
POST /document | Binary:create and DocumentReference:create |
POST /document/:id | DocumentReference:read and DocumentReference:update |
GET /document | DocumentReference:search and DocumentReference:read |
GET /document/:id | DocumentReference:read |
GET /document/public/:token | Nothing. No bearer token is needed. |
PATCH /document/:id | DocumentReference:read and DocumentReference:update |
DELETE /document/:id | DocumentReference: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 400. 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 400, not 422. message is then a list of strings of the form path: message, for example fileName: Required. 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.