info:
  name: Update Saved Filter
  type: http
  seq: 3
http:
  method: PUT
  url: '{{base_url}}/api/saved-filters/{{filter_id}}'
  auth: inherit
  body:
    type: json
    jsonBody: "{\n    \"name\": \"Updated Sci-Fi Books\",\n    \"resource_type\"\
      : \"media-items\",\n    \"filters\": {\n      \"genre_filter\": \"Science Fiction\
      \ Fantasy\",\n      \"sort\": \"author ASC\",\n      \"year_min\": \"2000\"\
      \n    }\n  }"

docs: |-
  ## Update Saved Filter

  Updates an existing saved filter's name and/or filter criteria.

  **Method:** PUT

  **Endpoint:** /api/saved-filters/{filter_id}

  **Authentication:** Required (Bearer token)

  **Path Parameters:**
  - `filter_id` (string, required): UUID of the filter to update
    - Must be a valid UUID
    - Must belong to the authenticated user

  **Request Body:**
  ```json
  {
    "name": "Updated Sci-Fi Books",
    "resource_type": "media-items",
    "filters": {
      "genre_filter": "Science Fiction Fantasy",
      "sort": "author ASC",
      "year_min": "2000",
      "year_max": "2024"
    }
  }
  ```

  **Required Fields:**
  - `name` (string, required): New filter name
    - Must be unique per user + resource type (excluding current filter)
    - Maximum 100 characters
  - `resource_type` (string, required): Resource type (must match existing)
    - Cannot change resource type after creation
  - `filters` (object, required): Updated filter criteria
    - Replaces existing filters entirely

  **Response:**
  ```json
  {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "Updated Sci-Fi Books",
    "resource_type": "media-items",
    "filters": {
      "genre_filter": "Science Fiction Fantasy",
      "sort": "author ASC",
      "year_min": "2000",
      "year_max": "2024"
    },
    "created_at": "2024-03-20T12:00:00Z",
    "updated_at": "2024-03-20T15:30:00Z"
  }
  ```

  **Status Codes:**
  - 200: Success - Filter updated successfully
  - 400: Bad Request - Invalid request body or filter ID
  - 401: Unauthorized - Invalid or missing authentication token
  - 404: Not Found - Filter doesn't exist or doesn't belong to user
  - 409: Conflict - New name conflicts with existing filter

  **Error Response Examples:**

  Filter not found:
  ```json
  {
    "error": "filter not found or access denied"
  }
  ```

  Duplicate name:
  ```json
  {
    "error": "filter with name 'Updated Sci-Fi Books' already exists for this resource type"
  }
  ```

  **Example Usage:**
  ```bash
  curl -X PUT \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Updated Sci-Fi Books",
      "resource_type": "media-items",
      "filters": {
        "genre_filter": "Science Fiction Fantasy",
        "sort": "author ASC",
        "year_min": "2000"
      }
    }' \
    "{{base_url}}/api/saved-filters/{{filter_id}}"
  ```

  **Important Notes:**
  - You can only update filters that belong to you
  - The `updated_at` timestamp is automatically updated
  - Cannot change the resource_type (it's immutable)
  - New name must not conflict with other filters you own for the same resource type
  - All filter fields are replaced entirely (partial updates not supported)
