# Test tool

> Run a tool with the parameters you supply and return what it answered.

`POST https://api.zavu.dev/v1/senders/{senderId}/agent/tools/{toolId}/test`

Run a tool with the parameters you supply and return what it answered.

The call is synchronous: the response carries the tool's status, body, and duration, so a green result is evidence the tool ran rather than evidence it was accepted. Each run is also recorded and readable afterwards via `GET /v1/senders/{senderId}/agent/tools/{toolId}/test-runs`.

A tool that answers with an error is reported as a run with `success: false` — the endpoint itself still returns 200. This fires the tool's real webhook, so a test has whatever side effects the tool has.

## Parameters

- `senderId` (path, string, required)
- `toolId` (path, string, required)

## Body

- `testParams` (object, required): Parameters to pass to the tool for testing.

## Responses

### 200

The tool ran. Check `run.success` for what it answered.

- `run` (object, required): One run of a tool triggered from the test endpoint. Recorded so a test is verifiable after the fact rather than only visible in the response.
  - `id` (string, required)
  - `toolId` (string, required)
  - `params` (object): The parameters the tool was called with.
  - `success` (boolean, required): Whether the tool returned without error. A tool that answered with a non-2xx status is a failed run, not an error of this endpoint.
  - `statusCode` (integer, nullable): HTTP status the tool's webhook returned. Absent for tools that do not go over HTTP.
  - `response` (string, nullable): The tool's response body, truncated.
  - `error` (string, nullable): Why the run failed, when it did.
  - `durationMs` (integer, required)
  - `createdAt` (string<date-time>, required)

### 401

Unauthorized.

- `code` (string, required)
- `message` (string, required)
- `details` (object)

### 404

Tool not found.

- `code` (string, required)
- `message` (string, required)
- `details` (object)

## Example

```bash
curl -X POST "https://api.zavu.dev/v1/senders/sender_abc123/agent/tools/tool_abc123/test" \
  -H "Authorization: Bearer $ZAVUDEV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "testParams": {
    "order_id": "ORD-12345"
  }
}'
```

```typescript
import Zavudev from "@zavudev/sdk";

const zavu = new Zavudev({ apiKey: process.env.ZAVUDEV_API_KEY });

const result = await zavu.senders.agent.tools.test("tool_abc123", {
  senderId: "sender_abc123",
  testParams: {
    order_id: "ORD-12345",
  },
});

console.log(result);
```
