Overview
The Global Constants node is designed to inject a set of predefined global constants into your n8n workflow. It retrieves these constants from secure credentials and makes them available as part of the data flowing through the workflow. This node is useful when you need to reference static values (such as configuration settings, API endpoints, or other shared parameters) across multiple steps in your automation.
Practical examples:
- Centralizing environment-specific variables (e.g., base URLs, tokens) for use throughout a workflow.
- Ensuring that all workflow items have access to the same set of constants without hardcoding them in multiple places.
- Dynamically merging constants into incoming data for downstream processing.
Properties
| Display Name | Type | Description |
|---|---|---|
| Put All Constants in One Key | Boolean | Whether to put all constants in one key or use separate keys for each constant. |
| Constants Key Name | String | The name of the key under which all constants will be grouped (only shown if above is true). |
Property Details
Put All Constants in One Key:
- If enabled (
true), all constants are placed inside a single object with the key specified by "Constants Key Name". - If disabled (
false), each constant is added as a top-level key in the output.
- If enabled (
Constants Key Name:
- Only visible and used if "Put All Constants in One Key" is enabled.
- Specifies the property name under which all constants will be nested (default:
constants).
Output
- The node outputs an array of items, each with a
jsonfield. - The structure of the
jsonfield depends on the "Put All Constants in One Key" setting:
Example Outputs
When "Put All Constants in One Key" is enabled:
{
"constants": {
"CONSTANT_A": "valueA",
"CONSTANT_B": "valueB"
}
}
When "Put All Constants in One Key" is disabled:
{
"CONSTANT_A": "valueA",
"CONSTANT_B": "valueB"
}
- If there is input data, the constants are merged into each item's existing
jsonobject. - If there is no input data, a new item is created containing only the constants.
Dependencies
- Credentials: Requires a credential named
GlobalConstantsApi(or similar, as defined in your n8n instance) that contains the global constants. - No external services are called; the node relies solely on the provided credentials.
- n8n Configuration: Ensure the relevant credentials are configured and accessible to the workflow.
Troubleshooting
Missing Credentials:
- Error: "No credentials found" or similar.
- Solution: Make sure the required Global Constants credentials are set up in n8n and assigned to the node.
- Error: "No credentials found" or similar.
Incorrect Constants Structure:
- If the constants are not appearing as expected, check the "Put All Constants in One Key" setting and ensure the "Constants Key Name" is correctly specified.
Empty Output:
- If the node outputs nothing, verify that the credentials contain the expected constants and that the workflow is triggering the node as intended.