# Configuration with a custom server

The Efento Gateway sends data to external systems using a **REST API** over **HTTP or HTTPS**, depending on your configuration. Data is delivered to the selected endpoints in JSON format. The full API documentation is available [here](/efento-gateways/integration/api-documentation.md).

To configure the gateway to work with your custom server, follow the steps below:

{% stepper %}
{% step %}

### **Select “Custom settings” as the connection type**

In the **Settings > Server > Connection to server** field, choose **Custom settings**. This enables manual configuration of server parameters instead of using Efento Cloud defaults.

<figure><img src="/files/UsdcRFSZDetch5V5tc95" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### **Configure the server address and port**

Enter the **server URL or IP address** and the **port number** your application uses to receive data. Ensure that the server is accessible from the network the gateway is connected to.

<figure><img src="/files/vJSahOqbmIsTv3kMJ9Ca" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### **Enable or disable TLS**

Choose whether the communication should use **TLS encryption**.

{% hint style="info" %}
We strongly recommend **enabling TLS** to ensure secure, encrypted data transmission and protect your infrastructure from unauthorized access. If required, you can add [custom CA certificates](/efento-gateways/ethernet-gateway/other-settings.md#custom-ca-certificates).
{% endhint %}
{% endstep %}

{% step %}

### **Enable measurements buffering**

Set the toggle next to **Synchronize with server** to **ON**.\
When enabled, the gateway will **buffer logger measurements in its internal memory** and **automatically resend all missing data** to the server after a temporary connection loss. This ensures continuity of data even when the network or server is unavailable for a period of time.
{% endstep %}

{% step %}

### **Optionally configure authentication and custom endpoint**

* You may enter a value in the **Token** field. This value will be included in the HTTP headers of **every message** sent by the gateway, allowing you to implement simple authentication or routing logic on your server.
* Additionally, you can **optionally set a custom endpoint** (path) where the gateway should send measurement and heartbeat messages, if your server does not use the default API paths.
  {% endstep %}
  {% endstepper %}

## Optional configuration parameters

### Heartbeat

The Efento Gateway can send **heartbeat messages** to a user-defined endpoint at regular intervals. These messages allow the server to monitor the gateway’s status, including whether it is online, its uptime, and the number of loggers within range.

<figure><img src="/files/XMjEg9T5tSOM8aNEUqZZ" alt=""><figcaption></figcaption></figure>

To enable heartbeat messages:

1. Toggle the switch next to **“Send heartbeat messages”** to **ON**.
2. Specify the **endpoint** where the messages should be sent. By default the heart beat messages are sent to **/api/v2/gateways/heartbeat**.
3. Set the **time interval** (in minutes) for sending the heartbeat messages.

The structure and details of the heartbeat message payload are described in the [**API Documentation**](/efento-gateways/integration/api-documentation.md#heartbeat) section of this manual.

### Custom HTTP  headers

By default, the Efento Gateway includes the value from the **“Token”** field in the HTTP "X-Api-Token" header. The default headers are:

```http
Content-Type: application/json
charset=UTF-8
X-Api-Token: <value of the “Token” field>
```

If needed, you can configure the gateway to use **custom headers that will overwrite the default "X-Api-Token" header**. To do this, enable the **“Custom headers”** toggle and add the desired header names and values. You can define **up to ten custom headers**, which will be sent in the same order as they appear in the list. The headers **“Content-Type”** and **“charset”** are always included automatically.

<figure><img src="/files/TvATHoblDPTDrDub0WPF" alt=""><figcaption></figcaption></figure>

For example, if you add a custom header named **“Token”** with the value **“sdffsWED34sdfFG6wddV3”**, the gateway will send:

```http
Content-Type: application/json
charset=UTF-8
Token: sdffsWED34sdfFG6wddV3
```

{% hint style="warning" %}
**Important:** The server’s response to the gateway must not contain more than **ten headers**. If the response includes more than ten, the gateway will treat it as invalid and reject the message.
{% endhint %}

## **Hands-on tutorial: Build a server for Efento Gateways**

If you want to see a complete, working example of how to receive measurements from Efento Gateways and store them in a database, make sure to check out our [step-by-step tutorial](/efento-gateways/integration/example-server-application-in-python.md). It includes sample Python code, a simple server application, and instructions for saving incoming data to PostgreSQL - perfect as a starting point for your own integration.


---

# 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://docs.efento.io/efento-gateways/ethernet-gateway/configuration-with-a-custom-server.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.
