# Add a case to a suite

Source: https://docs.vlayers.ai/reference/test/add-test-case

`POST /v1/tests/{id}/cases` · scope `workspace:write`

Adds a case to a suite. `from` names where it comes from: a conversation or a call that went wrong (the contact's lines are copied, with personal details hidden; a message that tries to instruct the agent is kept so the test can see how the agent copes), or a script of your own. Without `expectations` the case expects the agent's goal to be met.

Requires an API key with the `workspace:write` scope.

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | yes | The suite id. Example: `"0192f5f8-c1d0-7b2e-8d7e-8f9012345678"` |
| `from` | body | "conversation" \| "call" \| "script" | yes | Where the case comes from: `conversation`, `call` or `script`. |
| `conversationId` | body | string | no | The conversation to copy the contact’s lines from, when `from` is `conversation`. |
| `callId` | body | string | no | The call to copy the caller’s lines from, when `from` is `call`. |
| `turns` | body | string[] | no | The contact’s lines, in order, when `from` is `script`. |
| `name` | body | string | no | A name for the case. |
| `expectations` | body | object[] | no | What the run must reach. Left out: the agent’s goal is met. |

## Request

cURL:

```bash
curl -X POST "https://api.vlayers.ai/v1/tests/$SUITE_ID/cases" \
  -H "Authorization: Bearer $VOICELAYER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "from": "script",
    "turns": [
      "Hi, I want a refund",
      "It arrived broken"
    ],
    "name": "Refund request"
  }'
```

TypeScript:

```ts
import { VoiceLayer } from '@voicelayer/api';

const voicelayer = new VoiceLayer();

await voicelayer.test.addCase('<suite-id>', {
  from: 'script',
  turns: ['Hi, I want a refund', 'It arrived broken'],
  name: 'Refund request'
});
```

Python:

```python
from voicelayer import VoiceLayer

vl = VoiceLayer()

vl.test.add_case(
    "<suite-id>",
    from_="script",
    turns=["Hi, I want a refund", "It arrived broken"],
    name="Refund request",
)
```

## Response `201`

```json
{
  "case": {
    "id": "0192f5f9-d2e1-7c3f-9e8f-90123456789a",
    "suiteId": "0192f5f8-c1d0-7b2e-8d7e-8f9012345678",
    "agentId": "0192f5c2-6f7a-7b9c-8d1e-2f3a4b5c6d78",
    "name": "Refund went wrong",
    "inputKind": "replay",
    "turns": [
      "I was charged twice",
      "Yes, the card ending 4242"
    ],
    "sourceCallId": null,
    "sourceConversationId": "0192f5b0-7c3e-7a51-9b2d-4e8f1a6c3d21",
    "expectations": [
      {
        "evaluationId": "0192f5f7-b0cf-7a1d-9c6d-7e8f90123456",
        "expect": {
          "bool": true
        }
      }
    ],
    "createdBy": "user_2abc",
    "createdAt": "2026-10-20T15:04:05.000Z",
    "expiresAt": null
  }
}
```
