Tests y simulaciones
Tests guionados y simulaciones de un asistente, y el control antes de publicar.
GET /v1/assistants/{assistant_id}/tests
List the test cases of an assistant
Solo para usuarios con sesión iniciada (sin API key) · Rol: viewer o superior
Signed-in users only (an API key cannot call it yet). Any signed-in member. Each case carries `last_run`, its newest run on any target, or `null` when it never ran. 401 when the token is missing, expired or invalid; 404 when the assistant is not in the tenant; 503 when tests are not available.
Parámetros
| Nombre | En | Tipo | Requerido | Descripción |
|---|---|---|---|---|
assistant_id | path | string (uuid) | sí |
Respuestas
200Successful Response · TestCaseListNombre Tipo Requerido Descripción itemsTestCaseResponse[]sí items[].assertionsCriterion | ToolCalled | ToolNotCalled | ReachedStep | EndedWith | Said | NotSaid[]items[].assistant_idstring (uuid)sí items[].created_atstring (date-time)sí items[].idstring (uuid)sí items[].last_runRunSummary | nullitems[].last_run.created_atstring (date-time)sí items[].last_run.finished_atstring (date-time) | nullsí items[].last_run.idstring (uuid)sí items[].last_run.statusstringsí (queued, running, passed, failed, error) items[].max_turnsintegeritems[].namestringsí items[].personastringsí items[].tool_mocksToolMock[]items[].tool_mocks[].argumentsobjectitems[].tool_mocks[].errorbooleanitems[].tool_mocks[].responsestringitems[].tool_mocks[].toolstringsí items[].tool_mode"mock" | "live"(mock, live) items[].updated_atstring (date-time)sí items[].variablesobject401Missing, expired or invalid token. · ErrorResponse403Role below the one in `x-min-role`, a suspended organization, or an API key without the operation's `x-api-key-scope` (any key, if the operation has none). · ErrorResponse404No such assistant, test or run. · ErrorResponse503Tests are not available. · ErrorResponsedefaultDefault Response · ErrorResponse
POST /v1/assistants/{assistant_id}/tests
Create a test case for an assistant
Solo para usuarios con sesión iniciada (sin API key) · Rol: editor o superior
Signed-in users only (an API key cannot call it yet). An `editor` or above. A test case plays the assistant against a simulated caller: `persona` says who the caller is, what they want and how they behave (for example "cannot pay, gets angry, asks for a person"); `variables` are the values of the `{{name}}` the prompts use; `max_turns` (1 to 40, default 12) bounds the conversation. `assertions` are checked after the conversation: `criterion` (`text`, a success criterion in plain language judged by an LLM, with a rationale), `tool_called` (`name`, optional `arguments` that must match, `match` `equals`, `contains` or `regex`), `tool_not_called`, `reached_step` (a step of the conversation tree), `ended_with` (`completed`, `transferred`, `caller_hangup` or `max_turns`), `said` and `not_said` (a phrase the assistant said, ignoring case). `tool_mocks` give a tool a canned `response` (or an error) so no real API is called: a mock names the `tool` and may require `arguments` to match; with `tool_mode` `mock` (default) a tool without a mock answers a stub, with `live` the real tool is called. A knowledge search is mocked by the name `search_kb_<first 8 hex of the base id>`. An assistant has up to 100 cases. Audited as `assistant_test.create`. 401 when the token is missing, expired or invalid; 403 below `editor`; 404 when the assistant is not in the tenant; 409 when it has the most cases; 422 when the body is invalid; 503 when tests are not available.
Parámetros
| Nombre | En | Tipo | Requerido | Descripción |
|---|---|---|---|---|
assistant_id | path | string (uuid) | sí |
Cuerpo de la solicitud
| Nombre | Tipo | Requerido | Descripción |
|---|---|---|---|
assertions | Criterion | ToolCalled | ToolNotCalled | ReachedStep | EndedWith | Said | NotSaid[] | ||
max_turns | integer | ||
name | string | sí | |
persona | string | sí | |
tool_mocks | ToolMock[] | ||
tool_mocks[].arguments | object | ||
tool_mocks[].error | boolean | ||
tool_mocks[].response | string | ||
tool_mocks[].tool | string | sí | |
tool_mode | "mock" | "live" | (mock, live) | |
variables | object |
Respuestas
201Successful Response · TestCaseResponseNombre Tipo Requerido Descripción assertionsCriterion | ToolCalled | ToolNotCalled | ReachedStep | EndedWith | Said | NotSaid[]assistant_idstring (uuid)sí created_atstring (date-time)sí idstring (uuid)sí last_runRunSummary | nulllast_run.created_atstring (date-time)sí last_run.finished_atstring (date-time) | nullsí last_run.idstring (uuid)sí last_run.statusstringsí (queued, running, passed, failed, error) max_turnsintegernamestringsí personastringsí tool_mocksToolMock[]tool_mocks[].argumentsobjecttool_mocks[].errorbooleantool_mocks[].responsestringtool_mocks[].toolstringsí tool_mode"mock" | "live"(mock, live) updated_atstring (date-time)sí variablesobject401Missing, expired or invalid token. · ErrorResponse403Role below the one this needs. · ErrorResponse404No such assistant, test or run. · ErrorResponse503Tests are not available. · ErrorResponsedefaultDefault Response · ErrorResponse
GET /v1/assistants/{assistant_id}/tests/runs
The runs of an assistant's tests, newest first
Solo para usuarios con sesión iniciada (sin API key) · Rol: viewer o superior
Signed-in users only (an API key cannot call it yet). Any signed-in member. Filter by `test_id`, `batch_id` (the runs of one "run all"), `status` (`queued`, `running`, `passed`, `failed` or `error`) or `config_hash`. `limit` is at most 200 (default 50). 401 when the token is missing, expired or invalid; 404 when the assistant is not in the tenant; 503 when tests are not available.
Parámetros
| Nombre | En | Tipo | Requerido | Descripción |
|---|---|---|---|---|
assistant_id | path | string (uuid) | sí | |
test_id | query | string (uuid) | null | ||
batch_id | query | string (uuid) | null | ||
status | query | string | null | ||
config_hash | query | string | null | ||
limit | query | integer |
Respuestas
200Successful Response · RunListNombre Tipo Requerido Descripción itemsRunResponse[]sí items[].batch_idstring (uuid)sí items[].config_hashstringsí items[].created_atstring (date-time)sí items[].finished_atstring (date-time) | nullsí items[].idstring (uuid)sí items[].resultRunResult | nullsí What the simulation runner reports: the conversation and each verdict. items[].result.assertionsAssertionResult[]items[].result.duration_msintegeritems[].result.end_reasonstring | nullitems[].result.errorstring | nullitems[].result.stepsstring[]items[].result.tokensTokenUsageitems[].result.tool_callsToolCallRecord[]items[].result.transcriptTranscriptTurn[]items[].result.usageModelUsage[]items[].started_atstring (date-time) | nullsí items[].statusstringsí (queued, running, passed, failed, error) items[].target"draft" | "published"sí (draft, published) items[].test_idstring (uuid)sí items[].test_namestringsí items[].version_numberinteger | nullsí 401Missing, expired or invalid token. · ErrorResponse403Role below the one in `x-min-role`, a suspended organization, or an API key without the operation's `x-api-key-scope` (any key, if the operation has none). · ErrorResponse404No such assistant, test or run. · ErrorResponse503Tests are not available. · ErrorResponsedefaultDefault Response · ErrorResponse
POST /v1/assistants/{assistant_id}/tests/runs
Run the tests of an assistant
Solo para usuarios con sesión iniciada (sin API key) · Rol: editor o superior
Signed-in users only (an API key cannot call it yet). An `editor` or above. Queues one run for each case in `test_ids`, or for every case of the assistant when it is left out. `target` `draft` (default) plays the current draft, which is what a publish would ship; `published` plays the live version (`409` when it was never published). The runs share a `batch_id` and are played asynchronously by the simulation runner: poll `GET .../tests/runs?batch_id=` until no run is `queued` or `running`. Each run keeps the config it ran against (`config_hash`), the transcript, the verdict of each assertion, the tool calls, the tree steps, the tokens and the duration. The assistant, the simulated caller and the judge all use the assistant's own provider. 401 when the token is missing, expired or invalid; 403 below `editor`; 404 when the assistant or a case is not in the tenant; 409 when `published` is asked and there is no published version; 429 when too many runs of the assistant are waiting; 503 when tests are not available.
Parámetros
| Nombre | En | Tipo | Requerido | Descripción |
|---|---|---|---|---|
assistant_id | path | string (uuid) | sí |
Cuerpo de la solicitud
| Nombre | Tipo | Requerido | Descripción |
|---|---|---|---|
target | "draft" | "published" | (draft, published) | |
test_ids | string (uuid)[] | null |
Respuestas
202Successful Response · RunsStartedNombre Tipo Requerido Descripción batch_idstring (uuid) | nullsí itemsRunResponse[]sí items[].batch_idstring (uuid)sí items[].config_hashstringsí items[].created_atstring (date-time)sí items[].finished_atstring (date-time) | nullsí items[].idstring (uuid)sí items[].resultRunResult | nullsí What the simulation runner reports: the conversation and each verdict. items[].result.assertionsAssertionResult[]items[].result.duration_msintegeritems[].result.end_reasonstring | nullitems[].result.errorstring | nullitems[].result.stepsstring[]items[].result.tokensTokenUsageitems[].result.tool_callsToolCallRecord[]items[].result.transcriptTranscriptTurn[]items[].result.usageModelUsage[]items[].started_atstring (date-time) | nullsí items[].statusstringsí (queued, running, passed, failed, error) items[].target"draft" | "published"sí (draft, published) items[].test_idstring (uuid)sí items[].test_namestringsí items[].version_numberinteger | nullsí 401Missing, expired or invalid token. · ErrorResponse403Role below the one this needs. · ErrorResponse404No such assistant, test or run. · ErrorResponse503Tests are not available. · ErrorResponsedefaultDefault Response · ErrorResponse
GET /v1/assistants/{assistant_id}/tests/runs/{run_id}
One run with its transcript and verdicts
Solo para usuarios con sesión iniciada (sin API key) · Rol: viewer o superior
Signed-in users only (an API key cannot call it yet). Any signed-in member. `result` is `null` until the run is finished. 401 when the token is missing, expired or invalid; 404 when the assistant or the run is not in the tenant; 503 when tests are not available.
Parámetros
| Nombre | En | Tipo | Requerido | Descripción |
|---|---|---|---|---|
assistant_id | path | string (uuid) | sí | |
run_id | path | string (uuid) | sí |
Respuestas
200Successful Response · RunResponseNombre Tipo Requerido Descripción batch_idstring (uuid)sí config_hashstringsí created_atstring (date-time)sí finished_atstring (date-time) | nullsí idstring (uuid)sí resultRunResult | nullsí What the simulation runner reports: the conversation and each verdict. result.assertionsAssertionResult[]result.assertions[].indexintegersí result.assertions[].labelstringsí result.assertions[].passedbooleansí result.assertions[].rationalestringresult.assertions[].typestringsí result.duration_msintegerresult.end_reasonstring | nullresult.errorstring | nullresult.stepsstring[]result.tokensTokenUsageresult.tokens.assistant_completionintegerresult.tokens.assistant_promptintegerresult.tokens.caller_completionintegerresult.tokens.caller_promptintegerresult.tokens.judge_completionintegerresult.tokens.judge_promptintegerresult.tool_callsToolCallRecord[]result.tool_calls[].argumentsobjectresult.tool_calls[].is_errorbooleanresult.tool_calls[].mockedbooleanresult.tool_calls[].namestringsí result.tool_calls[].outputstring | nullresult.transcriptTranscriptTurn[]result.transcript[].role"caller" | "assistant"sí (caller, assistant) result.transcript[].stepstring | nullresult.transcript[].textstringsí result.usageModelUsage[]result.usage[].input_tokensintegerresult.usage[].modelstringsí result.usage[].output_tokensintegerresult.usage[].providerstringsí result.usage[].role"assistant" | "caller" | "judge"sí (assistant, caller, judge) started_atstring (date-time) | nullsí statusstringsí (queued, running, passed, failed, error) target"draft" | "published"sí (draft, published) test_idstring (uuid)sí test_namestringsí version_numberinteger | nullsí 401Missing, expired or invalid token. · ErrorResponse403Role below the one in `x-min-role`, a suspended organization, or an API key without the operation's `x-api-key-scope` (any key, if the operation has none). · ErrorResponse404No such assistant, test or run. · ErrorResponse503Tests are not available. · ErrorResponsedefaultDefault Response · ErrorResponse
GET /v1/assistants/{assistant_id}/tests/settings
Whether publishing needs the tests to pass
Solo para usuarios con sesión iniciada (sin API key) · Rol: viewer o superior
Signed-in users only (an API key cannot call it yet). Any signed-in member. 401 when the token is missing, expired or invalid; 404 when the assistant is not in the tenant; 503 when tests are not available.
Parámetros
| Nombre | En | Tipo | Requerido | Descripción |
|---|---|---|---|---|
assistant_id | path | string (uuid) | sí |
Respuestas
200Successful Response · TestSettingsResponseNombre Tipo Requerido Descripción require_pass_before_publishbooleansí 401Missing, expired or invalid token. · ErrorResponse403Role below the one in `x-min-role`, a suspended organization, or an API key without the operation's `x-api-key-scope` (any key, if the operation has none). · ErrorResponse404No such assistant, test or run. · ErrorResponse503Tests are not available. · ErrorResponsedefaultDefault Response · ErrorResponse
PUT /v1/assistants/{assistant_id}/tests/settings
Require the tests to pass before publishing
Solo para usuarios con sesión iniciada (sin API key) · Rol: editor o superior
Signed-in users only (an API key cannot call it yet). An `editor` or above. With `require_pass_before_publish` `true`, `POST /v1/assistants/{id}/publish` answers `409` with code `tests_failing` unless every case has a run that passed on the current draft; the message links the runs to look at. An assistant without cases publishes freely. Audited as `assistant_test.require`. 401 when the token is missing, expired or invalid; 403 below `editor`; 404 when the assistant is not in the tenant; 503 when tests are not available.
Parámetros
| Nombre | En | Tipo | Requerido | Descripción |
|---|---|---|---|---|
assistant_id | path | string (uuid) | sí |
Cuerpo de la solicitud
| Nombre | Tipo | Requerido | Descripción |
|---|---|---|---|
require_pass_before_publish | boolean | sí |
Respuestas
200Successful Response · TestSettingsResponseNombre Tipo Requerido Descripción require_pass_before_publishbooleansí 401Missing, expired or invalid token. · ErrorResponse403Role below the one this needs. · ErrorResponse404No such assistant, test or run. · ErrorResponse503Tests are not available. · ErrorResponsedefaultDefault Response · ErrorResponse
GET /v1/assistants/{assistant_id}/tests/{test_id}
One test case
Solo para usuarios con sesión iniciada (sin API key) · Rol: viewer o superior
Signed-in users only (an API key cannot call it yet). Any signed-in member. 401 when the token is missing, expired or invalid; 404 when the assistant or the case is not in the tenant; 503 when tests are not available.
Parámetros
| Nombre | En | Tipo | Requerido | Descripción |
|---|---|---|---|---|
assistant_id | path | string (uuid) | sí | |
test_id | path | string (uuid) | sí |
Respuestas
200Successful Response · TestCaseResponseNombre Tipo Requerido Descripción assertionsCriterion | ToolCalled | ToolNotCalled | ReachedStep | EndedWith | Said | NotSaid[]assistant_idstring (uuid)sí created_atstring (date-time)sí idstring (uuid)sí last_runRunSummary | nulllast_run.created_atstring (date-time)sí last_run.finished_atstring (date-time) | nullsí last_run.idstring (uuid)sí last_run.statusstringsí (queued, running, passed, failed, error) max_turnsintegernamestringsí personastringsí tool_mocksToolMock[]tool_mocks[].argumentsobjecttool_mocks[].errorbooleantool_mocks[].responsestringtool_mocks[].toolstringsí tool_mode"mock" | "live"(mock, live) updated_atstring (date-time)sí variablesobject401Missing, expired or invalid token. · ErrorResponse403Role below the one in `x-min-role`, a suspended organization, or an API key without the operation's `x-api-key-scope` (any key, if the operation has none). · ErrorResponse404No such assistant, test or run. · ErrorResponse503Tests are not available. · ErrorResponsedefaultDefault Response · ErrorResponse
PUT /v1/assistants/{assistant_id}/tests/{test_id}
Replace a test case
Solo para usuarios con sesión iniciada (sin API key) · Rol: editor o superior
Signed-in users only (an API key cannot call it yet). An `editor` or above replaces the whole case (same body as create). Runs already made keep the case as it was when they ran. Audited as `assistant_test.update`. 401 when the token is missing, expired or invalid; 403 below `editor`; 404 when the assistant or the case is not in the tenant; 422 when the body is invalid; 503 when tests are not available.
Parámetros
| Nombre | En | Tipo | Requerido | Descripción |
|---|---|---|---|---|
assistant_id | path | string (uuid) | sí | |
test_id | path | string (uuid) | sí |
Cuerpo de la solicitud
| Nombre | Tipo | Requerido | Descripción |
|---|---|---|---|
assertions | Criterion | ToolCalled | ToolNotCalled | ReachedStep | EndedWith | Said | NotSaid[] | ||
max_turns | integer | ||
name | string | sí | |
persona | string | sí | |
tool_mocks | ToolMock[] | ||
tool_mocks[].arguments | object | ||
tool_mocks[].error | boolean | ||
tool_mocks[].response | string | ||
tool_mocks[].tool | string | sí | |
tool_mode | "mock" | "live" | (mock, live) | |
variables | object |
Respuestas
200Successful Response · TestCaseResponseNombre Tipo Requerido Descripción assertionsCriterion | ToolCalled | ToolNotCalled | ReachedStep | EndedWith | Said | NotSaid[]assistant_idstring (uuid)sí created_atstring (date-time)sí idstring (uuid)sí last_runRunSummary | nulllast_run.created_atstring (date-time)sí last_run.finished_atstring (date-time) | nullsí last_run.idstring (uuid)sí last_run.statusstringsí (queued, running, passed, failed, error) max_turnsintegernamestringsí personastringsí tool_mocksToolMock[]tool_mocks[].argumentsobjecttool_mocks[].errorbooleantool_mocks[].responsestringtool_mocks[].toolstringsí tool_mode"mock" | "live"(mock, live) updated_atstring (date-time)sí variablesobject401Missing, expired or invalid token. · ErrorResponse403Role below the one this needs. · ErrorResponse404No such assistant, test or run. · ErrorResponse503Tests are not available. · ErrorResponsedefaultDefault Response · ErrorResponse
DELETE /v1/assistants/{assistant_id}/tests/{test_id}
Delete a test case and its runs
Solo para usuarios con sesión iniciada (sin API key) · Rol: editor o superior
Signed-in users only (an API key cannot call it yet). An `editor` or above. Audited as `assistant_test.delete`. 401 when the token is missing, expired or invalid; 403 below `editor`; 404 when the assistant or the case is not in the tenant; 503 when tests are not available.
Parámetros
| Nombre | En | Tipo | Requerido | Descripción |
|---|---|---|---|---|
assistant_id | path | string (uuid) | sí | |
test_id | path | string (uuid) | sí |
Respuestas
204Successful Response401Missing, expired or invalid token. · ErrorResponse403Role below the one this needs. · ErrorResponse404No such assistant, test or run. · ErrorResponse503Tests are not available. · ErrorResponsedefaultDefault Response · ErrorResponse
POST /v1/assistants/{assistant_id}/tests/{test_id}/runs
Run one test case
Solo para usuarios con sesión iniciada (sin API key) · Rol: editor o superior
Signed-in users only (an API key cannot call it yet). An `editor` or above. Queues a run of the case against `target` (`draft` by default, or `published`); see `runAssistantTests` for how runs are played and read. 401 when the token is missing, expired or invalid; 403 below `editor`; 404 when the assistant or the case is not in the tenant; 409 when `published` is asked and there is no published version; 429 when too many runs are waiting; 503 when tests are not available.
Parámetros
| Nombre | En | Tipo | Requerido | Descripción |
|---|---|---|---|---|
assistant_id | path | string (uuid) | sí | |
test_id | path | string (uuid) | sí |
Cuerpo de la solicitud
| Nombre | Tipo | Requerido | Descripción |
|---|---|---|---|
target | "draft" | "published" | (draft, published) |
Respuestas
202Successful Response · RunResponseNombre Tipo Requerido Descripción batch_idstring (uuid)sí config_hashstringsí created_atstring (date-time)sí finished_atstring (date-time) | nullsí idstring (uuid)sí resultRunResult | nullsí What the simulation runner reports: the conversation and each verdict. result.assertionsAssertionResult[]result.assertions[].indexintegersí result.assertions[].labelstringsí result.assertions[].passedbooleansí result.assertions[].rationalestringresult.assertions[].typestringsí result.duration_msintegerresult.end_reasonstring | nullresult.errorstring | nullresult.stepsstring[]result.tokensTokenUsageresult.tokens.assistant_completionintegerresult.tokens.assistant_promptintegerresult.tokens.caller_completionintegerresult.tokens.caller_promptintegerresult.tokens.judge_completionintegerresult.tokens.judge_promptintegerresult.tool_callsToolCallRecord[]result.tool_calls[].argumentsobjectresult.tool_calls[].is_errorbooleanresult.tool_calls[].mockedbooleanresult.tool_calls[].namestringsí result.tool_calls[].outputstring | nullresult.transcriptTranscriptTurn[]result.transcript[].role"caller" | "assistant"sí (caller, assistant) result.transcript[].stepstring | nullresult.transcript[].textstringsí result.usageModelUsage[]result.usage[].input_tokensintegerresult.usage[].modelstringsí result.usage[].output_tokensintegerresult.usage[].providerstringsí result.usage[].role"assistant" | "caller" | "judge"sí (assistant, caller, judge) started_atstring (date-time) | nullsí statusstringsí (queued, running, passed, failed, error) target"draft" | "published"sí (draft, published) test_idstring (uuid)sí test_namestringsí version_numberinteger | nullsí 401Missing, expired or invalid token. · ErrorResponse403Role below the one this needs. · ErrorResponse404No such assistant, test or run. · ErrorResponse503Tests are not available. · ErrorResponsedefaultDefault Response · ErrorResponse