Create custom API endpoint to change custom header image

The header image falls under what WordPress calls theme modification values. To update that type of value, use the function set_theme_mod()

function cs_set_logo($request) {
 set_theme_mod('header_image', $request->get_param('new_header_image'));
 return new WP_REST_Response(null, 200);
}

add_action('rest_api_init', function() {
  register_rest_route('cs/v1', 'changelogo', [
  'methods' => 'POST',
  'callback' => 'cs_set_logo'
  ])
});