Variables in API Testing
Variables in Robonito enable you to capture dynamic values from an API response and seamlessly reuse them in subsequent API requests. Passing data downstream is essential for building dynamic, chained, and realistic end-to-end automation scenarios.
Variables are critically useful for:
- Managing authentication tokens (JWTs, Bearer tokens).
- Retrieving newly generated Object IDs (Users, Orders).
- Propagating transaction references.
- Validating holistic workflows rather than isolated endpoints.
Why Variables Matter
Traditional hardcoding is fragile. In the real world, APIs create dynamic identifiers and session tokens on the fly.
By extracting values dynamically, you ensure your Robonito tests remain reusable, reliable, and entirely maintenance-free.
How Variable Extraction Works
During an execution sequence:
- An API test sends a request and receives a server response.
- Robonito uses a designated JSONPath to isolate a specific target value.
- The isolated value is cached into memory under your custom Variable Name.
- Subsequent tests reference this cached data using the
{{variableName}}syntax.
Configuring a Variable Extraction
Follow these steps to programmatically extract an API response value:

- Access the Source Request: Open the API test case that generates the desired data.
- Navigate to Variables: Open the Variables tab.
- Add an Extraction: Click Extract Variable.
- Define the Rules:

- Variable Name: An intuitive identifier (e.g.,
userIdorauthToken). You will inject this later using{{userId}}. - Source: Choose where to look. The most common target is
Response Body (JSON). - JSONPath Navigation: A valid JSONPath expression pointing directly to the value.
Example Setup: If the API returns:
{
"user": { "id": 101 },
"token": "abc123xyz"
}
You could use $.user.id to capture 101, and $.token to capture abc123xyz.
Using Variables Downstream
Once extracted, variables exist in the test workflow memory. You can inject them securely into subsequent API test configuration fields simply by wrapping the variable name in double curly braces: {{variableName}}.
Supported Injection Points:
- URLs and Endpoints (e.g.,
https://api.site.com/users/{{userId}}) - Query Parameters
- HTTP Headers
- Authorization Tokens
- Request Body Payload (JSON)
Example Injection in a Body Payload:
{
"targetUserId": "{{userId}}",
"action": "activate"
}
A Real-World Scenario: End-to-End Workflow
Variables truly shine when validating multi-step user actions.
-
Step 1: Account Creation
- Action: Execute a
POST /usersrequest to create an account. - Extraction: Target
$.idand save it as{{userId}}.
- Action: Execute a
-
Step 2: Authentication Login
- Action: Execute a
POST /loginrequest for the new user. - Extraction: Target
$.accessTokenand save it as{{authToken}}.
- Action: Execute a
-
Step 3: Access Secured Profile
- Action: Request the user profile to validate creation.
- Endpoint:
GET /users/{{userId}} - Header:
Authorization: Bearer {{authToken}}
With dynamic variables, this complex three-step authentication framework works reliably in test automation pipelines every single time.