Skip to main content

REST Server

The REST Server plug-in provides the technical foundation for the REST endpoints that the OPC Router itself publishes externally. These endpoints are then used within a flow via the REST Trigger.

The mapping between the plug-in configuration and the trigger is described on the page REST in the OPC Router: Structure and Responsibilities.

Dialog Overview​

REST Server

The screenshot shows the general settings for deploying custom REST endpoints, such as port, route prefix, authentication, SSL, and the provision of OpenAPI data.

REST Server Configuration​

PropertyDescription
NameAny name under which the REST server appears in the flow configuration.
Provide API via Web Management endpointIf this option is enabled, the OPC router’s Web Management endpoint is used to provide the API in addition to the configured port. For more information, see the section “Deployment via the Web Management Endpoint.”
PortPort on which the API should be accessible. For more information, see the section “Port and Accessibility.”
Route prefixPath prefix that must be specified after the host address and port to access the API.
Send Error as ResponseIf this option is enabled, the appropriate HTTP status code is returned as a response in case of errors.
Always send status codeSends the HTTP status code even for successful responses.
AuthenticationSpecifies how external clients must authenticate with the REST server.
UsernameUsername for logging in using the Basic authentication method.
PasswordPassword for logging in using the Basic authentication method.
Enable SSLEnables a TLS-secured connection.
SSL CertificateCertificate to be used for the secure connection. Click the plus sign to add a certificate, and the trash can icon to remove it. Click the eye icon to view the properties of the selected certificate. General information on importing and creating certificates can be found on the Certificate Management and Create SSL Certificates pages.
Provide OpenAPI DataEnables the provision of the OpenAPI description for the configured endpoints as a JSON file. The following OpenAPI properties are subordinate to this option.
API URLDisplays the full URL of the exposed REST endpoint. This property is only available if “OpenAPI provide data” is enabled.
OpenAPI Data URLDisplays the URL to the JSON description of the OpenAPI data. This property is only available if “OpenAPI provide data” is enabled.
OpenAPI Data InterfaceDisplays the URL to the web interface where the provided OpenAPI data can be viewed or tested. This property is only available if “OpenAPI provide data” is enabled.

The OpenAPI properties are organized hierarchically: Only when “OpenAPI provide data” is enabled do “API URL”,” “OpenAPI data URL”,” and “OpenAPI data interface” become available.

Provisioning via the Web Management Endpoint​

If “Provide API via web management endpoint.” is enabled, the path segment /services/{Plug-in-Name} is inserted between the host address with port and the configured route prefix.

If the OPC Router is running as a Docker instance, this allows the API to be accessible without an additional exposed REST port, provided that the Web Management Endpoint itself is already accessible.

note

If you use this feature with Siemens Industrial Edge, the client address must be used without /opcrouter. For example, if https://172.20.10.220/opcrouter/services/MyPlugin/api is displayed in the plugin, the client must use https://172.20.10.220/services/MyPlugin/api.

Example:

  • Host address and port of the web management endpoint: http://server:8080
  • Additional path segment: /services/MyPlugin
  • Route prefix: /api
  • Result: http://server:8080/services/MyPlugin/api

Port and Accessibility​

When configuring the port, note the following:

  • The port must not already be in use elsewhere.
  • If clients are to access the server from other devices, the port must be opened in the firewall.
  • If the OPC Router is running as a Docker instance, this port must also be exposed to the outside world within the container.
  • If “Provide API via web management endpoint.” is enabled instead, there is no need to explicitly open the REST port, provided that the web management endpoint is accessible.

Route Prefix​

The route prefix determines the path portion following the host address and port.

Example:

  • Host address and port: http://server:50117
  • Route prefix: /api
  • Result: http://server:50117/api

Authentication​

The following options are available for the “Authentication” property:

OptionDescription
AnonymousThe endpoint is accessible without login.
BasicAccess is granted via username and password.
Block APIThe REST endpoint is not made available for external calls.

Certificates​

For general information on importing and creating certificates, see the pages Certificate Management and Creating SSL Certificates.

MCP Server Configuration​

Using the Model Context Protocol (MCP), the provided REST endpoints can also be published as tools for AI applications. You can then specify which endpoints are offered as MCP tools in the REST Trigger.

MCP Server tab

PropertyDescription
Enable MCPEnables MCP functionality for the REST server.
AuthenticationSpecifies whether no authentication (None) or Bearer token authentication (Bearer) is used for the MCP endpoint.
Route PrefixPath prefix of the MCP endpoint.
Bearer TokenToken for authentication when Bearer token authentication is used.

The “Bearer Token” field is used when “Bearer” is selected for “Authentication”.”

The MCP link consists of the host address and port of the REST server, as well as the route prefix from the MCP Server tab—not to be confused with the route prefix specific to the REST Server tab.

Example:

  • Host address and port: http://server:50117
  • Route prefix: /mcp
  • Result: http://server:50117/mcp

MCP clients access this link directly. The REST server implements the MCP transport protocol “Streamable HTTP,” in which a single endpoint both receives requests and returns responses. If <Ui>Authentifizierung</Ui> is set to Bearer, clients must send the Bearer token in the Authorization: Bearer <Token> header for authentication.

Advanced Configuration​

On this tab, you can configure CORS (Cross-Origin Resource Sharing), among other settings. CORS uses HTTP response headers to control whether a web browser allows access to the REST endpoint from a different origin.

Advanced Tab

PropertyDescription
Legacy ModeEnables a compatibility mode for the REST server deployment. This provides backward compatibility with older OPC Router versions. Enable this only if instructed by Support or if problems persist after updating from an older OPC Router version.
Use CORS PolicyEnables the configuration of CORS response headers for the REST endpoint.
Access-Control-Allow-OriginSpecifies which origin is returned in the Access-Control-Allow-Origin header.
Access-Control-Allow-MethodsSpecifies which HTTP methods are allowed in the Access-Control-Allow-Methods header.
Access-Control-Allow-HeadersSpecifies which HTTP headers are allowed in the Access-Control-Allow-Headers header.

The fields for the CORS headers are displayed when “Use Cors Policy” is enabled.