# Parallel flows

This instruction is required when you want to fire multiple API calls in **parallel** and compare their responses. A simple use case for this would be to test for race conditions in an API by sending multiple requests in parallel.

To configure Akto test YAML for multiple parallel requests, set `type: parallel`. All the `requests` defined under this block are fired **at the same time**.

```yaml
execute: 
  type: parallel    # this means multiple requests are configured to run in parallel
  requests: 
   - req: 
     ...
   - req:
     ...  
```

### Instructions available -

For each request in a parallel flow, you can now use

* A global `validate` block to test for a certain response across all parallel requests.
* A local `validate` block for each individual request.
* A local `validate` block and global `validate` block.

If multiple `validate` blocks are used, all the validate blocks will be evaluated using the `Logical AND` operation.

Example 1 - Try adding body parameters to each request with a global validate block applying to all of them.

```yaml
execute:
  type: parallel
  requests:
  - req:
    - add_body_param:
        test1: one
  - req:
    - add_body_param:
        test2: two
  - req:
    - add_body_param:
        test3: three
validate:
  response_code:
    gte: 200
    lt: 300
```

Example 2 - Use local `validate` blocks on each parallel request, and a global `validate` block for a common condition.

```yaml
execute:
  type: parallel
  requests:
  - req:
    - add_body_param:
        test1: one
    - validate:
        response_payload:
          regex: ".*\"test1\":\"one\".*" 
  - req:
    - add_body_param:
        test2: two
    - validate:
        response_payload:
          regex: ".*\"test2\":\"two\".*" 
  - req:
    - add_body_param:
        test3: three
    - validate:
        response_payload:
          regex: ".*\"test3\":\"three\".*"
validate:
  response_code:
    gte: 200
    lt: 300
```

**Note**: A maximum of 10 requests can be made in parallel.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.akto.io/test-editor/concepts/test-yaml-syntax-detailed/parallel-flows.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
