> For the complete documentation index, see [llms.txt](https://docs.walnutai.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.walnutai.ai/test-and-quality-management/test-management/creating-test-cases-in-walnut/how-to-create-api-test-case.md).

# How to create API test case

An API Test Case is a structured validation scenario designed to test the functionality and behaviour of backend services. It validates API endpoints by sending requests and verifying responses such as status codes, headers, and response data to ensure the service works as intended.

#### **Steps to Create a API Test Case**

* Click the [C**reate New Test Case**](/test-and-quality-management/test-management/test-cases/test-case-creation.md) button to start a new validation scenario.

<figure><img src="/files/SVHEDYhdATgpzbfwlH6N" alt=""><figcaption></figcaption></figure>

* Click "**Add Step"**, then type “/” inside the step field. From the dropdown menu, choose **Test Case Type** and select **API**. This allows you to configure structured API validation steps without writing manual code.

<figure><img src="/files/3MfNu4VGVLhegEV9Pu0a" alt=""><figcaption></figcaption></figure>

* Select the required HTTP Method (GET, POST, PUT, DELETE, PATCH).

<figure><img src="/files/x0Bxmw4mIiLdNbHZ8Mwv" alt=""><figcaption></figcaption></figure>

* Enter the Request URL. You can use variables inside the URL if needed.

<figure><img src="/files/ODEqGwQfljFGaiTZJAw8" alt=""><figcaption></figcaption></figure>

* Use the available tabs to configure the request:
  * In **Params**, add query parameters as key-value pairs.
  * In **Authorization**, select the required authentication type such as Bearer Token, Basic Auth, API Key, OAuth, JWT, etc.
  * In **Headers**, add the necessary request headers.
  * In **Body**, choose the required body type such as JSON, Form Data, Raw, x-www-form-URL encoded, or Graph, and provide the payload if needed.
  * In **Variables**, manage Local, Runtime, and Global variables.
  * In **Extractions**, define rules to capture values from the API response for use in subsequent steps.
  * In **Pre-request Script**, add logic that should execute before the request is sent.
  * In **Tests**, define validations to verify response status codes and response data.
* Enter the step description in simple English to clearly describe the API validation scenario.
* To reuse an existing parameter, type `${` to open the parameter dropdown and select the required variable. To create a new parameter, refer to the Create New Parameter section for guidance.

<figure><img src="/files/GjAPWbjPqkkRnT0vBjA3" alt=""><figcaption></figcaption></figure>

* Once all steps and configurations are completed, click **Save** to store your test case in the dashboard.
* Run the created API test case using either:
  * **Manual Mode** for step-by-step validation.
  * **Automation (Walnut AI) Mode**, where Walnut AI automatically sends the request, resolves parameters, processes variables, performs validations, and generates structured execution results.

<figure><img src="/files/nro8AU3RM0mCtqgiwTWh" alt=""><figcaption></figcaption></figure>

To understand the details of running your tests and how the system handles changes, refer to the documentation on[ Execution & AI Healing.](/test-and-quality-management/test-management/execution-and-ai-healing.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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.walnutai.ai/test-and-quality-management/test-management/creating-test-cases-in-walnut/how-to-create-api-test-case.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.
