Skip to content

Automation with Lua

Lua Scripting transforms Solo from a simple HTTP client into an automation tool. Using Lua allows you to manipulate requests before sending and validate responses in real-time.


In Solo, logic can be inserted at two points in a request’s lifecycle:

This section is dedicated to data preparation. You can calculate dynamic security signatures (HMAC, SHA256), add custom headers based on the current time, or generate unique IDs (UUID) for transaction tracking.

This section is intended for analyzing results. You can extract tokens or IDs from the response, run assertion tests (e.g., verifying a 200 status), or log messages to the console for debugging.


Session Variables allow communication between requests. Unlike environment variables, which are static and saved to disk, session variables reside exclusively in Solo’s memory and are populated dynamically during testing.

Extracting a value via env.set("my_token", value) in one request allows it to be used as {{my_token}} in any other tab or request in the collection.

You can monitor the session state directly in the builder:

  1. Access the “Scripts” tab.
  2. Consult the “Session Vars” list in the editor sidebar.
    The Session Variables panel showing the list of keys and current values in memory.The Session Variables panel showing the list of keys and current values in memory.
  3. Reset the session using the “Clear” button next to the header.

Solo extends Lua with modules dedicated to common API operations:

ModuleFunctionalityExample
envVariable management and logs.env.set("key", "val"), env.log("msg")
jsonJSON parsing and generation.data = json.parse(response.body)
cryptoHashing and encoding.hash = crypto.sha256("test"), crypto.base64_encode("...")
uuidUnique identifiers.id = uuid.v4()
timeTime and date management.now = time.now()

Example of a Post-response script for saving an access token:

-- 1. Convert response body to a Lua object
local data = json.parse(response.body)
-- 2. Extract the token from the "access_token" field
local token = data.access_token
-- 3. Save to Solo's session variables
if token then
env.set("auth_token", token)
env.log("Token saved successfully!")
else
env.log("Error: token not found in response")
end