With flows, you can encapsulate your commonly used API testing sequences for reuse in other API tests, such as obtaining an auth token, setting up test data, or cleaning up data at the end of the test.
This article shows you how to work with flows in the API Test Editor, including how to…
Looking for info about flows in browser or mobile tests? See our article on working with flows in the mabl Trainer.
Create a new flow
There are two ways to create a new flow in the API Test Editor: create the flow from scratch or create the flow from existing steps. When you save the test, mabl saves the new API flow to your workspace.
From scratch
Click on Add flow > New flow to create a new flow. Add flow-level auth, custom scripts, and parameters if needed. Then add steps or drag and drop existing steps from the test into the correct order between the Start flow and End flow steps.
From existing steps
For each step that you want to include in the flow, hover over the step number and check the checkbox that appears. Steps must be contiguous to create a flow.
Click on the Create flow icon at the top. Add flow-level auth, custom scripts, and parameters if needed.
Import an existing flow
In the API Test Editor, click on Add flow > Existing flow to import an existing flow.
If you import a flow that uses parameters, you can review the default parameter values in the FLOW PARAMETERS tab. If you need to, add override values for the current instance of the flow. Overrides do not impact other instances of the flow.
Use flow parameters
With flow parameters, you can scope variables to a single flow or reuse a flow with different variable values. To add flow parameters, click on the Edit flow pencil and open the FLOW PARAMETERS tab. Give the parameter a name and default value. mabl uses the default value unless you provide an override.
Adding parameters to a flow
To use a flow parameter in a test step, prepend the parameter name with flow.
. For example, the flow parameter test_var
becomes the variable flow.test_var
. Flow parameters are only available for steps within the flow.
Using flow parameters in a request
To customize the flow for a different scenario, add an override. Overrides only apply to that instance of the flow.
Edit a flow
To edit a flow, open a test that contains the flow in the API Test Editor. Modify steps as needed.
Keep in mind the following about editing flows:
- When you edit a flow in one test, you update the flow across all tests that use it.
- Any user with an editor or owner role in your workspace can edit flows.
- If you want to keep your version of a flow separate from other versions, save the flow to a branch.
API flow limitations
Looping and conditionals are not supported for API flows.
Remove a flow
To remove a flow from an API test, click on the trash icon in the Start flow step.
To delete a flow from your workspace, go to Tests > Flows and click on the trash icon. You may only delete flows that are not used in any tests. If you delete a flow by accident, you can recover it within 30 days of deletion from the activity feed: Settings > Activity feed.