Add To Response (Fixed)

Overview

Add To Response (Fixed) adds static key-value pairs to the flow's response payload. These values are configured at design time and returned when the flow completes. Use this stage to attach metadata, status flags, or contextual data to the final response.

* This example demonstrates how Add To Response (Fixed) captures the value of a variable when the stage executes. Although counter changes later in the flow, the response keeps the original captured value (count = 0).

Note: The variable names, values, criteria, and configuration used in this example are for demonstration purposes only.

Where to find it: Actions in the stage library.

Configuration

Required Fields

FieldDescriptionExample
Name (Response Key)Key name in response (plain text, no {{}})status, userId, totalAmount
Value (Response Value)Value to include (static text, variable reference, or formula)success, {{userId}}, ={{price}} * 1.1

How values are typed: a value is stored as text unless you either set the field to a number type or start the value with =. There is no automatic number detection, so 42 typed as a normal value is returned as the text "42", not the number 42. To return it as a number, set the field type to number, or use a formula (=42).

Formula syntax: a value starting with = is calculated. Wrap each variable in braces and keep the math outside the braces: ={{price}} * 1.1 is correct; ={{price * 1.1}} does not work.

Using functions in these fields: Any value field above accepts @ functions, for example @NowSecond for the current time or @calc(...) for a calculation. 

See Flows Functions for the full list.

Value Types

Value TypeHandlingExample
Static TextAdded as-issuccess, completed
NumberReturned as a number only if the field is set to number type or the value starts with =; a plain 42 is returned as text=42, =99.99
Variable ReferenceResolved and included (as text){{userId}}, {{timestamp}}
Formula ExpressionEvaluated and result included (math outside the braces)={{price}} * 1.1, ={{total}} / {{count}}

Exit Points

ExitWhen
PassAlways (stage cannot fail)

How It Works

When executed, the stage:

  1. Processes each key-value pair - Iterates through configured Values
  2. Resolves values - Evaluates variables, formulas, or uses static values
  3. Applies the value type - Text by default; a number only when the field is set to number type or the value starts with = (no automatic number detection)
  4. Adds to response - Non-destructively adds fields to response payload

Key behavior: Non-destructive - adds to response without removing existing fields. Multiple Add To Response stages can be used to build response incrementally.

Common Use Cases

1. Add Status and Metadata

Include standard response metadata.

Configuration:

  • status → success
  • timestamp → @NowSecond
  • version → 1.0
  • userId → {{userId}}

Response:

{  "status": "success",  "timestamp": "1704067200000",  "version": "1.0",  "userId": "user_123" }

2. Computed Values in Response

Include calculated values using formulas.

Configuration:

  • totalAmount → {{amount}}
  • taxAmount → ={{amount}} * 0.1
  • netAmount → ={{amount}} * 0.9
  • processed → true

Response:

{  "totalAmount": 100.00,  "taxAmount": 10.00,  "netAmount": 90.00,  "processed": true }

3. Multi-Stage Response Building

Build response incrementally across multiple stages.

Stage 1:

  • result → success
  • processedAt → {{timestamp}}

Stage 2:

  • itemCount → {{count}}
  • averagePrice → ={{totalPrice}} / {{count}}

Result: Final response combines all fields from both stages.

4. Conditional Metadata

Add different fields based on conditions using Route Flow.

Pass branch:

  • status → completed
  • duration → {{elapsed}}
  • success → true

Fail branch:

  • status → failed
  • error → {{errorMessage}}

Key Behaviors

FeatureBehavior
Non-Destructive✓ Adds to response without removing existing fields
Multiple Stages✓ Can use multiple stages to build response incrementally
Value typeText by default; a number only when the field is number type or the value starts with = (no auto number detection)
Formula Support✓ Values starting with = are evaluated (keep math outside the braces: ={{a}} * 2)
Variable Resolution✓ {{variable}} syntax resolved from flow dictionary
Always Succeeds✓ No error exit - stage cannot fail

Best Practices

  • ✓ Organize response fields logically (status first, then data, then metadata)
  • ✓ Use consistent naming conventions (camelCase recommended)
  • ✓ Include traceability information (requestId, timestamp, version)
  • ✓ Use formulas for calculations instead of pre-calculating
  • ✓ Place at end of flow to ensure all variables are available
  • ✓ Use multiple stages to organize different response sections
  • ✓ Test response structure to verify all expected fields present

Common Mistakes

MistakeSymptomFix
Using {{}} in key namesKey name incorrect in responseKeys are plain text: userId not {{userId}}
Forgetting = for formulasFormula treated as text instead of being evaluatedStart formulas with = and keep math outside the braces: ={{price}} * {{qty}}
Uninitialized variable referencesEmpty or null values in responseUse Set Default Value to initialize variables first
Duplicate keysOnly last value appears in responseUse unique key names; last value overwrites
Number returned as textA plain 42 is stored as text (no auto number detection)Set the field to number type, or use a formula: =42

Troubleshooting

IssueCommon CauseFix
Field missing from responseVariable doesn't exist or is uninitializedInitialize variable with Set Default Value before Add To Response
Formula not evaluatingMissing = prefixStart with =: ={{expression}}
Value is wrong typeNumber typed as a plain value comes back as textSet the field to number type, or use a formula: =42
Duplicate keys overwritingSame key used multiple timesUse unique key names or combine in single stage
Empty responseAdd To Response not connected or executedVerify stage is on execution path before Return

Do's and Don'ts

Do:

  • ✓ Use for static response metadata and fixed fields
  • ✓ Use variable references for dynamic values: {{userId}}
  • ✓ Use formulas for computed values: ={{total}} * 0.1
  • ✓ Include request ID, timestamp, or version in response
  • ✓ Place at end of flow before returning result

Don't:

  • ✗ Use {{}} in key names (plain text keys only)
  • ✗ Forget = prefix for formulas
  • ✗ Expect dynamic values to update mid-flow (fixed at execution time)
  • ✗ Use when values need to be conditional (use Route Flow first)
  • ✗ Forget to initialize variables before referencing

Edge Cases

  • Numeric strings vs numbers: a plain 42 is stored as text; use =42 or a number-type field to return an actual number
  • Null values: Uninitialized variable references stored as empty string
  • Duplicate keys: Last value wins if same key added multiple times
  • Empty value: Empty string included in response (distinguishable from null)
  • Formula errors: Errors logged but don't fail stage; field added with error message

Related Stages