> 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/core-features/intelligence-hub/generate-test-cases/smart-recording/generator-mode/api.md).

# API

**When to Use API Smart Recording:**\
Use this feature when you want to generate real-time, structured API test cases by interacting with live applications using Walnut AI.

* **Supported Platform:** API
* **Execution Type:** AI-driven API interaction

**Steps to Generate:**

* **Enter Application URL:** Click the **API** option under **Generate Test Cases → Smart Recording** and enter the base application URL.

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

* **Connect:** Click **Connect** to start the AI-controlled session. Walnut AI establishes the connection and begins monitoring API network activity.

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

* **Provide Prompt:** Enter a prompt describing the API functionality (for example: *Generate login API test case*, *Validate dashboard API*, *Create user API flow*). Walnut AI triggers API calls and structures them into test steps.
* **AI Analysis & Recording:** Walnut AI captures API requests, endpoints, payloads, headers, response codes, and validations while structuring them into organized test steps.

<figure><img src="/files/9TgRRs8uEDduEk5ytBiW" alt=""><figcaption></figcaption></figure>

* **Parameter Generation:** Input values such as base URLs, endpoints, credentials, headers, payload values, and expected responses are automatically converted into reusable parameters.

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

* **Step Optimization:** You can provide prompts to optimize the API flow. WalnutAI removes redundant API calls, retains required validations, and structures the steps into an optimized, execution-ready API test case.

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

* **Finalize Session:** Click **Disconnect** and then **Done** to complete the recording session.

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

* **Save:** Click **Save** to store the generated test case. If not saved, the generated test case will not be retained.

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

{% hint style="info" %}
**Result:** Saved **Test Cases** will appear in the **Test Case Module** reflected accordingly.
{% endhint %}


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.walnutai.ai/core-features/intelligence-hub/generate-test-cases/smart-recording/generator-mode/api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
