TypeScript icon, indicating that this package has built-in type declarations

2.1.7 • Public • Published

ZapEHR Logo

The complete health-tech developer platform.


Version Compatible Node Versions Install Size Minified Size Downloads / Month License


The ZapEHR SDK is a TypeScript library for interacting with ZapEHR's FHIR and Project APIs.

While you can always make raw HTTP requests to ZapEHR'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 ZapEHR'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.


npm install @zapehr/sdk


  1. Import the SDK.
  2. Initialize the SDK with a ZapEHR access token. (Learn how to get an access token).
  3. Invoke any of ZapEHR's APIs with a function call.
import zapehr from '@zapehr/sdk'

  ZAPEHR_ACCESS_TOKEN: 'your_access_token',

// Create a Patient FHIR resource
const patient = await zapehr.fhir.create({
  resourceType: 'Patient',

// Upload a zambda
try {
  const zambda = await zapehr.project.zambda.create({ name: 'new zambda', triggerMethod: 'http_open' });
  const fileHandle = await fs.open('./path/to/my/zambda.zip')
  const file = new Blob([await fileHandle.readFile()]);
  await zapehr.project.zambda.uploadFile({ id: createZambda.data.id, file, })
} catch (err) {
  // Handle error thrown by ZapEHR or JS in some way

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).
  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:

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

In the example, someFileBlob is a Blob.

    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.

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

Package Sidebar


npm i @zapehr/sdk

Weekly Downloads






Unpacked Size

1.33 MB

Total Files


Last publish


  • cwelchml
  • ibenham
  • shawnlimkq95
  • ozubaidi
  • jsaewitz
  • bholyshevskyi
  • awillinghamml