meta { name: Bulk Add Books to Collections type: http seq: 1 } post { url: {{base_url}}/api/collections/bulk-add-books body: json auth: inherit } headers { Content-Type: application/json Authorization: Bearer {{authToken}} } body:json { { "operations": [ { "collection_id": "{{collectionId1}}", "book_ids": [ "{{bookId1}}", "{{bookId2}}" ] }, { "collection_id": "{{collectionId2}}", "book_ids": [ "{{bookId3}}" ] } ] } } script:post-response { function onResponse(res) { if (res.getStatus() === 200) { tests['Bulk add successful'] = true; const body = res.getBody(); tests['Has results array'] = Array.isArray(body.results); tests['All operations processed'] = body.results.length > 0; } else { tests['Bulk add failed'] = false; } } onResponse(res); } settings { encodeUrl: true timeout: 0 } docs { ## Bulk Add Books to Collections Adds multiple books to multiple collections in a single request. Each operation specifies a collection and a list of books to add. **Method:** POST **Endpoint:** /api/collections/bulk-add-books **Authentication:** Bearer token **Request Body:** - `operations` (array): Array of collection-book operations - `collection_id` (string): Collection UUID - `book_ids` (array): Array of book UUIDs to add to the collection **Response:** - `results` (array): Results for each operation - `total` (number): Total number of operations - `success` (number): Number of successful operations - `failed` (number): Number of failed operations **Status Codes:** - 200: Success (with partial results if some failed) - 400: Invalid request data - 401: Unauthorized - 403: Forbidden - 500: Internal server error **Example:** ```json { "operations": [ { "collection_id": "collection-uuid-1", "book_ids": ["book-1", "book-2"] }, { "collection_id": "collection-uuid-2", "book_ids": ["book-3"] } ] } ``` **Note:** Adding a book that's already in a collection is idempotent (no error). }