info:
  name: Sync Multiple Books Progress
  type: http
  seq: 3

http:
  method: POST
  url: '{{base_url}}/api/sync/kobo/markup'
  auth: inherit
  headers:
    - key: Content-Type
      value: application/json
    - key: x-kobo-device
      value: '{"DeviceId":"{{kobo_device_id}}","Model":"Kobo Aura"}'
  body:
    type: json
    json:
      ReadingSync:
        - ContentId: book-1-uuid
          PercentRead: 25.0
          EntitlementId: entitlement-1
          RemainingTimeMinutes: 240
          FirstReadTime: '2026-01-25T10:00:00Z'
          LastModified: '2026-01-30T18:00:00Z'
        - ContentId: book-2-uuid
          PercentRead: 78.5
          EntitlementId: entitlement-2
          RemainingTimeMinutes: 45
          FirstReadTime: '2026-01-25T14:00:00Z'
          LastModified: '2026-01-30T20:00:00Z'
      BookmarkSync: []

docs: |-
  ## Sync Multiple Books Progress

  Synchronizes reading progress for multiple books in a single request.

  **Method:** POST

  **Endpoint:** /api/sync/kobo/markup

  **Authentication:** Bearer token

  **Headers:**
  - `Authorization`: Bearer {{kobo_device_token}}
  - `x-kobo-device`: Device information (Model: "Kobo Aura")

  **Request Body:**
  - `ReadingSync` (array): Multiple progress items
    - Each item contains: ContentId, PercentRead, EntitlementId, etc.
  - `BookmarkSync` (array): Empty for progress-only batch

  **Response:**
  - `total` (integer): Total items in request
  - `synced` (integer): Successfully synced
  - `failed` (integer): Failed items
  - `results` (array): Per-item results
    - `ContentId` (string): Book UUID
    - `status` (string): `synced`, `failed`, `skipped`
    - `error` (string, optional): Error message if failed

  **Status Codes:**
  - 200: Batch sync completed
  - 207: Multi-status (some succeeded, some failed)
  - 401: Unauthorized
  - 413: Payload too large (>1MB)

  **Batch Sync Advantages:**
  - Efficient sync of entire library
  - Reduces HTTP overhead
  - Faster for devices with many books
  - Atomic operation (all or nothing by default)

  **Kobo Batch Sync Behavior:**
  - Triggered when device connects after being offline
  - Occurs during manual "Sync now" operation
  - Limited to 100 books per request
  - Progress updates shown on device
  - Failed items retried individually

  **Performance:**
  - Typical batch: 10-50 books in 1-3 seconds
  - Large batch: 50-100 books in 3-8 seconds
  - Timeout: 30 seconds
  - Rate limit: 10 batches per minute per device

  **Use Cases:**
  - Initial device sync after registration
  - Catch-up sync after extended offline period
  - Library-wide progress update
  - Pre-sync before device firmware update
