> ## Documentation Index
> Fetch the complete documentation index at: https://docs.magpipe.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Test Case

> Create a test case inside a suite with assertions for phrases, functions, and call duration

Creates a test case inside a suite. Test cases define a scenario — the call direction, how the test caller behaves, and what assertions to validate after the call completes.

## Body Parameters

<ParamField body="action" type="string" required>
  Must be `create_case`
</ParamField>

<ParamField body="suite_id" type="string" required>
  UUID of the test suite this case belongs to.
</ParamField>

<ParamField body="name" type="string" required>
  Display name for the test case.

  **Example:** `"Caller asks about business hours"`
</ParamField>

<ParamField body="description" type="string">
  What this test case validates.
</ParamField>

<ParamField body="type" type="string" default="inbound_call">
  Call direction. `inbound_call` — test caller dials the agent. `outbound_call` — agent calls the test number.
</ParamField>

<ParamField body="agent_id" type="string">
  UUID of the agent to test. If omitted, uses the agent associated with the test suite.
</ParamField>

<ParamField body="caller_mode" type="string" default="silent">
  How the test caller behaves. `silent` — stays quiet (tests greeting/opening). `scripted` — speaks from `caller_script`.
</ParamField>

<ParamField body="caller_script" type="array">
  Array of strings the test caller speaks, one per turn. Used when `caller_mode` is `scripted`.

  **Example:** `["Hi, what are your hours?", "Can I book for tomorrow?"]`
</ParamField>

<ParamField body="expected_phrases" type="array">
  Phrases that must appear in the transcript. Case-insensitive substring matching.

  **Example:** `["Monday through Friday", "9 AM to 5 PM"]`
</ParamField>

<ParamField body="prohibited_phrases" type="array">
  Phrases that must NOT appear. Test fails if any are found.

  **Example:** `["I don't know", "I'm not sure"]`
</ParamField>

<ParamField body="expected_functions" type="array">
  Custom function names that must be called during the conversation.

  **Example:** `["book_appointment", "send_confirmation_sms"]`
</ParamField>

<ParamField body="min_duration_seconds" type="number">
  Minimum acceptable call duration in seconds.
</ParamField>

<ParamField body="max_duration_seconds" type="number">
  Maximum acceptable call duration in seconds.
</ParamField>

## Response

<ResponseField name="case" type="object">
  The created test case object with all configured fields and its new UUID.
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.magpipe.ai/functions/v1/test-cases" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "action": "create_case",
      "suite_id": "a1b2c3d4-1234-5678-9abc-def012345678",
      "name": "Caller asks about business hours",
      "type": "inbound_call",
      "caller_mode": "scripted",
      "caller_script": ["Hi, what are your business hours?"],
      "expected_phrases": ["Monday through Friday", "9 AM"],
      "prohibited_phrases": ["I don'\''t know"],
      "min_duration_seconds": 10,
      "max_duration_seconds": 60
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json theme={null}
  {
    "case": {
      "id": "b2c3d4e5-2345-6789-abcd-ef0123456789",
      "suite_id": "a1b2c3d4-1234-5678-9abc-def012345678",
      "name": "Caller asks about business hours",
      "description": null,
      "type": "inbound_call",
      "agent_id": "c72ea2b8-1234-5678-9abc-def012345678",
      "caller_mode": "scripted",
      "caller_script": ["Hi, what are your business hours?"],
      "expected_phrases": ["Monday through Friday", "9 AM"],
      "prohibited_phrases": ["I don't know"],
      "expected_functions": null,
      "min_duration_seconds": 10,
      "max_duration_seconds": 60,
      "created_at": "2024-01-15T10:05:00.000Z"
    }
  }
  ```
</ResponseExample>
