def METHOD_NAME(user: str, session_id: str | None = None) -> Response:
    """
    Invalidate a session.
    .. note:: This endpoint is only accessible to administrators.
    :param user: Username to invalidate.
    :param session_id: Session ID to invalidate. If not specified, all sessions will be invalidated.
    :return: OK response.
    """
    verify_admin()
    invalidate_sessions_for(user, session_id)
    db.session.commit()
    return ok_response()