Skip to main content

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:

  1. Creates a new user via API
  2. Extracts the user ID from the response
  3. Retrieves the user's details using the ID
  4. Updates the user
  5. Validates the update was successful
  6. 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

  1. Navigate to "Conduits" in the sidebar
  2. Click "New Conduit"
  3. Name it: "User CRUD Flow"
  4. Add a description: "Complete user lifecycle test"
  5. Click "Create"

Step 2: Add the First Request

Create User Request

  1. Click "Add Step"
  2. Select "Request"
  3. Choose an existing "Create User" request or create one:
    POST {{baseUrl}}/users

    Body:
    {
    "name": "Test User",
    "email": "test-{{$randomInt}}@example.com"
    }
  4. 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.

  1. In the "Create User" step, click "Add Extraction"
  2. Configure extraction:
    • From: Response body
    • Path: id (or $.id for JSON path)
    • Save as: userId
  3. Save

Now {{userId}} is available for later steps!

Learn more about extraction →

Step 4: Add Assertion

Validate the user was created successfully.

  1. In the "Create User" step, click "Add Assertion"
  2. Add assertion:
    • Status code equals 201
  3. Add another assertion:
    • Response field email contains @example.com
  4. Save

Learn more about assertions →

Step 5: Retrieve User

Use the extracted ID to get user details.

  1. Click "Add Step"
  2. Select "Request"
  3. Create "Get User" request:
    GET {{baseUrl}}/users/{{userId}}
  4. Add assertion:
    • Status code equals 200
  5. Add assertion:
    • Response field id equals {{userId}}
  6. Save

Step 6: Update User

Modify the user's information.

  1. Add another request step
  2. Create "Update User" request:
    PUT {{baseUrl}}/users/{{userId}}

    Body:
    {
    "name": "Updated User",
    "email": "updated-{{$randomInt}}@example.com"
    }
  3. Add extraction for new email:
    • Path: email
    • Save as: updatedEmail
  4. Add assertion:
    • Status code equals 200
  5. Save

Step 7: Verify Update

Confirm the update was applied.

  1. Add another GET request:
    GET {{baseUrl}}/users/{{userId}}
  2. Add assertion:
    • Response field email equals {{updatedEmail}}
  3. Add assertion:
    • Response field name equals "Updated User"
  4. Save

Step 8: Cleanup

Delete the test user to keep the system clean.

  1. Add final request step:
    DELETE {{baseUrl}}/users/{{userId}}
  2. Add assertion:
    • Status code equals 204 (or 200, depending on API)
  3. Save

Step 9: Run the Conduit

Time to test your conduit!

  1. Click "Run Conduit"
  2. Watch the steps execute sequentially
  3. 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.

  1. Click "Add Step" between two request steps
  2. Select "Delay"
  3. Set duration: 1000 ms (1 second)
  4. 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:

  1. Open step settings
  2. Enable "Continue on failure"
  3. Save

Conditional Steps

Execute steps only if conditions are met:

  1. Add a step
  2. Configure "Run condition":
    • Only if previous step succeeded
    • Only if variable equals value
    • Custom condition
  3. Save

Advanced Features

Variable Steps

Set or modify variables during execution:

  1. Add "Variable" step
  2. Set variable:
    • Name: retryCount
    • Value: 3
  3. Use in later steps

Script Steps

For complex logic (advanced):

  1. Add "Script" step
  2. 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

  1. Check the error message
  2. Review the request/response
  3. Verify variable values
  4. Run the step manually
  5. 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:

  1. Login: Get authentication token
  2. Create Customer: Register new customer
  3. Extract Customer ID: Save for later use
  4. Add to Cart: Create shopping cart
  5. Extract Cart ID: Save cart reference
  6. Add Items: Add products to cart (loop)
  7. Calculate Total: Verify cart total
  8. Checkout: Create order
  9. Extract Order ID: Save order reference
  10. Verify Order: Get order details
  11. Check Inventory: Verify stock was decremented
  12. Send Confirmation: Trigger email (if supported)
  13. Cleanup: Cancel order, delete test customer

This conduit tests the complete purchase flow!

Next Steps