This boiled down to a user being clever. Deleting corresponding record allowed me to apply configuration.
I modified the throw to see where data was wrong.
delete from devices where id = ‘sting in question’;
i modified below function to output $config, and grepped it out sql dump to delete
if (isset($retarr[“pjsip.endpoint.conf”][$endpointname])) {
throw new \Exception("Endpoint $endpointname already exists.");
}