Runs a tool by name. Body is the tool input from [Get Tool](/docs/api-reference/v2/tools-get). Example: `POST /api/v2/tools/list_subscribers`.

Dangerous tools return `confirmation_required` with `details.confirmationCode`. Retry the same body plus `confirmationCode`. SDK: `lumail.tools.run(name, params, { autoConfirm: true })` retries once.

## Path Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| `toolName` | string | **Required.** Tool name. |

## Body Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| *(tool fields)* | varies | Fields from the tool `inputSchema`. Example `list_subscribers`: `limit`, `status`, `tag`, `query`, `cursor`. |
| `confirmationCode` | integer | Required on the retry after `confirmation_required`. |

## Options

| Name | Type | Description |
| ---- | ---- | ----------- |
| `autoConfirm` | boolean | SDK-only. When `true`, `tools.run` retries once with `confirmationCode`. HTTP clients send `confirmationCode` themselves. Default `false`. |

## Response Fields

| Field | Type | Description |
| ----- | ---- | ----------- |
| *(tool output)* | object | Tool-specific JSON. Not wrapped in `{ success: true }`. |

`confirmation_required` error fields:

| Field | Type | Description |
| ----- | ---- | ----------- |
| `name` | `"confirmation_required"` | Error name. |
| `message` | string | Why confirmation is required. |
| `statusCode` | `403` | HTTP status. |
| `details.action` | string | Tool / action name. |
| `details.confirmationCode` | integer | Code to send back. |
| `details.instruction` | string | How to confirm. |

## Errors

| Status | `name` | When |
| ------ | ------ | ---- |
| 401 | `missing_api_key` | Missing or invalid bearer token |
| 403 | `missing_permission` | Token lacks the tool's permission |
| 403 | `confirmation_required` | Dangerous tool needs `confirmationCode` |
| 404 | `not_found` | Unknown tool name |
| 400 | `validation_error` | Invalid tool input |

## Related

- [Get Tool](/docs/api-reference/v2/tools-get)
- [List Tools](/docs/api-reference/v2/tools-list)
- [SDK: lumail.tools.run](/docs/sdk/v2/tools-run)


## API Reference
**Method:** POST
**Endpoint:** /api/v2/tools/:toolName

### SDK
```ts
import { Lumail } from "lumail";

const lumail = new Lumail({ apiKey: process.env.LUMAIL_API_KEY });
const { data, error } = await lumail.tools.run("list_subscribers", {
  limit: 10,
});
if (error) {
  throw error;
}
console.log(data);
```

### cURL
```bash
curl -X POST https://lumail.io/api/v2/tools/list_subscribers \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"limit":10}'
```

### JavaScript
```javascript
const response = await fetch(
  "https://lumail.io/api/v2/tools/list_subscribers",
  {
    method: "POST",
    headers: {
      Authorization: "Bearer YOUR_API_TOKEN",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ limit: 10 }),
  },
);
const data = await response.json();
```

### Success Response
```json
{
  "total": 2,
  "count": 2,
  "subscribers": [
    {
      "id": "sub_abc123",
      "email": "user@example.com"
    }
  ],
  "nextCursor": null
}
```

### Error Response
```json
{
  "name": "confirmation_required",
  "message": "This will send up to 100 transactional emails immediately.",
  "statusCode": 403,
  "details": {
    "action": "send_email",
    "confirmationCode": 482193,
    "instruction": "Retry with confirmationCode to proceed."
  }
}
```
