async def save_z(data):
    """
    Save the current Z height value for the calibration data

    :param data: Information obtained from a POST request.
    The content type is application/json.
    The correct packet form should be as follows:
    {
      'token': UUID token from current session start
      'command': 'save z'
    }
    """
    if not session.tip_length:
        message = "Tip length must be set before calibrating"
        status = 400
    else:
        if not feature_flags.use_protocol_api_v2():
            mount = 'Z' if session.current_mount == 'left' else 'A'
            actual_z = position(
                mount, session.adapter)[-1]
            length_offset = pipette_config.load(
                session.current_model, session.pipette_id).model_offset[-1]
            session.z_value = actual_z - session.tip_length + length_offset
        else:
            session.z_value = position(
                session.current_mount, session.adapter, session.cp)[-1]

        message = "Saved z: {}".format(session.z_value)
        status = 200
    return web.json_response({'message': message}, status=status)
Save the current Z height value for the calibration data

    :param data: Information obtained from a POST request.
    The content type is application/json.
    The correct packet form should be as follows:
    {
      'token': UUID token from current session start
      'command': 'save z'
    }