Public Zambdas

We will cover what public Zambdas are and when you should use them. If you are interested in creating your own public Zambda, we recommend reading the Writing Zambdas guide.

Overview of Public Zambdas

As the name implies, Public Zambdas are accessible to anyone. They do not require any authentication to use. Use public Zambdas when you wish to intentionally expose a Zambda to the public.

Example use cases:

  • getting a list of available slots for scheduling an appointment
  • returning a list of recent blog posts on your website
  • form submissions that don't require authentication
  • signing up for an appointment on a website that doesn't require authentication

Creating and Executing a Public Zambda

If you do not already have a Zambda, you can create one by following the Writing Zambdas guide.

Navigate to https://console.zapehr.com/zambdas (opens in a new tab) and select your Zambda. Edit it to use trigger method http_open and save your changes:


Create a Zambda

You can use the ZapEHR SDK or the curl command to test your Zambda. You will need to replace the following values:

You don't need an access token since this is a public Zambda.

Execute a public Zambda with the SDK:

  const zambda = await zapehr.project.zambda.executePublic(
    {
      id: 'your_zambda_id',
      name: 'ZapEHR User',
      // you can submit additional data to your Zambda here
    }
  );

If you try modifying your project ID and you will see that the request fails with an Unauthorized error.

💡
When executing a public Zambda by name, you must always provide a project ID in the x-zapehr-project-id header.