Skip to main content
POST
Teach the agent from a test call
Requires agents:update and calls:read (reading the run needs agents:read and calls:read): Teach reads the call’s transcript. After a web test call (a call made from the dashboard’s test panel or a test link), you can tell the agent what to do differently, in your own words, during the call. Teach reads the finished call, makes a small checked edit to the agent’s instructions, and publishes it live. The next call runs the new instructions.
string
required
Local agent UUID. It must be the agent the call was made to.
string
required
The finished web test call’s id.
boolean
default:"false"
true runs again a run that ended held or failed, up to 5 times per run.

Who and what it works on

  • Web test calls only. A phone call is refused with 422 TEACH_CALL_NOT_WEB. The call must be less than 30 minutes old and must have run on the agent’s version that is live now (409 TEACH_CALL_NOT_ON_LIVE_VERSION otherwise).
  • Owner or admin only. The API key’s owner must be an owner or admin of the workspace (403 TEACH_FORBIDDEN_ROLE). Any owner or admin of the workspace can teach from a recent browser test call of the agent, not only the person who took the call. A key with no owner is refused with 403 TEACH_ACTOR_REQUIRED.
  • Workflow agents with a published version. Other agents answer 422 AGENT_ENGINE_UNSUPPORTED or 422 TEACH_AGENT_NOT_PUBLISHED.
  • Three applied runs per agent in 24 hours (429 TEACH_DAILY_LIMIT), and one run at a time per agent (409 TEACH_AGENT_BUSY).

It is idempotent per call

Sending the same request again returns the same run, so the way to wait is to send it again. The answer is 200 when the run has finished and 202 while it is working:
Wait retry_after_ms and send the same request. If the call has not ended yet, the answer is 202 with run: null and wait: "call_running". A run that finished is never started again for the same call, except by retry.

What a finished run says

status is one of: GET /agents/{id}/workflow/train?call_id=CALL_ID returns the same run without starting or changing anything (run is null when nobody taught from that call).

Undo

An applied run publishes a new version. To undo it, call Restore workflow version with the run’s base_revision.id. The restore is a roll-forward: it publishes the earlier workflow as another new version and is not guaranteed to be byte-identical to it. In the version list the run’s version shows source: "teach", and the restored one source: "restore".

Refusals

Every refusal carries error and code; see 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

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
call_id
string<uuid>
required

The finished web test call to teach from, the call's id.

retry
boolean
default:false

True starts a run that ended held or failed again (up to 5 times per run).

Response

The run has finished (applied, no_change, held, failed or reverted).

run
null | object
required
wait
string

Present with run null while the call has not ended; ask again after retry_after_ms.

Allowed value: "call_running"
retry_after_ms
integer