The question is: How do i insert the variable (echo $url_endpoint;) as a part of the link in the last line: header(\'Location: http://linkhere.com/HERE_I_WANT_THE_VARIABLE\');>
Try using double quotes and keeping the L in location lowercase...
L
location
header("location: http://linkhere.com/HERE_I_WANT_THE_VARIABLE");
or for example
header("location: http://linkhere.com/$variable");
No need to concatenate here to insert variables.