Accessing Endpoint Configuration from Groovy
Overview
1Gateway exposes endpoint configuration values to Groovy scripts through the substitution mechanism.
This allows Groovy-based plugins to dynamically resolve endpoint URLs, credentials, and other configuration properties without hardcoding environment-specific values.
The substitution mechanism can be used to access endpoint configuration as well as other configuration variables available in 1Gateway.
Using substitution.substitute() with Endpoints
Endpoint values are accessed by referencing the endpoint name and, optionally, a specific property.
Supported Substitution Keys
substitution.substitute("endpoint:url")
substitution.substitute("endpoint:user")
substitution.substitute("endpoint:password")
Example
Given an endpoint configuration named 1gateway-dev, there are multiple ways to access its values from Groovy.

Accessing the Endpoint Properties as a JSON Object
You can retrieve the full endpoint configuration as a JSON string and parse it into a Groovy map:
def json = substitution.substitute("endpoint:1gateway-dev")
def endpoint = parser.asMap(json)
println endpoint.urlEndpoint
println endpoint.mandant
This approach is useful when you want to work with the full endpoint configuration in a structured way.
Accessing the Endpoint Properties Individually
You can also retrieve individual endpoint properties directly using the property path syntax:
def url = substitution.substitute("endpoint:1gateway-dev/urlEndpoint")
def user = substitution.substitute("endpoint:1gateway-dev/user")
def password = substitution.substitute("endpoint:1gateway-dev/password")
println "Endpoint URL: ${url}"
Using Endpoint Credentials in REST Calls
When making REST calls from Groovy, authentication can be configured using the endpoint name directly:
option.rest.useAuth("erp")
Credential Resolution Logic
When you provide an endpoint name (for example via option.rest.useAuth("erp")), 1Gateway resolves credentials using the following logic:
- 1Gateway first checks whether a credentials profile exists with the same name.
- If no credentials profile is found, 1Gateway falls back to the credentials configured directly on the endpoint.
This allows endpoint-based authentication without explicitly retrieving or handling credentials in Groovy scripts.
Best Practices
- Use endpoint configuration instead of hardcoded URLs or credentials.
- Prefer
option.rest.useAuth(endpoint)for REST authentication. - Access endpoint configuration via substitution to ensure portability across environments.