Skip to main content
POST
Add a contract revision to a tool
Requires tools:update. Adds one immutable contract revision to a tool that was created through the earlier tool endpoints, so a workflow can use it. Only tools that call your own endpoint, or transfer a call, can take one — anything else returns 422 WORKFLOW_TOOL_IMPORT_REQUIRED.
No other property is accepted — an unexpected key is 400 WORKFLOW_REQUEST_INVALID, with the key in issues[0].path (/name); so is a missing contract (/contract) or a bad expected_revision (/expected_revision). Name, description and the private endpoint configuration come from the saved tool and cannot be set here. Transfer tools always come back restricted to a live call on a phone, and marked as ending the call, whatever the request asked for. Revisions are immutable and additive: workflows that already pinned an earlier revision keep it until they are published again.

What your endpoint receives

A request Yappr makes to this tool’s endpoint carries the call it is serving, as one call member alongside your declared inputs:
One definition, one version. The member is sent on every request to your own endpoint — a before-call request, a tool the agent uses mid-call, a follow-up after the call ends, and a tool test alike. A connected-app action and a transfer do not receive the whole object; they read the same values through {{call.field}} in what you configured, so there is still one definition to learn. Turn it off for one tool with "include_call_context": false in the contract. Your mapped inputs are unaffected: a fixed input that quotes {{call.caller_number}} still arrives filled in, because that is a value you asked for rather than the whole call. Read phase first. The package is graded by what that moment can know, and a member the phase cannot know is absent rather than null — so a missing call_id means there is no call yet, while "caller_number": "" means the call had no number to give (a browser call, or the preview gap above). The nine members Yappr’s webhook tools have always sent — company_id, agent_id, agent_name, call_id, call_direction, caller_number, callee_number, call_metadata and call_variables — keep their names and their empty-string and empty-object convention inside call, so an endpoint written against that payload keeps parsing. A declared input of your own named call wins over the package. A tool test sends the same shape with "test": true inside call, so your endpoint can tell a rehearsal from a call. A real call never carries that member. A test serves no call and no agent, so its call_id (from the during phase on) and agent_id are null, not "". The full field list is the CallPackage schema in the OpenAPI document.

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

x-company-id
string<uuid>

Explicit active workspace. Optional; when sent it must be the API key's own workspace — any other value is refused with 403 WORKSPACE_MISMATCH.

Path Parameters

id
string<uuid>
required

Body

application/json

Exactly these two properties are accepted; any other property is rejected. Identity, description and private endpoint configuration are read from the saved tool and cannot be supplied here.

expected_revision
integer | null
required

The highest revision you last read for this tool, or null when the tool has no revision yet. A mismatch is a conflict and nothing is written.

Required range: x >= 1
contract
object
required

Response

The new revision.

One immutable contract revision of a saved tool. Private endpoint configuration (URL, header values, transfer destination) is never included: it stays on the tool itself and is supplied by Yappr at call time.

id
string<uuid>
required
tool_id
string<uuid>
required
revision
integer
required

Increments by one per revision of this tool. Use the highest value as expected_revision for the next write.

Required range: x >= 1
name
string
required

Copied from the saved tool. It cannot be set through this endpoint.

kind
enum<string>
required

Derived from the saved tool's own type; it cannot be set through this endpoint.

Available options:
http,
transfer
input_schema
object
required
output_schema
object
required
created_at
string<date-time>

When this revision was made. On every row of the list.

description
string
allowed_phases
enum<string>[]

Defaults to all three. Transfer tools are always ["during"], whatever you send.

Available options:
before,
during,
after
allowed_channels
enum<string>[]

Defaults to both. Transfer tools are always ["phone"], whatever you send.

Available options:
phone,
web
timeout_ms
integer
default:30000
effect
string

Defaults to "write". Transfer tools are always "terminal", whatever you send.

replay_safe
boolean
default:false

Transfer tools are always false, whatever you send.

include_call_context
boolean
default:true

Whether every request this tool makes carries the call under call (see CallPackage). Returned only when it is false, because true is what every tool does unless you say otherwise. Turn it off for an endpoint that wants nothing but the inputs you mapped; the inputs themselves still read the call through {{call.field}} either way.