# Test a custom tool

`POST https://api.morevoice.ai/v1/tools/test`

Runs a custom tool once with the arguments you give, the way a call runs it: the same request body, signed with your tool signing secret (Standard Webhooks headers; test-mode keys sign with the test secret) and sent through the same network guard. Webhook failures (an HTTP error, a timeout) are reported in the result; a URL that cannot be called at all is a 400.

Authenticate with a secret API key: `Authorization: Bearer $MOREVOICE_API_KEY`.

Operation ID: `tools_test`.

## Parameters

### Headers

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `MoreVoice-Version` | `string` | no | The API version to use for this request. Defaults to the version the API key is pinned to. |
| `Idempotency-Key` | `string` | no | A unique key (for example a UUID) that makes this request safe to retry: for 24 hours, a retry with the same key and parameters returns the first response instead of acting twice. |

## Request body

Optional, `application/json`.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `arguments` | `object` | no | The arguments, as the model would pass them (default `{}`). |
| `assistant_id` | `string` | no | The assistant whose stored tool (with its stored headers) to test. |
| `tool` | `CustomToolParamsInput` | no | A custom tool as you send it. `headers` are write-only: stored with the assistant, never returned. |
| `tool.name` | `string` | yes | The function name the model calls (unique per assistant). |
| `tool.contract` | `"legacy" \| "v1"` | no | Default `legacy`. |
| `tool.description` | `string` | no | What the tool does and when to call it. |
| `tool.enabled` | `boolean` | no | Default true. |
| `tool.headers` | `Record<string, string>` | no | Extra request headers, e.g. `Authorization`. Write-only. On update, leave it out to keep the stored headers; send `{}` to remove them. |
| `tool.mock_response` | `string` | no | The answer of a `mock` tool. |
| `tool.parameters` | `object` | no | JSON Schema (an object schema) of the arguments. |
| `tool.request_start_message` | `string` | no | Spoken while the tool runs. |
| `tool.timeout_seconds` | `number` | no | How long to wait for the webhook, 1–60 (default 15). |
| `tool.type` | `"webhook" \| "mock"` | no | Default: `webhook` when `url` is set, else `mock`. |
| `tool.url` | `string` | no | The webhook URL (http or https). Required for `webhook` tools. `cli://<name>` sends the tool's calls to your CLI `listen --forward-tools` session instead (development). |
| `tool_name` | `string` | no | The stored tool's name (with `assistant_id`). |

Example:

```json
{
  "arguments": {
    "date": "2026-11-04"
  },
  "tool": {
    "headers": {
      "Authorization": "Bearer crm-secret"
    },
    "name": "find_slots",
    "timeout_seconds": 10,
    "url": "https://crm.example.com/voice/tools"
  }
}
```

## Responses

### 200 OK

OK Returns `ToolTest`.

| Field | Type | Description |
| --- | --- | --- |
| `object` | `"tool_test"` | — |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `tool` | `string` | The tool's name. |
| `type` | `"webhook" \| "mock"` | `webhook` tools were called over HTTP (signed); `mock` tools answered their `mock_response`. |
| `ok` | `boolean` | true when the tool answered (a 2xx for webhooks). |
| `duration_ms` | `integer` | How long the tool took. |
| `result` | `any` | What the model would receive: the parsed JSON (or text) of the answer. |
| `error` | `object \| null` | null when `ok`. |
| `error.code` | `"http_error" \| "timeout" \| "network" \| "response_too_large" \| "tool_error"` | Why the tool failed. |
| `error.message` | `string` | A human-readable explanation. |
| `error.status` | `integer \| null` | The webhook's HTTP status, when it answered. |

Example:

```json
{
  "duration_ms": 182,
  "error": null,
  "livemode": true,
  "object": "tool_test",
  "ok": true,
  "result": {
    "slots": [
      "10:30",
      "11:00"
    ]
  },
  "tool": "find_slots",
  "type": "webhook"
}
```

### 400 Bad Request

The request is invalid: a parameter is missing, malformed or unknown, or the version header is unknown. Returns `ErrorEnvelope`.

### 401 Unauthorized

No valid API key was sent. Returns `ErrorEnvelope`.

### 403 Forbidden

The key may not do this (a missing scope, a plan limit, or a compliance block). Returns `ErrorEnvelope`.

### 404 Not Found

No object with this ID (in the path or the body) exists in this organisation and mode. Returns `ErrorEnvelope`.

### 409 Conflict

The request conflicts with the object's state, or the Idempotency-Key was reused with other parameters. Returns `ErrorEnvelope`.

### 413 Payload Too Large

The request body is larger than the endpoint accepts, or has more parts or files than it takes. Returns `ErrorEnvelope`.

### 415 Unsupported Media Type

The request body's Content-Type is not one the endpoint takes. Returns `ErrorEnvelope`.

### 429 Too Many Requests

Too many requests, or no call capacity right now. Retry after the Retry-After delay. Returns `ErrorEnvelope`.

### 500 Internal Server Error

Something went wrong on MoreVoice's side. Retry with the same Idempotency-Key. Returns `ErrorEnvelope`.

## Code samples

**TypeScript**

```ts
import MoreVoice from "@morevoice/sdk";

const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment

const toolTest = await mv.tools.test({
	arguments: {
		date: "2026-11-04",
	},
	tool: {
		headers: {
			Authorization: "Bearer crm-secret",
		},
		name: "find_slots",
		timeout_seconds: 10,
		url: "https://crm.example.com/voice/tools",
	},
});
console.log(toolTest);
```

**Python**

```python
from morevoice import MoreVoice

client = MoreVoice()  # MOREVOICE_API_KEY from the environment

tool_test = client.tools.test({
    "arguments": {
        "date": "2026-11-04",
    },
    "tool": {
        "headers": {
            "Authorization": "Bearer crm-secret",
        },
        "name": "find_slots",
        "timeout_seconds": 10,
        "url": "https://crm.example.com/voice/tools",
    },
})
print(tool_test)
```

**cURL**

```sh
curl -X POST https://api.morevoice.ai/v1/tools/test \
  -H "Authorization: Bearer $MOREVOICE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
  "arguments": {
    "date": "2026-11-04"
  },
  "tool": {
    "headers": {
      "Authorization": "Bearer crm-secret"
    },
    "name": "find_slots",
    "timeout_seconds": 10,
    "url": "https://crm.example.com/voice/tools"
  }
}'
```
