> ## Documentation Index
> Fetch the complete documentation index at: https://www.testmuai.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Make API Calls with Kane CLI

> Have the Kane CLI agent make HTTP API calls directly inside an objective to seed data, hit a backend, then assert on or reuse the response.

An objective can tell the agent to **make an API call itself**, in addition to observing the requests a page makes. Use this to seed data before a flow, call a backend to set up state, or check a service, and then assert on or reuse the response.

## Making a call

Write the HTTP request explicitly, and name its response with "save the response as …":

```
Call POST https://api.example.com/orders with body {"item": "sku_42", "qty": 1}, save the response as order
Hit GET https://api.example.com/orders/123, save the response as fetched
Call DELETE https://api.example.com/orders/123
```

You can also paste a `curl` command. The agent keeps it exactly as written, including method, headers, body, and auth:

```
curl -X POST https://api.example.com/login -H 'Content-Type: application/json' -d '{"u":"a","p":"b"}', save the response as login
```

## Using the response

Refer to the response in plain English. The `{{name}}` syntax is reserved for global variables and secrets (see [Variables and Context](https://www.testmuai.com/docs/kane-cli-variables-and-context.md)). Never use it for a value the run produces.

| To use | Say |
| - | - |
| the HTTP status code | `assert the response status is 201` |
| a field from the JSON body | `store the id from the response body as 'order_id'` |
| the whole body | `store the response body as 'order_body'` |
| a value later in the run | `the stored order_id value` |

When one objective makes several calls, name each response (`save the response as order`) and say which one you mean, as in `assert the order response status is 201`.

You can assert on a response or use it in later actions. API calls and browser actions can be mixed freely in one objective:

```
Call POST https://api.example.com/login with body {"u": "{{user}}", "p": "{{password}}"}, save the response as login,
assert the response status is 200,
then open https://app.example.com and verify the dashboard loads
```

```
Call POST https://api.example.com/orders with body {"item": "sku_42", "qty": 1}, save the response as order,
assert the response status is 201,
then open https://app.example.com/orders and verify an order for "sku_42" is visible
```

## Tokens and secrets

Store every API token or credential in a variable marked `secret: true` (see [Variables and Context](https://www.testmuai.com/docs/kane-cli-variables-and-context.md)). The value is then masked in logs and never stored in plain text:

```
curl -X DELETE https://api.example.com/records/42 -H "Authorization: Bearer {{api_token}}"
```

## Make a call vs. observe page traffic

These are two different features:

* **Make a call (this page)**: *you* tell the agent to send a request, for example to seed a record, call a backend, or set up state.
* **[Network assertions](https://www.testmuai.com/docs/kane-cli-checkpoint-devtools-network.md)**: *observe* the requests the page makes on its own during a UI flow, such as status codes, bodies, and timing.

They work together: seed state with a direct call, drive the UI, then assert on the page's own network traffic.

## Terminal First Testing With Kane CLI

Natural language browser & mobile app tests right from terminal.

Book a Demo

![Kane CLI terminal](https://assets.testmu.ai/resources/images/Terminal-KaneCLI.png)

×

Schedule Your Personal Demo

<form>
  Select Product

  Schedule Demo
</form>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.