# Batch Add (Token Auth)

> For AI agents: the complete documentation index is at https://buddy.works/llms.txt

`POST /unit-tests/sessions/:sessionId/cases/batch`

Add multiple test cases in batch using suite token authentication

## URL Parameters

```typescript
interface URLParameters {
  /** The ID of the test session */
  sessionId: string; // Example: "r4nBYXVq"
}
```

## Body Parameters

```typescript
interface BodyParameters {
  cases: AddTestCaseRequest[];
}
```

## Response Body

```typescript
interface ResponseBody {
  /** API endpoint to GET this object */
  url?: string;
  /** Web URL to view this object in Buddy.works */
  html_url?: string;
  cases?: ShortTestCaseView[];
}
```

## Type Definitions

```typescript
interface AddTestCaseRequest {
  /** Name of the test case */
  name: string;
  /** Name of the test group this case belongs to (typically corresponds to a test suite in JUnit XML) */
  test_group_name: string;
  /** Fully qualified class name of the test */
  classname: string;
  /** Test execution status */
  status: "PASSED" | "FAILED" | "SKIPPED" | "ERROR";
  /** Execution time in seconds */
  time: number;
  /** Original XML data from the test report */
  data?: string;
}

interface ShortTestCaseView {
  /** API endpoint to GET this object */
  url?: string;
  /** Web URL to view this object in Buddy.works */
  html_url?: string;
  /** Unique identifier of the test case */
  id?: string;
  /** Name of the test case */
  name?: string;
  /** Name of the test group this case belongs to (typically corresponds to a test suite in JUnit XML) */
  test_group_name?: string;
  /** ID of the test group this case belongs to */
  test_group_id?: string;
  /** Fully qualified class name of the test */
  classname?: string;
  /** Test execution status */
  status?: "PASSED" | "FAILED" | "SKIPPED" | "ERROR";
  /** Execution time in seconds */
  time?: number;
}

```

## Request Example

```bash
curl -X POST "https://api.buddy.works/unit-tests/sessions/:sessionId/cases/batch" \
  -H "Authorization: Bearer <YOUR-TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{
  "cases": [
    {
      "name": "testUserLogin",
      "test_group_name": "com.example.tests.IntegrationTests",
      "classname": "com.example.tests.IntegrationTests",
      "status": "PASSED",
      "time": 2.5,
      "data": "<testcase name=\"testUserLogin\" classname=\"com.example.tests.IntegrationTests\" time=\"2.5\"/>"
    },
    {
      "name": "testUserLogout",
      "test_group_name": "com.example.tests.IntegrationTests",
      "classname": "com.example.tests.IntegrationTests",
      "status": "PASSED",
      "time": 1.2,
      "data": "<testcase name=\"testUserLogout\" classname=\"com.example.tests.IntegrationTests\" time=\"1.2\"/>"
    },
    {
      "name": "testPasswordReset",
      "test_group_name": "com.example.tests.IntegrationTests",
      "classname": "com.example.tests.IntegrationTests",
      "status": "SKIPPED",
      "time": 0,
      "data": "<testcase name=\"testPasswordReset\" classname=\"com.example.tests.IntegrationTests\" time=\"0.0\"><skipped/></testcase>"
    }
  ]
}'
```

## Response Example

**Status:** `201 Created`

```json
{
  "url": "https://api.buddy.works/workspaces/my-workspace/projects/my-project/unit-tests/suites/5ddb7c180fb38be67bd78a88a/sessions/5ddb7c180fb38be67bd78a88b/cases",
  "html_url": "https://app.buddy.works/my-workspace/projects/my-project/unit-tests/suites/5ddb7c180fb38be67bd78a88a/sessions/5ddb7c180fb38be67bd78a88b",
  "cases": [
    {
      "url": "https://api.buddy.works/workspaces/my-workspace/projects/my-project/unit-tests/suites/5ddb7c180fb38be67bd78a88a/sessions/5ddb7c180fb38be67bd78a88b/test-groups/com.example.UserServiceTest/cases/com.example.UserServiceTest.testShouldReturnSuccess",
      "html_url": "https://app.buddy.works/my-workspace/projects/my-project/unit-tests/suites/5ddb7c180fb38be67bd78a88a/sessions/5ddb7c180fb38be67bd78a88b",
      "id": "com.example.UserServiceTest.testShouldReturnSuccess",
      "name": "testShouldReturnSuccess",
      "test_group_name": "com.example.UserServiceTest",
      "test_group_id": "com.example.UserServiceTest",
      "classname": "com.example.UserServiceTest",
      "status": "PASSED",
      "time": 0.123
    },
    {
      "url": "https://api.buddy.works/workspaces/my-workspace/projects/my-project/unit-tests/suites/5ddb7c180fb38be67bd78a88a/sessions/5ddb7c180fb38be67bd78a88b/test-groups/com.example.UserServiceTest/cases/com.example.UserServiceTest.testShouldHandleError",
      "html_url": "https://app.buddy.works/my-workspace/projects/my-project/unit-tests/suites/5ddb7c180fb38be67bd78a88a/sessions/5ddb7c180fb38be67bd78a88b",
      "id": "com.example.UserServiceTest.testShouldHandleError",
      "name": "testShouldHandleError",
      "test_group_name": "com.example.UserServiceTest",
      "test_group_id": "com.example.UserServiceTest",
      "classname": "com.example.UserServiceTest",
      "status": "FAILED",
      "time": 0.456
    },
    {
      "url": "https://api.buddy.works/workspaces/my-workspace/projects/my-project/unit-tests/suites/5ddb7c180fb38be67bd78a88a/sessions/5ddb7c180fb38be67bd78a88b/test-groups/com.example.PaymentServiceTest/cases/com.example.PaymentServiceTest.testSkipped",
      "html_url": "https://app.buddy.works/my-workspace/projects/my-project/unit-tests/suites/5ddb7c180fb38be67bd78a88a/sessions/5ddb7c180fb38be67bd78a88b",
      "id": "com.example.PaymentServiceTest.testSkipped",
      "name": "testSkipped",
      "test_group_name": "com.example.PaymentServiceTest",
      "test_group_id": "com.example.PaymentServiceTest",
      "classname": "com.example.PaymentServiceTest",
      "status": "SKIPPED",
      "time": 0
    }
  ]
}
```

---
Original source: https://buddy.works/docs/api/unit-tests/cases/batch-token