meta { name: Create Library type: http seq: 1 } post { url: {{base_url}}/api/libraries auth: inherit body: json } headers { Content-Type: application/json } body:json { { "name": "My Ebook Library", "description": "A collection of technical books and novels", "type": "ebooks" } } tests { test_create_library_success(status, headers, body) { if (status !== 201) { throw new Error("Expected status 201, got " + status); } const contentType = headers["content-type"]; if (!contentType || !contentType.includes("application/json")) { throw new Error("Expected content-type to contain application/json, got " + contentType); } // Verify response body is valid JSON and has expected structure let data; try { data = JSON.parse(body); } catch (e) { throw new Error("Response body is not valid JSON"); } if (!data || typeof data !== "object") { throw new Error("Expected response body to be an object"); } // Check for required fields in library response if (!data.id) { throw new Error("Library response missing required field: id"); } if (!data.name) { throw new Error("Library response missing required field: name"); } if (!data.type) { throw new Error("Library response missing required field: type"); } // Validate data types if (typeof data.id !== "string") { throw new Error("Library id must be a string"); } if (typeof data.name !== "string") { throw new Error("Library name must be a string"); } if (!["ebooks", "audiobooks", "videos", "other"].includes(data.type)) { throw new Error("Invalid library type: " + data.type); } return true; } } settings { encodeUrl: true timeout: 0 } docs { ## Create Library Creates a new library for organizing media items. **Method:** POST **Endpoint:** /api/libraries **Authentication:** Required (Bearer token) **Request Body:** - `name` (string, required): Library name - `description` (string, optional): Library description - `type` (string, required): Library type - `"ebooks"`: Electronic books - `"audiobooks"`: Audio books - `"videos"`: Video content - `"other"`: Other media types **Response:** Library object - `id` (string): Library UUID - `name` (string): Library name - `description` (string, optional): Library description - `type` (string): Library type - `is_visible` (boolean): Library visibility status - `created_at` (string): Creation timestamp - `updated_at` (string): Last update timestamp **Status Codes:** - 201: Library created successfully - 400: Invalid request data - 401: Unauthorized - 403: Forbidden (insufficient permissions) - 409: Library name already exists - 500: Internal server error }