Core Documentation
TypeScript SDK

TypeScript SDK

The Oystehr TypeScript SDK makes it easy to work with Oystehr's APIs (opens in a new tab) from TypeScript.

While you can always make raw HTTP requests to Oystehr's APIs from any language, this SDK provides several advantages for developers:

  • TypeScript types — The SDK provides complete typing for requests and responses across all of Oystehr's APIs. This gives you helpful autocomplete and build-time type checking.
  • Convenience functions — The SDK provides convenience functions for doing common tasks like uploading and downloading files with Z3.



Our SDK is available as an npm package (opens in a new tab).

npm install @zapehr/sdk


  1. Import the SDK.
  2. Initialize the SDK with a Oystehr access token. (Learn how to get an access token).
  3. Invoke any of Oystehr's APIs with a function call.


Create a Patient resource in FHIR with the SDK
import zapehr from '@zapehr/sdk'
// Initialize the SDK with a Oystehr access token
  ZAPEHR_ACCESS_TOKEN: "<your_access_token>",
// Create a Patient FHIR resource
const patient = await zapehr.fhir.create<Patient>({
  resourceType: 'Patient',
  active: true,
  name: [
      given: ['Jon'],
      family: 'Snow',
  address: [
      use: 'home',
      type: 'physical',
      text: 'Winterfell',

Convenience Functions


Under the hood, uploading and downloading files with Z3 is a two-step process:

  1. Create a presigned URL to upload or download the file (API Reference (opens in a new tab)).
  2. Upload or download the file using the presigned URL.

The SDK provides convenience functions which combine these steps into a single function call to make it a one-liner:

Upload a file to Z3 with the SDK
    await zapehr.project.z3.uploadFile(
      { bucketName: 'your-bucket-name', 'objectPath+': 'path/to/your-filename', file: someFileBlob }

In the example, someFileBlob is a Blob (opens in a new tab).

Download a file from Z3 with the SDK
    const downloadedBuffer = await zapehr.project.z3.downloadFile(
      { bucketName: 'your-bucket-name', 'objectPath+': 'path/to/your-filename' }


Uploading code for your Zambda Functions is very similar to uploading a file with Z3. After creating your .zip archive, use the uploadFile() function to deploy your code.

Deploy a code zip to a Zambda Function
  const zambdaFile = fs.readFileSync('build/');
  await zapehr.project.zambda.uploadFile({
    id: yourZambdaId,
    file: new Blob([zambdaFile]),