# HOW TO: Installation and Exposing the flaik Resort API to an External URL

{% hint style="warning" %}
**API INSTALLER DOWNLOAD**&#x20;

<https://drive.google.com/drive/folders/1eTaE-EB3i-c-frJHNvxv-rjGXq_mzI8f>

PLEASE SEE RELEASE NOTES FOR VERSIONS

{% endhint %}

<figure><img src="/files/rKxFYRbPoZlUbY1TaLVt" alt=""><figcaption><p>Simple Network Architecture using a server in a public subnet</p></figcaption></figure>

***

### Section 1: Overview and Architecture

Below is a simple overview of the system architecture and the steps required to complete the installation.

#### Network Architecture

The flaik Resort API typically runs on a server in a public subnet, allowing it to interact with the POS database while being accessible from the flaik servers.

#### System Requirements

* **Flaik Database**: Microsoft SQL Server 2012 or above.
* **Flaik Resort Service**: Windows 10 or Windows Server 2018 or above.
* **Network Ports**: The flaik service communicates with the POS SQL database over a TCP port (SQL default is 1433).

***

### Section 2: Installation Steps

#### 2.1 Installing the flaik Resort Service (System Admin)

1. **Download the Installer**:\
   Download the flaik Resort Service installer from the link at the top of this page.
2. **Run the Installer**:
   * Follow the prompts in the MSI file.
   * Accept the terms in the License Agreement and allow the service to install.
3. **Complete Installation**:
   * Once the installation is complete, the flaik Resort Service will be installed as a Windows service.

***

#### 2.2 Database Setup (Admin)

1. **Create the flaik Database**:
   * Open SQL Server Management Studio.
   * Create a new database named `flaik` for production or `flaik_staging` for staging.
2. **Create SQL Logins**:
   * Create a SQL user called `FlaikId`, and grant it `db_owner` role for the flaik database. You can use AD or SQL server authentication.
   * Ensure the user has read permissions on the resort’s POS database.
3. **Run SQL Scripts**:
   * Execute any provided SQL scripts to modify the database schema as required.  These are located inside the API's program files.

***

### Section 3: Configuration for Exposing the API to External URLs

#### 3.1 Configure the `appsettings.json` File

After installation, you will need to update the configuration file to set the database connection, API key, and (optionally) enable SSL for secure access.

1. **Locate the File**: Navigate to `C:\Program Files\Flaik Resort Service\appsettings.json`.
2. **Update API Key and Database Connection strings**: Replace placeholders with actual values for production environments default to port 8001, staging defaults to 8002:

   ```json
   "FlaikServiceSettings": {
       "ApiKey": "YourProductionApiKey",  
       "FlaikDatabaseConnectionString": "Server=YourDatabaseServer;Database=FlaikStagingDatabaseHere;Trusted_Connection=True;MultipleActiveResultSets=True;Integrated Security=False;TrustServerCertificate=True;User Id=FlaikId;Password=YourPassword",
       "ResortDatabaseConnectionString": "Server=YourDatabaseServer;Database=YourStagingPOSDatabaseHere;Trusted_Connection=True;MultipleActiveResultSets=True;Integrated Security=False;TrustServerCertificate=True;User Id=FlaikId;Password=YourPassword",
   }
   ```
3. **Update the POS Connection Type**: Replace placeholders with actual values for staging environments using port 8002:

   ```json
   "resortPosSoftwareCode": 0, // 1== RTP|One, 2== Siriusware, 5== Intouch, if in doubt please check
   ```
4. **(Optional) Enable SSL**: If SSL is required, update the `Kestrel` section to enable HTTPS.

   For production:

   ```json
   "Kestrel": {
       "EndPoints": {
         "Https": {
           "Url": "https://*:8001"
         }
       }
   },
   "Certificates": {
       "Default": {
           "Path": "C:\\Path\\To\\YourCertificate.pfx",  
           "Password": "YourCertificatePassword"
       }
   }
   ```

   For staging:

   ```json
   "Kestrel": {
       "EndPoints": {
         "Https": {
           "Url": "https://*:8002"
         }
       }
   },
   "Certificates": {
       "Default": {
           "Path": "C:\\Path\\To\\YourStagingCertificate.pfx",  
           "Password": "YourStagingCertificatePassword"
       }
   }
   ```

***

#### 3.2 Configure Firewall and Ports (Network Admin)

1. **Open Ports**:
   * Ensure that port **8001 (for production)** and **8002 (for staging)** are open for inbound and outbound traffic.
2. **Allow access to flaik Server IPs**:
   * Add the IP addresses provided by flaik to your allow list to allow communication between your resort’s server and the flaik servers.
3. **Configure NAT or Reverse Proxy**:
   * If your server is behind a firewall, set up Network Address Translation (NAT) or a reverse proxy to map external traffic to the server running the flaik Resort Service.
   * Map port 8001 for production and 8002 for staging environments.

***

### Section 4: Testing the flaik Resort API

After installation and configuration, you can test the API to ensure it’s correctly exposed.

1. **Open a Browser**:
   * For production, visit:

     ```
     http://ExternalURLOrIP:8001/api/test
     ```
   * For staging, visit:

     ```
     http://ExternalURLOrIP:8002/api/test
     ```
   * If SSL is enabled, use `https://` instead of `http://`.
2. **Verify Success**:
   * A confirmation page will appear if the API is correctly exposed and operational. Any issues with the database connection or firewall will be shown on this page.

***

### Section 5: Restarting the flaik Resort Service

Any changes to the `appsettings.json` file or firewall configuration require restarting the service.

1. **Open Windows Services**:
   * Go to the **Services** panel in Windows.
2. **Find the flaik Resort Service**:
   * Right-click the service and select **Restart**.

***

### Section 6: Troubleshooting

If you encounter issues:

1. **Verify the flaik Resort Service**:
   * Ensure the service is running and listed in Windows Services.
2. **Check Firewall Configuration**:
   * Ensure that ports 8001 (production) and 8002 (staging) are open and that flaik IPs are whitelisted.
3. **Review SSL Setup** (if applicable):
   * Confirm that the certificate paths and passwords in the `appsettings.json` file are correct.

***


---

# 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://knowledgebase.flaik.com/flaik-knowledge-base/for-it-specialists/1.-resort-pos-integration/resort-services/resort-api-installation.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.
