# Extension and Cloud Function Hosting

Emporix provides a built-in, secure, and scalable hosting environment for custom extensions and cloud functions built on top of the Emporix Management Dashboard. Instead of maintaining your own cloud infrastructure, you can deploy and operate your custom code directly within the Emporix environment — with versioning, rollback, monitoring, and tenant isolation included out of the box.

{% hint style="danger" %}
Hosting of the extensions and cloud functions is not included in standard billing plans and is billed separately on a pay-as-you-go basis. If you're interested in getting access to the feature, contact the [Sales Team](mailto:support@emporix.com).
{% endhint %}

## How it works

The hosting model is project-based. It means that each tenant initializes a single hosting project as a one-time action. The project receives a unique Project ID and acts as the container for all hosted extensions and cloud functions on that tenant.

Emporix supports lazy hosting, which means no pre-configuration is required per tenant before the project is initialized. Once the project is set up, you can add any number of extensions and cloud functions to it.

Each hosted resource follows the same lifecycle:

1. You upload the code either from a GitHub repository or as a `zip` / `tar.gz` archive.
2. The system automatically triggers a build process.
3. A successful build produces a versioned release that is immediately available for use.
4. For extensions hosting — all previous releases are retained, enabling rollback to any earlier version at any time.

## What you can host

### Extensions

Extensions are custom UI add-ons built on the [MD Module Template](https://github.com/emporix/md-module-template), which is based on the module federation concept. A hosted extension integrates directly into the Emporix Management Dashboard and can be registered in one of two ways:

* As a **module** — visible in the **Extensions** section of the Management Dashboard.
* As a **perspective** — accessible with a dedicated URL path in the Dashboard navigation.

Each extension is identified by a unique **Hosting ID**, which becomes part of its hosting URL. Display names can be localized to support multiple languages.

{% hint style="warning" %}
The Emporix infrastructure supports up to 20 extensions per hosting project.
{% endhint %}

### Cloud functions

Cloud functions are serverless units of custom logic that can be triggered by events, Emporix APIs, or other platform processes. Unlike extensions, they are not UI components; they operate in the background and can exposed in the [Partner Library](https://app.gitbook.com/o/z8MNPigQv25NZe33g3AV/s/aAxCFK0JJRlhIPufuXz8/) or consumed through custom API integrations.

Supported runtimes:

* Node.js 24
* Python 3.14

Cloud functions support **environment variables**, which can be defined as key-value pairs and used within the function code to securely decode credentials and configuration data.

Full invocation logs are available in the hosting details of each cloud function, showing when and how it was called and what the outcome was.

**Example cloud function**

Here is the example of a simple cloud function that returns a welcome message and the headers injected by Emporix.

{% file src="<https://3057647601-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbTY7EwZtYYQYC6GOcdTj%2Fuploads%2Fgit-blob-54e59a8e0c157e90aefaf4baa35cce4f8f70b249%2Femporix-cloud-function.zip?alt=media>" %}

## Deployment and versioning

Every deployment — whether an initial upload or an update — triggers a build. The **Build History** tracks all builds with the following details: deployment ID, build ID, status, and timeline.

For extensions, all published versions are retained in the **Releases** panel. Each release shows its version ID, status, and timeline. If a new deployment introduces a regression, you can use the **Rollback** option to revert to any previous release — this results in the release of the selected version.

{% hint style="info" %}
To set up hosting and deploy your first extension or cloud function, refer to the step-by-step instructions in the Management Dashboard: [Hosting](https://developer.emporix.io/ce/management-dashboard/administration/hosting).
{% endhint %}

## Invoking cloud functions

Once you have enabled a cloud function hosting in Emporix, you can call the cloud function within your integration through API.

* **HTTP Methods**

To invoke a cloud function, send an `HTTP` request to the function endpoint. Standard `HTTP` methods are available, so depending on what you need, you can call one of the following: `POST`, `GET`, `PUT`, `DELETE`.

* **Endpoint path**

The root endpoint path:

```
https://api.emporix.io/cloud-functions/{TENANT}/functions/{FUNCTION_ID} 
```

If your cloud function exposes internal endpoints in addition, you can extend the path. For example:

```
https://api.emporix.io/cloud-functions/{TENANT}/functions/{FUNCTION_ID}/products
```

* **Authentication and authorization**

All the requests are routed through the Emporix platform. This means that the platform validates the provided tokens (service, customer, or anonymous). You do not need to implement any additional token validation inside your cloud function.

* **Request headers**

Emporix enriches each request with additional headers that can be used within your function:

| Header                    | Description                                                                                                                                 |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| `emporix-scopes`          | Contains the list of scopes assigned to the requester. Use this header to verify whether the user has permission to trigger specific logic. |
| `emporix-user-id`         | Available for customer tokens. Identifies the customer who triggered the function.                                                          |
| `emporix-token`           | The token used for invocation. It can be reused to call Emporix APIs on behalf of the requester.                                            |
| `emporix-legal-entity-id` | Present when the customer token is associated with a legal entity. Identifies the related legal entity.                                     |

* **Environment variables**

If your cloud function uses environment variables, you can access them in your code as follows:

```
process.env.{ENV_KEY}
```

For example, `process.env.client_id`.

* **Example**

See the example request calling a cloud function:

```bash
curl --location --request POST 'https://api.emporix.io/cloud-functions/{{tenant}}/functions/{{FUNCTION_ID}}' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{EMPORIX_TOKEN}}' \
--data-raw '{
    "name":"John"
}'
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.emporix.io/ce/extensibility-and-integrations/extensibility-cases/extension-hosting.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
