curl --request POST \
--url https://api.goyappr.com/agents/{id}/workflow/train \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"call_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"retry": false
}
'import requests
url = "https://api.goyappr.com/agents/{id}/workflow/train"
payload = {
"call_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"retry": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({call_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a', retry: false})
};
fetch('https://api.goyappr.com/agents/{id}/workflow/train', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.goyappr.com/agents/{id}/workflow/train",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'call_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'retry' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.goyappr.com/agents/{id}/workflow/train"
payload := strings.NewReader("{\n \"call_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"retry\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.goyappr.com/agents/{id}/workflow/train")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"call_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"retry\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.goyappr.com/agents/{id}/workflow/train")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"call_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"retry\": false\n}"
response = http.request(request)
puts response.read_body{
"run": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"call_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "claimed",
"reasons": [
{
"code": "<string>",
"op_index": 123,
"detail": "<string>"
}
],
"can_undo": true,
"can_retry": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"step": "gates",
"attempt": 123,
"reason": "no_instruction",
"summary": "<string>",
"changes": [
{
"op_index": 1,
"op": "add",
"target": {
"kind": "global",
"node_id": "<string>"
},
"target_label": "<string>",
"before": "<string>",
"after": "<string>",
"directive": "<string>",
"evidence": [
{
"turn": 1,
"quote": "<string>"
}
],
"title": "<string>",
"sensitive": [
"prohibition_removed"
]
}
],
"base_revision": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"version": 123
},
"result_revision": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"version": 123
},
"retry_after_ms": 123,
"finished_at": "2023-11-07T05:31:56Z"
},
"wait": "call_running",
"retry_after_ms": 123
}{
"run": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"call_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "claimed",
"reasons": [
{
"code": "<string>",
"op_index": 123,
"detail": "<string>"
}
],
"can_undo": true,
"can_retry": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"step": "gates",
"attempt": 123,
"reason": "no_instruction",
"summary": "<string>",
"changes": [
{
"op_index": 1,
"op": "add",
"target": {
"kind": "global",
"node_id": "<string>"
},
"target_label": "<string>",
"before": "<string>",
"after": "<string>",
"directive": "<string>",
"evidence": [
{
"turn": 1,
"quote": "<string>"
}
],
"title": "<string>",
"sensitive": [
"prohibition_removed"
]
}
],
"base_revision": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"version": 123
},
"result_revision": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"version": 123
},
"retry_after_ms": 123,
"finished_at": "2023-11-07T05:31:56Z"
},
"wait": "call_running",
"retry_after_ms": 123
}{
"error": "<string>",
"code": "<string>",
"issues": [
{
"code": "<string>",
"path": "<string>",
"message": "<string>",
"node_id": "<string>",
"label": "<string>",
"tool_name": "<string>",
"field": "<string>"
}
],
"warnings": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>",
"node_id": "<string>",
"label": "<string>",
"tool_name": "<string>",
"field": "<string>"
}
]
}{
"error": "<string>",
"code": "<string>",
"issues": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>"
}
]
}{
"error": "<string>",
"code": "<string>",
"issues": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>"
}
],
"reason": "<string>",
"retry_after_ms": 123
}{
"error": "<string>",
"code": "<string>",
"issues": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>"
}
],
"reason": "<string>",
"retry_after_ms": 123
}{
"error": "<string>",
"code": "<string>",
"issues": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>"
}
],
"reason": "<string>",
"retry_after_ms": 123
}{
"error": "<string>",
"code": "<string>",
"issues": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>"
}
],
"reason": "<string>",
"retry_after_ms": 123
}{
"error": "<string>",
"code": "<string>",
"issues": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>"
}
],
"reason": "<string>",
"retry_after_ms": 123
}{
"error": "<string>",
"code": "<string>",
"issues": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>"
}
],
"reason": "<string>",
"retry_after_ms": 123
}Teach an agent from a test call
Update a workflow agent’s instructions from what you said on a web test call, and publish them live.
curl --request POST \
--url https://api.goyappr.com/agents/{id}/workflow/train \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"call_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"retry": false
}
'import requests
url = "https://api.goyappr.com/agents/{id}/workflow/train"
payload = {
"call_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"retry": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({call_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a', retry: false})
};
fetch('https://api.goyappr.com/agents/{id}/workflow/train', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.goyappr.com/agents/{id}/workflow/train",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'call_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'retry' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.goyappr.com/agents/{id}/workflow/train"
payload := strings.NewReader("{\n \"call_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"retry\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.goyappr.com/agents/{id}/workflow/train")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"call_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"retry\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.goyappr.com/agents/{id}/workflow/train")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"call_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"retry\": false\n}"
response = http.request(request)
puts response.read_body{
"run": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"call_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "claimed",
"reasons": [
{
"code": "<string>",
"op_index": 123,
"detail": "<string>"
}
],
"can_undo": true,
"can_retry": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"step": "gates",
"attempt": 123,
"reason": "no_instruction",
"summary": "<string>",
"changes": [
{
"op_index": 1,
"op": "add",
"target": {
"kind": "global",
"node_id": "<string>"
},
"target_label": "<string>",
"before": "<string>",
"after": "<string>",
"directive": "<string>",
"evidence": [
{
"turn": 1,
"quote": "<string>"
}
],
"title": "<string>",
"sensitive": [
"prohibition_removed"
]
}
],
"base_revision": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"version": 123
},
"result_revision": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"version": 123
},
"retry_after_ms": 123,
"finished_at": "2023-11-07T05:31:56Z"
},
"wait": "call_running",
"retry_after_ms": 123
}{
"run": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"call_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "claimed",
"reasons": [
{
"code": "<string>",
"op_index": 123,
"detail": "<string>"
}
],
"can_undo": true,
"can_retry": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"step": "gates",
"attempt": 123,
"reason": "no_instruction",
"summary": "<string>",
"changes": [
{
"op_index": 1,
"op": "add",
"target": {
"kind": "global",
"node_id": "<string>"
},
"target_label": "<string>",
"before": "<string>",
"after": "<string>",
"directive": "<string>",
"evidence": [
{
"turn": 1,
"quote": "<string>"
}
],
"title": "<string>",
"sensitive": [
"prohibition_removed"
]
}
],
"base_revision": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"version": 123
},
"result_revision": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"version": 123
},
"retry_after_ms": 123,
"finished_at": "2023-11-07T05:31:56Z"
},
"wait": "call_running",
"retry_after_ms": 123
}{
"error": "<string>",
"code": "<string>",
"issues": [
{
"code": "<string>",
"path": "<string>",
"message": "<string>",
"node_id": "<string>",
"label": "<string>",
"tool_name": "<string>",
"field": "<string>"
}
],
"warnings": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>",
"node_id": "<string>",
"label": "<string>",
"tool_name": "<string>",
"field": "<string>"
}
]
}{
"error": "<string>",
"code": "<string>",
"issues": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>"
}
]
}{
"error": "<string>",
"code": "<string>",
"issues": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>"
}
],
"reason": "<string>",
"retry_after_ms": 123
}{
"error": "<string>",
"code": "<string>",
"issues": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>"
}
],
"reason": "<string>",
"retry_after_ms": 123
}{
"error": "<string>",
"code": "<string>",
"issues": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>"
}
],
"reason": "<string>",
"retry_after_ms": 123
}{
"error": "<string>",
"code": "<string>",
"issues": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>"
}
],
"reason": "<string>",
"retry_after_ms": 123
}{
"error": "<string>",
"code": "<string>",
"issues": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>"
}
],
"reason": "<string>",
"retry_after_ms": 123
}{
"error": "<string>",
"code": "<string>",
"issues": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>"
}
],
"reason": "<string>",
"retry_after_ms": 123
}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.
curl -X POST 'https://api.goyappr.com/agents/AGENT_ID/workflow/train' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'x-company-id: COMPANY_ID' \
-H 'Content-Type: application/json' \
-d '{"call_id":"CALL_ID"}'
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_VERSIONotherwise). - 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 with403 TEACH_ACTOR_REQUIRED. - Workflow agents with a published version. Other agents answer
422 AGENT_ENGINE_UNSUPPORTEDor422 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 is200 when the run has finished and 202 while it
is working:
{ "run": { "id": "…", "status": "running", "step": "llm", "retry_after_ms": 3000 }, "retry_after_ms": 3000 }
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:
| Status | Meaning |
|---|---|
applied | The new instructions are live. changes[] shows each edit as it read before and after, with the words you said that it rests on, and summary is one sentence on what changed, or null when none could be written (read changes[]). |
no_change | There was nothing to change (you gave no instruction, the call was too short, the request was only role-play, or it was about the opening line, which Teach does not edit). reason says which. |
held | Refused on purpose, and nothing live changed: the edit would have gone beyond a small change, lost a tool or a variable, touched a number or a prohibition the call did not support, or the agent had unpublished changes in its draft. reason and reasons[] say why. |
failed | Something went wrong (the transcript did not arrive, the model did not answer, publishing could not be confirmed). can_retry says whether retry: true is allowed; it is false for anyone but the person who requested the run. |
reverted | The run was undone from the dashboard. |
claimed, waiting_transcript, running, put_done | In progress. Ask again after retry_after_ms. |
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’sbase_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
| Status | Code | Meaning |
|---|---|---|
| 400 | WORKFLOW_REQUEST_INVALID | call_id missing or not a UUID, another field, or a query parameter. |
| 403 | TEACH_FORBIDDEN_ROLE, TEACH_ACTOR_REQUIRED, TEACH_DISABLED | See above. TEACH_DISABLED: teaching is switched off. |
| 404 | AGENT_NOT_FOUND, TEACH_CALL_NOT_FOUND, TEACH_RUN_NOT_FOUND | Nothing with that id in this workspace. |
| 409 | TEACH_AGENT_BUSY, TEACH_CALL_NOT_ON_LIVE_VERSION, TEACH_RETRY_NOT_ALLOWED | Another run is working on the agent; the call ran on an older version; the run cannot be retried (not held or failed, 5 retries used, or another owner or admin started the run, in which case the answer’s reason is not_requester). |
| 422 | TEACH_CALL_AGENT_MISMATCH, TEACH_CALL_NOT_WEB, TEACH_CALL_TOO_OLD, TEACH_CALL_RUN_UNAVAILABLE, TEACH_ENVIRONMENT_MISMATCH, AGENT_ENGINE_UNSUPPORTED, TEACH_AGENT_NOT_PUBLISHED | The call or the agent cannot be taught from. |
| 429 | TEACH_DAILY_LIMIT | Three applied runs for this agent in the last 24 hours. |
error and code; see Errors.Authorizations
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).