# Auto Link Books

Automatically link books to media items based on matching metadata.

**Endpoint**: `POST /api/sync/auto-link-books`
**Auth**: Required
**Content-Type**: `application/json`

## Request Body

| Field     | Type          | Required | Description                                        |
| --------- | ------------- | -------- | -------------------------------------------------- |
| device_id | string (UUID) | Yes      | Device UUID                                        |
| threshold | float         | No       | Match confidence threshold (0.0-1.0, default: 0.7) |

### Example Request

```json
{
  "device_id": "550e8400-e29b-41d4-a716-446655440000",
  "threshold": 0.8
}
```

## Response (200 OK)

```json
{
  "message": "Auto-link completed",
  "linked_count": 15,
  "unmatched_count": 5,
  "links": [
    {
      "book_id": "book-123",
      "media_item_id": "uuid",
      "confidence": 0.95
    }
  ]
}
```

## Error Responses

| Code | Description              |
| ---- | ------------------------ |
| 400  | Invalid request data     |
| 401  | Invalid or expired token |
| 404  | Device not found         |
