Skip to main content
POST
Test a saved tool
This page documents two different contracts on one URL. Which one you get depends on the tool, not on what you send:Everything down to Legacy webhook tools is the asynchronous contract. Everything from that heading on is the legacy one, and the two never mix: a legacy body cannot execute a workflow-owned tool, and a workflow test never returns payload_sent.

Workflow-owned tools

Workflow-owned tools use one standalone test in the shared execution journal, with the same preparation, claim and receipt path as workflow actions. This creates no fake agent or phone/web call. Required scope: tools:update.
A tool whose creation failed has no revision to test: the request answers 409 WORKFLOW_TOOL_NOT_READY, and error names the failure (for example connection_unavailable). Fix it with PATCH /tools/{id} first. The 202 response includes local test_id, run_id, tool_id, and frozen revision_id. Poll Get saved test. The optional revision_id pins a specific revision of this tool; otherwise the current head is frozen at acceptance. Same-key replay retains the original revision even after the head changes. Altering the accepted body returns 409; replay under a different original user/API key returns 404 without revealing the existing test. Mock is the default and makes no HTTP/app request. It validates typed input and mock output against the frozen schemas. Unless revision_id pins another revision, inputs and mock_output are also read against the tool’s current schemas before the test is accepted: a missing required input, a field the schema does not have, a value of the wrong type or outside its enum answers 422 WORKFLOW_TOOL_TEST_INVALID with issues[0].path at that value — /inputs/order_id, /mock_output/found — instead of 202 and a test that later settles failed. The body itself is read first: a field a test does not take, a missing or unknown phase or channel, inputs that is missing or not an object (send {} when the tool takes none) and a revision_id that is not an id each answer 422 WORKFLOW_TOOL_TEST_INVALID with issues[0].path naming it. policy: "allowlist" with allowed_binding_ids: ["test_tool"] is explicit permission for this exact binding’s effect through the shared executor; an empty allowlist does not grant effects. Never use real here. Fixed account, action, version, URL/destination and fixed inputs cannot be overridden.
"test_tool" is the whole of allowed_binding_ids. A saved-tool test runs the tool on its own, outside any workflow, so it has exactly one binding and test_tool is that binding’s id — it is a fixed word, not a binding id copied out of your published workflow. The field accepts only [] or ["test_tool"], and only ["test_tool"] grants the effect:policy: "real" is not a value this endpoint takes.
phase and channel are validation placement, not live-call authority. Standalone transfer tests require during/phone and are mock-only. A real transfer requires an actual live phone assignment. A workflow-owned tool’s test request carries the same call member a real call sends (see Add a tool contract revision), with "test": true inside it. That member is the one reliable way for your endpoint to tell a rehearsal from a call; a real call never carries it. A test’s call.call_id and call.agent_id are null — it serves no call and no agent. An empty answer (a 204, or a 200 with no body) is {} for a tool whose Outputs declare no fields, so it passes; a tool that declares Outputs reads it as an answer without them. A real test of a webhook (http) tool — policy: "allowlist" with ["test_tool"] — is recorded in the delivery log once the request has actually gone out and settled: List Deliveries returns it with call_id: null, source: "test" and the tool’s tool_id, exactly like a legacy test, and the test’s delivery_id names that row (see Get saved test): one request, one verdict on both — delivered and succeeded, failed and failed, unknown and unknown. A mock test sends nothing, and a connected-app action is not a webhook, so neither writes a row there and delivery_id stays null. Outcome output is a bounded, redacted preview—not raw vendor evidence, a receipt replacement, or a new execution input. Check redaction, receipt_settled_test, and resolution; generic success does not imply asynchronous remote work finished.

Legacy webhook tools only

Everything below this line is the synchronous contract, and it applies only to existing legacy webhook tools — the ones saved with type and config rather than workflow. A workflow-owned tool never answers this way: it answers 202 and is polled. This half of the page is a migration boundary and will be retired with the tools it describes. The following contract applies only to existing legacy webhook tools. It cannot execute a workflow-owned tool or use a workflow-owned agent as override authority. Send one request with the existing webhook payload contract. The tool must belong to the API key’s company. Required scope: tools:update.

Legacy: basic test

With no request body, Yappr generates a <test_name> value for every configured extraction parameter:
The delivery uses the tool’s saved URL, HTTP method, headers, static parameters, include_standard_metadata, and timeout_seconds (default 30 seconds; allowed range 1–60). The attempt is recorded in the delivery log like any other. It happens on no call, so List Deliveries returns it with call_id: null and source: "test" — ?source=test&tool_id=TOOL_ID is every rehearsal you have run for this tool, and ?source=live leaves them out of a delivery-health report. Configured headers may include authorization and custom content types, but request-routing/framing headers (Host, Content-Length, Transfer-Encoding, Connection, Expect, Keep-Alive, Proxy-*, TE, Trailer, Upgrade) are rejected when the tool is saved. Webhook targets must be final public HTTP(S) endpoints. Localhost, cloud-metadata hosts, non-global literal or DNS-resolved addresses, mixed public/private DNS answers, and redirects are rejected. Configure the final destination URL directly; redirects are not followed.

Legacy: supply representative values

Use an optional JSON body when the receiver needs realistic argument or call-context samples:
Unknown top-level, context, or argument names are rejected rather than silently forwarded.

Legacy: production parity

When include_standard_metadata is true (the default), payload_sent includes the real company id, the supplied agent context (or null agent fields), call context, configured static parameters, and extraction arguments. With it set to false, only static and extraction parameters are sent.
  • POST, PUT, PATCH, and DELETE tools receive the flat payload as JSON.
  • GET tools receive the same fields as query parameters and no request body. Object and array values are compact JSON strings.
  • Configured request headers are used for delivery but are never echoed in the API response.

Legacy: success response

Any downstream HTTP 2xx status returns 200 from this endpoint. Redirects and every other non-2xx status are delivery failures:
payload_sent is the exact flat object delivered. delivery_id can be null if delivery logging failed; logging failure does not turn a successful downstream request into a failure.

Legacy: delivery failure

A downstream HTTP or network failure returns 502; a timeout returns 504:
code is one of DOWNSTREAM_HTTP_ERROR, WEBHOOK_NETWORK_ERROR, or WEBHOOK_TIMEOUT. Downstream body previews are sanitized and length-capped. A host that resolves to a loopback, private or link-local address — when the test starts or when the request connects (a name that rebinds) — is not a delivery: nothing is sent and the test answers 400 with error “Webhook URL’s hostname resolves to a loopback, private or link-local address; use a public address”.

Legacy: errors

Authorizations

Authorization
string
header
required

Your Yappr API key (e.g. ypr_live_...). Generate one in the dashboard under Settings → API Keys. No key is 401 MISSING_KEY; a key that is not one of ours, or is revoked, is 401 INVALID_KEY; an expired one is 401 EXPIRED_KEY. A valid key without the scope an operation needs is 403 INSUFFICIENT_SCOPE on every operation, and the message names the scope. Every response, a 401 included, carries X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset: the budget is 60 requests a minute per API key. Every 429, whatever its code, carries Retry-After (whole seconds, never zero): the per-key budget's RATE_LIMIT asks for what is left of the minute, a route's daily cap (RATE_LIMITED) for the time until that cap resets. All four headers are listed in Access-Control-Expose-Headers, so a browser can read them. A path the API does not serve (an unknown sub-path, an id left empty) is 404 ROUTE_NOT_FOUND, and a method a served path does not take is 405 METHOD_NOT_ALLOWED with an Allow header; both are answered before any scope check, and nothing is read or changed. A trailing slash is ignored where it cannot be an id left empty (POST /calls/ is POST /calls) and refused where it can (GET /calls/). A doubled slash inside a path is merged into one before the request reaches the API (GET //calls is GET /calls).

Headers

Idempotency-Key
string

Required for workflow tools. Bound to workspace, tool, environment, original author and normalized accepted request.

Pattern: ^[A-Za-z0-9_-]{16,128}$

Path Parameters

id
string<uuid>
required

Body

application/json
phase
enum<string>
required

Validation placement only, never live-call authority.

Available options:
before,
during,
after
channel
enum<string>
required

Must be allowed by the pinned tool. Does not place a call.

Available options:
phone,
web
inputs
object
required

Exact typed JSON inputs, maximum 256 KiB. Fixed app fields cannot be overridden.

mock_output
any

Typed output used by mock execution, maximum 256 KiB. Must validate against the frozen output schema. Left out, the mock answers the output schema's minimal value ({} for {type: object}); a schema with required members needs it (400 field_required at /mock_output otherwise).

policy
enum<string>
default:mock
Available options:
mock,
allowlist
allowed_binding_ids
any[]

The one binding a saved-tool test has, whose id is always the literal test_tool - a binding id out of a workflow is refused. ["test_tool"] with policy allowlist permits that binding's single real effect; [] (the default, and the only value a mock test may send) keeps the test mocked; [] with policy allowlist grants nothing and is refused 422 at /allowed_binding_ids. Transfer effects are always forbidden in saved-tool tests.

Maximum array length: 1
revision_id
string<uuid> | null

Optional exact revision of this tool. Omission freezes the current head at initial acceptance; same-key replay retains that original revision.

Response

Downstream endpoint returned an HTTP 2xx status

success
boolean
required
status_code
integer
required
response_body
string
required

Sanitized, length-capped preview of the downstream response body.

payload_sent
object
required

Exact flat payload delivered to the tool's webhook URL.

delivery_id
string<uuid> | null
required

Webhook-delivery log ID. Null only if logging failed; logging does not change delivery success.