def METHOD_NAME(path: str, require_group: bool = False) -> Response:
    d = DocEntry.find_by_path(path)
    if not d:
        raise NotExist("Course not found")
    verify_view_access(d)
    added_to_group = False
    u = get_current_user_object()
    try:
        ug = verify_valid_course(path)
    except CourseException as e:
        if require_group:
            raise RouteException(str(e))
    else:
        u.add_to_group(ug, added_by=u)
        added_to_group = True
    add_to_course_bookmark(u.bookmarks, d, skip_if_hidden=False)
    db.session.commit()
    return json_response(
        {
            "bookmarks": get_current_user_object().bookmarks.as_dict(),
            "added_to_group": added_to_group,
        }
    )