For the complete documentation index, see llms.txt. This page is also available as Markdown.

Response body contains

This is a pre-built action available under @Assertion element type. This action validates whether the API response body contains the expected text or value or matches the expected regex pattern. The output variable stores the validation result as True or False.

Note: An API request must be added and executed successfully before configuring or evaluating API Assertion.

Syntax

Input Value: <Text or value or regex pattern to search in response>;<Match type: Contains/Regex>

Argument
Description

<Text or value or regex pattern to search in response>

Provide the text, value, or regular expression pattern that you want to search for in the API response body.

<Match type: Contains/Regex>

Specify the matching method to use for validating the response body:

  • Contains: Searches for the specified text or value anywhere in the API response body.

  • Regex: Searches the API response body using the specified regular expression pattern.

Output Value: <Keyword Status (Optional)>

Argument
Description

<Keyword Status (Optional)>

The keyword status variable stores the assertion status as True or False.

Example 1: Validating Text in an API

In this example, we explain how to verify that the API response body contains the expected text.

  • Action: Response body contains

  • Input Value: John;Contains

    • The first value John specifies the text to search for in the API response body.

    • The second value Contains specifies that the action searches for the text anywhere in the response body.

JSON Response Body
{
  "first_name": "John",
  "last_name": "Doe",
  "phone": "8765678987",
  "email": "johndoe@gmail.com.com",
  "id": 205
}
  • Output Value: {Status}

    • The output variable {Status} stores the verification result with the following possible values:

      • True: If the expected text is found in the API response body.

      • False: If the expected text is not found in the API response body.

  • Logical Explanation: The Response body contains action fetches the expected text John and match type Contains from the Input Value column. The action searches for the complete API response body for the specified text. John is present in the availability field, the {Status} variable stores True.

Example 2: Validating Response Body Using a Regex Pattern

In this example, we explain how to verify that the API response body contains a value that matches the specified regular expression pattern.

Note: To validate the response body using a regular expression, the response body must contain a value that matches the specified regex pattern.

  • Action: Response body contains

  • Input Value: ^[A-Za-z0-9]+$;Regex

    • The first value ^[A-Za-z0-9]+$ specifies the regular expression pattern to validate an alphanumeric value containing only letters and numbers.

    • The second value Regex specifies that the action uses regular expression matching to validate the response body.

  • Output Value: {Status}

    • The output variable {Status} stores the verification result with the following possible values:

      • True: If the API response body contains a value that matches the specified regular expression pattern.

      • False: If the API response body does not contain a value that matches the specified regular expression pattern.

  • Logical Explanation: The Response body contains action fetches the regular expression pattern ^[A-Za-z0-9]+$ and match type Regex from the Input Value column. The action searches the response body for a value that contains only letters and numbers. If the response body matches the regex pattern, the {keyword_status} variable stores True.

Following are some common use cases of regex patterns:

Use Case
Regex Pattern
Example Value

Contains only digits

^\d+$

12345

Exactly 6 digits (ZIP/PIN)

^\d{6}$

560001

Exactly 10 digits (Phone)

^\d{10}$

9876543210

Positive integer

^[1-9]\d*$

125

Decimal number

^\d+(\.\d+)?$

10.5

Alphabetic characters only

^[A-Za-z]+$

John

Alphabets with spaces

^[A-Za-z ]+$

John Doe

Alphanumeric

^[A-Za-z0-9]+$

EMP123

Email address

^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$

john@test.com

URL

^https?://.+

https://example.com

UUID

^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$

550e8400-e29b-41d4-a716-446655440000

Date (YYYY-MM-DD)

^\d{4}-\d{2}-\d{2}$

2026-07-24

Time (HH:mm:ss)

^\d{2}:\d{2}:\d{2}$

14:30:45

DateTime (ISO 8601)

^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$

2026-07-24T14:30:45Z

Starts with prefix

^EMP.*

EMP1023

Ends with suffix

.*\.pdf$

report.pdf

Contains specific text

.*Success.*

Operation Success

Boolean

`^(true

false)$`

Hexadecimal

^[0-9A-Fa-f]+$

A1B2C3

Password (8+ chars, upper, lower, digit)

^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,}$

Test1234

Last updated