through the api I create the user,
to assign a course to the function I have to pass the user id and the id role
$enrolment = array( 'roleid' => $role_id, 'userid' => $user_id, 'courseid' => $course_id );
$enrolments = array( $enrolment );
$params = array( 'enrolments' => $enrolments );
$response = call_moodle( 'enrol_manual_enrol_users', $params, $token );
to assign a course to the function I have to pass the user id and the id role
$enrolment = array( 'roleid' => $role_id, 'userid' => $user_id, 'courseid' => $course_id );
$enrolments = array( $enrolment );
$params = array( 'enrolments' => $enrolments );
$response = call_moodle( 'enrol_manual_enrol_users', $params, $token );