Building Conduits
Conduits are Nidra's powerful automation feature for building test flows. This tutorial will guide you through creating your first conduit.
What You'll Build
In this tutorial, you'll create a conduit that:
- Creates a new user via API
- Extracts the user ID from the response
- Retrieves the user's details using the ID
- Updates the user
- Validates the update was successful
- Deletes the user (cleanup)
Prerequisites
- A collection with user management endpoints
- An environment configured with
baseUrl - Basic understanding of REST APIs
Step 1: Create a Conduit
- Navigate to "Conduits" in the sidebar
- Click "New Conduit"
- Name it: "User CRUD Flow"
- Add a description: "Complete user lifecycle test"
- Click "Create"
Step 2: Add the First Request
Create User Request
- Click "Add Step"
- Select "Request"
- Choose an existing "Create User" request or create one:
POST {{baseUrl}}/users
Body:
{
"name": "Test User",
"email": "test-{{$randomInt}}@example.com"
} - Save the step
Expected Response
{
"id": 12345,
"name": "Test User",
"email": "test-42@example.com",
"createdAt": "2024-03-06T10:00:00Z"
}
Step 3: Extract Variables
Extract the user ID for use in subsequent steps.
- In the "Create User" step, click "Add Extraction"
- Configure extraction:
- From: Response body
- Path:
id(or$.idfor JSON path) - Save as:
userId
- Save
Now {{userId}} is available for later steps!
Step 4: Add Assertion
Validate the user was created successfully.
- In the "Create User" step, click "Add Assertion"
- Add assertion:
- Status code equals 201
- Add another assertion:
- Response field
emailcontains@example.com
- Response field
- Save
Step 5: Retrieve User
Use the extracted ID to get user details.
- Click "Add Step"
- Select "Request"
- Create "Get User" request:
GET {{baseUrl}}/users/{{userId}} - Add assertion:
- Status code equals 200
- Add assertion:
- Response field
idequals{{userId}}
- Response field
- Save
Step 6: Update User
Modify the user's information.
- Add another request step
- Create "Update User" request:
PUT {{baseUrl}}/users/{{userId}}
Body:
{
"name": "Updated User",
"email": "updated-{{$randomInt}}@example.com"
} - Add extraction for new email:
- Path:
email - Save as:
updatedEmail
- Path:
- Add assertion:
- Status code equals 200
- Save
Step 7: Verify Update
Confirm the update was applied.
- Add another GET request:
GET {{baseUrl}}/users/{{userId}} - Add assertion:
- Response field
emailequals{{updatedEmail}}
- Response field
- Add assertion:
- Response field
nameequals"Updated User"
- Response field
- Save
Step 8: Cleanup
Delete the test user to keep the system clean.
- Add final request step:
DELETE {{baseUrl}}/users/{{userId}} - Add assertion:
- Status code equals 204 (or 200, depending on API)
- Save
Step 9: Run the Conduit
Time to test your conduit!
- Click "Run Conduit"
- Watch the steps execute sequentially
- View results for each step:
- Green checkmarks for passed assertions
- Red X marks for failures
- Response times
- Extracted variables
Success!
If all steps pass, you've successfully created a complete test flow!
Adding Delays
Sometimes you need to wait between requests.
- Click "Add Step" between two request steps
- Select "Delay"
- Set duration:
1000ms (1 second) - Save
Use this when:
- Waiting for async operations
- Rate limiting
- Database propagation delays
Error Handling
What if a step fails?
Continue on Failure
By default, conduits stop on the first error. To continue:
- Open step settings
- Enable "Continue on failure"
- Save
Conditional Steps
Execute steps only if conditions are met:
- Add a step
- Configure "Run condition":
- Only if previous step succeeded
- Only if variable equals value
- Custom condition
- Save
Advanced Features
Variable Steps
Set or modify variables during execution:
- Add "Variable" step
- Set variable:
- Name:
retryCount - Value:
3
- Name:
- Use in later steps
Script Steps
For complex logic (advanced):
- Add "Script" step
- Write JavaScript to:
- Transform data
- Compute values
- Complex validations
Loops
Repeat a set of steps:
- For Each: Iterate over array
- While: Repeat until condition
- Retry: Retry failed steps
Best Practices
Organization
- One purpose per conduit: Don't mix unrelated workflows
- Name steps clearly: "Create User", not "Step 1"
- Add descriptions: Explain what each step does
- Group related conduits: Use folders or naming conventions
Reliability
- Add assertions liberally: Validate assumptions at every step
- Clean up resources: Delete test data created
- Handle errors: Plan for failure scenarios
- Use realistic data: Test with production-like data
Maintenance
- Keep conduits simple: Complex flows are hard to maintain
- Extract common flows: Reuse conduit building blocks
- Document special cases: Explain non-obvious logic
- Review regularly: Remove outdated conduits
Troubleshooting
Step Fails
- Check the error message
- Review the request/response
- Verify variable values
- Run the step manually
- Check API documentation
Variable Not Extracted
- Verify the JSON path is correct
- Check response structure
- Ensure the field exists in the response
- Test extraction with sample data
Assertions Fail
- Review expected vs actual values
- Check data types (string vs number)
- Verify variable resolution
- Update assertion logic if needed
Real-World Example
E-Commerce Order Flow
A production-ready conduit:
- Login: Get authentication token
- Create Customer: Register new customer
- Extract Customer ID: Save for later use
- Add to Cart: Create shopping cart
- Extract Cart ID: Save cart reference
- Add Items: Add products to cart (loop)
- Calculate Total: Verify cart total
- Checkout: Create order
- Extract Order ID: Save order reference
- Verify Order: Get order details
- Check Inventory: Verify stock was decremented
- Send Confirmation: Trigger email (if supported)
- Cleanup: Cancel order, delete test customer
This conduit tests the complete purchase flow!
Next Steps
- Master variable extraction →
- Learn about assertions →
- Check the conduit steps reference →
- Explore advanced conduit patterns