Create a prompt test case
/v1/prompts/{slug}/test-casesCreate a prompt test case.
Adds a test case: variables to render the prompt with and an optional pattern the answer must match. Run them with POST /v1/prompts/{slug/test-cases/run}. Requires an admin of the prompt's workspace, or an organization admin. 404 when the prompt does not exist.
Authorization
AuthorizationBearer va_A platform API key (
va_...), created under Settings > API keys. Scoped to an organization or one workspace, with an admin or member role. Used by the management API.
Path parameters
slugstringrequiredthe prompt's slug
Query parameters
organizationstringrequiredslug of the organization that owns it
Request body application/json
the test case
namestringrequiredA name for the test case (required).
variables_jsonmap<string, string>requiredThe variable values to render the prompt with, as a JSON object of strings, for example
{"customer": "Ada"} (required; may be empty).expected_patternstringWhat a passing answer contains: a regular expression, matched case-insensitively anywhere in the answer (a value that is not a valid regular expression is matched as a case-insensitive substring). Omit it to pass every answer that completes.
Responses
Created
idstringThe test case's unique id (UUID).
prompt_idstringId (UUID) of the prompt.
namestringThe test case's name.
variables_jsonmap<string, string>The variable values the prompt is rendered with, as a JSON object of strings.
expected_patternstringThe pattern a passing answer matches: a case-insensitive regular expression, or a substring when it is not a valid regular expression. Null when every completed answer passes.
created_atstring<date-time>When the test case was created (ISO 8601).