Store

Store hooks allow you to store and manage values in memory during execution, creating a shared key-value store that can be used by subsequent hooks and replications. This hook is particularly useful for storing processing results, creating reusable variables, or maintaining state across your workflow.

The store hook supports two storage targets:

  • Replication Store (default): Values stored with store.* or plain keys persist only within the current replication execution

  • Environment Variables: Values stored with env.* prefix become actual environment variables, available to all subsequent steps, replications, and even API spec rendering (authentication blocks, dynamic endpoints, etc.)

Configuration

Single Key/Value:

- type: store
  key: my_key             # Required: Key to store the value under
  value: some value       # Required (unless deleting): Value to store
  delete: false           # Optional: Set to true to delete the key

Multiple Key/Values:

- type: store
  map:                    # Set multiple key/value pairs at once
    key1: value1
    key2: value2
    env.API_KEY: "abc123"
  delete: false           # Optional: Set to true to delete all keys in the map (and unset env var)

Properties

Property
Required
Description

key

Yes*

The key name to store the value under. Use env.KEY_NAME prefix to set environment variables, or store.key_name (or just key_name) for replication store. *Required unless using map

value

Yes*

Value to store at the specified key. For environment variables, the value is automatically converted to a string. *Required unless using map or deleting

map

No

A map of key/value pairs to set multiple values at once. Use this instead of key and value when setting multiple store values. Supports both env.* and store.* keys

delete

No

When set to true, deletes the key(s) and their value(s) instead of storing. Works with both key/value and map approaches

on_failure

No

What to do if the operation fails (abort/warn/quiet/skip)

Output

When the store hook executes successfully, it returns the following output that can be accessed in subsequent hooks:

You can access these values in subsequent hooks using the following syntax:

  • {state.hook_id.status} - Status of the hook execution

  • {state.hook_id.operation} - The operation performed (set/delete)

  • {state.hook_id.path} - The key that was manipulated

  • {state.hook_id.value} - The value that was set (only for 'set' operation)

Accessing Stored Values

Replication Store Values

To access values stored in the replication store, use the store namespace:

For example, if you stored a complex object, you can access nested properties:

Environment Variable Values

To access values stored as environment variables, use the env namespace:

Environment variables set via env.* prefix are:

  • Available across all subsequent pipeline steps and replications

  • Accessible in API specs during rendering (authentication, dynamic endpoints, etc.)

  • Accessible in connection configurations

  • Visible to child processes

Storage Target Comparison

Feature

Replication Store (store.*)

Environment Variables (env.*)

Scope

Current replication only

All subsequent steps/replications

API Spec Rendering

❌ Not available during spec compilation

✅ Available before spec compilation

Complex Objects

✅ Supports nested objects/arrays

❌ String values only

Use in Authentication

❌ Cannot use in auth blocks

✅ Can use in auth/dynamic blocks

Performance

Faster (in-memory)

Slightly slower (OS env vars)

Best For

Temporary data, complex objects

Configuration, credentials, tokens

Examples

Setting a Simple Value

Store a simple value for later use:

Storing Complex Values

Store an object with multiple properties:

Using Variables in Values

Set values using variables from the runtime state:

Deleting Stored Values

Remove values that are no longer needed:

Conditional Storage

Store values based on conditions:

Storing Results from Other Hooks

Store and access results from other hooks:

Using Stored Values in Subsequent Hooks

Show how stored values can be used in various hooks:

Building Dynamic Values

Combine stored values to build more complex structures:

Temporary Storage for Processing

Use store for intermediate processing:

Setting Environment Variables

Use the env.* prefix to set environment variables that persist across pipeline steps and are available during API spec rendering.

Basic Environment Variable

Set a simple environment variable:

Dynamic API Authentication with Environment Variables

Set environment variables that are used in API spec authentication blocks:

Pipeline Configuration:

API Spec (using environment variables):

Key Advantage: Environment variables set via env.* hooks are available before API specs are compiled/rendered, making them usable in authentication blocks and dynamic endpoint definitions where store.* variables cannot be used.

Setting Multiple Values at Once

Use the map property to set multiple store or environment variables in a single step:

Dynamic Map from Query Results

Build a map dynamically from query results:

Deleting Environment Variables

Remove environment variables when no longer needed:

Deleting Multiple Variables

Remove multiple keys at once:

Last updated

Was this helpful?