Using Your Own API Gateway

Creation date: 02/12/2024 14:39    Updated: 16/12/2024 07:13
The ThinkAutomation API Gateway Server allows inbound public HTTPS API requests and any public Web Form or Web Chat form responses to be sent to your local ThinkAutomation server. The gateway acts as a secure tunnel between public web requests and your ThinkAutomation Server. The Gateway listens for web requests (HTTPS port 443) and forwards valid requests to your ThinkAutomation Server. Your ThinkAutomation server makes an outbound connection to the Gateway using a secure websocket connection on port 80.

By default, ThinkAutomation connects to 'api.thinkautomation.com', which is a shared API Gateway Server hosted by Parker Software. This works out-of-the-box and requires no setup but provides a restricted number of messages per day (5000 for the Pro edition, 1000 for Standard). 

With the ThinkAutomation Professional Edition, you can also host your own instance of the ThinkAutomation API Gateway Server which has no messages per day restrictions. For this you will need a separate Windows Server with a public IP address (or a virtual machine hosted in Microsoft Azure or any other cloud based provider) with its own DNS name and trusted SSL certificate. 

Configuration Steps


Important: Firstly, ensure you have the latest ThinkAutomation Server installed. You should not use an old ThinkAutomation Server with the latest Gateway.

  1. Register a DNS name (eg: api.mycompany.com). Add a DNS 'a' record to point this DNS name to the public IP address of your ThinkAutomation Gateway computer.
  2. Obtain an SSL certificate with a common name matching the DNS name. Import this certificate into the Windows Certificate store, or save it as a PFX file.
  3. Download and install the ThinkAutomationGateway.exe setup (Parker Software can provide the download link). No other software is required for the Gateway to work (IIS should not be enabled). Ports 443 and 80 need to be open on any firewalls used or connected to this computer. Once the Gateway is installed, run the ThinkAutomation Gateway Configuration application to setup the gateway. 
  4. In the HTTP External Address entry, enter the public DNS name (for example: api.mycompany.com). Click the Select Cert button to select the SSL certificate that is registered to the public DNS name. This can be a certificate selected from the certificate store, or you can select a path to a PFX file.
  5. Click Save to save the settings.
  6. Click the Install button to install the Gateway Service, then click Start to start it. If the service was already installed, you need to stop and restart the service after any changes are made.
  7. Now, go to your ThinkAutomation Server computer and start the Studio. Select File - Server Settings - Web API tab.
  8. Enable the Use Own API Gateway Server option.
  9. Change the Public Address and the Gateway Server Host to the public DNS name.
  10. Change the Gateway Server Host entry to the local IP address or host name of the computer running the Gateway Server. 
  11. The Gateway Server Instances Port must match the Instances Connect On Port entry in the Gateway Configuration - ThinkAutomation Instance Connections tab. This defaults to port 80, but can be changed to any available port (ensure this is open on the Gateway computer firewall).
  12. Save the server settings.
  13. Your ThinkAutomation Server should now connect to the new Gateway (it may take a minute or so for your ThinkAutomation Server to reconnect to the new gateway - this can be speeded up by simply restarting your ThinkAutomation Server). You can verify this by checking the ThinkAutomation Server log. All your public ThinkAutomation Message Source API and webform URL's will now point to the new DNS name.
  14. Verify the new endpoints work by making a public API request, or by viewing a webform via it's public address.

Multiple ThinkAutomation Server's can use the same Gateway Server. You can lock down which ThinkAutomation Server's can connect to your gateway by enabling the Instance Connections Must Be In Whitelist option, and then specifying your ThinkAutomation Server's public address in the whitelist.

Viewing The Gateway Status Page


You can view the gateway status page using a browser at https:{gatewaydns}/index.htm (eg: https://api.mycompany.com/index.htm).  This page will only be accessible on localhost, or via any IP address in the Gateway Whitelist. If you add IP's to the Gateway Whitelist you will need to restart the Gateway Service for the change to take effect.