# How to use Internal API with and without a VPN

On the Digibee Integration Platform, you can publish your pipelines for internal or external use:

* **Internal use:** The API is available only within your cluster’s internal gateway, allowing access by other pipelines in your realm or through a VPN.
* **External use:** The API is accessible over the internet, enabling interaction with external applications and services.

You can use the following triggers to configure your API: [**HTTP**](https://app.gitbook.com/s/EKM2LD3uNAckQgy1OUyZ/triggers/web-protocols/http), [**HTTP File**](https://app.gitbook.com/s/EKM2LD3uNAckQgy1OUyZ/triggers/web-protocols/http-file), and [**REST**](https://app.gitbook.com/s/EKM2LD3uNAckQgy1OUyZ/triggers/web-protocols/rest)**.**

Follow the steps below to enable and use an **Internal API**.

{% stepper %}
{% step %}

## **Request Internal API access**

To enable the Internal API in your realm, contact [Digibee Customer Support](https://docs.digibee.com/documentation/troubleshooting/help-and-faq/support).

The team will configure:

* **Hostname:** `{{realmname}}.digibee.internal`
* **Ports:**
  * `7070` (Production)
  * `9090` (Test)

{% hint style="info" %}
On the **Dedicated SaaS** model, the ports may have **different values**.
{% endhint %}
{% endstep %}

{% step %}

## **Set up a pipeline for Internal API access**

To configure the pipeline to use the Internal API:

1. Choose a supported trigger: [**HTTP**](https://app.gitbook.com/s/EKM2LD3uNAckQgy1OUyZ/triggers/web-protocols/http), [**HTTP File**](https://app.gitbook.com/s/EKM2LD3uNAckQgy1OUyZ/triggers/web-protocols/http-file), and [**REST**](https://app.gitbook.com/s/EKM2LD3uNAckQgy1OUyZ/triggers/web-protocols/rest)**.**
2. Enable **Internal API** and **API Key** in the trigger configuration form.
3. Assign the pipeline to an [API Key](https://app.gitbook.com/s/jvO5S91EQURCEhbZOuuZ/platform-administration/settings/api-keys-consumers).
4. [Deploy the pipeline](https://app.gitbook.com/s/jvO5S91EQURCEhbZOuuZ/development-cycle/overview/deployment/deployments) on the **Run** page.
5. Open the Deployment details card for the pipeline and expand the trigger configuration section to find the endpoint in the following format:

{% code overflow="wrap" %}

```
https://{replace-with-Digibee-internal-host}/pipeline/realm/v1/{{pipeline-name}}
```

{% endcode %}
{% endstep %}

{% step %}

## **Consume the endpoint**

Once the pipeline is deployed and the endpoint is available, you can consume it in two ways:

1. **Using a** [**VPN**](https://app.gitbook.com/s/jvO5S91EQURCEhbZOuuZ/connectivity-management/vpn)
2. **Locally from other pipelines (without a VPN)**

{% hint style="warning" %}
By default, it’s **not** possible to consume the endpoint locally from other pipelines (without a VPN) on the **Dedicated SaaS** model.
{% endhint %}

### **Consuming the endpoint using a VPN**

To successfully consume an endpoint via a VPN, ensure that **Phase 2 of Digibee** is properly configured in your network. The service making the request must be within the IP range mapped to Digibee’s Phase 2.

<figure><img src="https://content.gitbook.com/content/boT4qPJIk6PZotrxlJWL/blobs/okciMeX0G4x9SiQWZMaM/4.png" alt=""><figcaption></figcaption></figure>

#### **Configuration requirements**

Before making a request, confirm that:

* **Phase 2 of Digibee** is declared in your network.
* The API consumer’s IP range is mapped in Digibee’s Phase 2.

#### **Calling the endpoint**

Once Phase 2 mappings are configured, use the following format to call the endpoint:

```
http://10.255.0.2:9090/pipeline/dgb-support-lab/v1/test-api-internal
```

{% hint style="danger" %}
Use **HTTP** instead of HTTPS.
{% endhint %}

#### **Troubleshooting checklist**

If you find issues while making the request, verify the following:

* The **Internal API** is available in your realm.
* Your **Phase 2 mapping** is correctly configured in Digibee.
* **Phase 2 of Digibee** is declared in your network.
* You are using **HTTP** instead of HTTPS.

### **Consuming the endpoint locally (without VPN)**

{% hint style="warning" %}
By default, it’s **not** possible to consume the endpoint locally from other pipelines (without a VPN) on the **Dedicated SaaS** model.
{% endhint %}

To consume this endpoint locally, replace this part: `{replace with Digibee internal host}`\
with the appropriate internal host and port. See this example:

* **Host:** `dgb-support-lab.digibee.internal`
* **Port (Test):** `9090`

The following URL will be used to access the endpoint:

{% code overflow="wrap" %}

```
http://dgb-support-lab.digibee.internal:9090/pipeline/dgb-support-lab/v1/test-api-internal
```

{% endcode %}

{% hint style="danger" %}
Use **HTTP** instead of HTTPS.
{% endhint %}

#### **Using an Internal API in a pipeline**

You can trigger this endpoint within a pipeline using one of the following connectors:

* [**REST**](https://app.gitbook.com/s/EKM2LD3uNAckQgy1OUyZ/connectors/web-protocols/rest-v2)
* [**Pipeline Executor**](https://app.gitbook.com/s/EKM2LD3uNAckQgy1OUyZ/connectors/tools/pipeline-executor)

Additionally, an external application can access it if a VPN connection is established with your realm.

**Example: Using the REST connector**

Here's an example of how to configure the **REST** connector to call this internal API:

**Connector’s configuration:**

<figure><img src="https://content.gitbook.com/content/boT4qPJIk6PZotrxlJWL/blobs/BwWiZuQMnEJ3uk8Zwlak/REST%20V2%20example.png" alt=""><figcaption></figcaption></figure>

**Output:**

```json
{
  "status": 200,
  "statusMessage": "OK",
  "body": {
    "success": true
  },
  "headers": {
    "Access-Control-Allow-Origin": "*",
    "Access-Control-Expose-Headers": "Authorization",
    "Connection": "keep-alive",
    "Content-Type": "application/json",
    "X-Digibee-Trace-Id": "d8e14b0b-fade-425d-b1f0-ed1cef66c8df"
  }
}
```

{% endstep %}
{% endstepper %}
