Not sure if it's what you're looking for but I self host gitolite on a VPS. Access and auth control is via ssh keys on its user on the server and its script there. Administration is via a git push. There are only git repos, no GUI. Git is the API.
https://docs.gitea.io/en-us/api-usage/
It's not headless but maybe there is a way to shut down the HTML interface. But probably the same could be said of GitLab.