Branches protection API



$GITHUB_TOKEN is the access token for a organisation installation

I would like to GET the branch protection and maybe PATCH it later, but I get:

$ curl -H ‘Accept: application/vnd.github.loki-preview+json’ -H “Authorization: token $GITHUB_TOKEN”
“message”: “Resource not accessible by integration”,
“documentation_url”: “

I have tested many permissions combination but I always get the error.

The application permissions are currently:
Repository administration -> ReadWrite
Pull requests -> ReadWrite
Repository contents -> ReadWrite
Issues -> Read
Commit statuses -> ReadWrite

Do I miss something ? Does this API endpoint is supported ? if no, any ETA ?


As far as I can tell that endpoint isn’t enabled for GitHub Apps yet:

If you compare the documentation for that endpoint with the documentation for you can see a little blue (i) after the list branches one. That means that it’s enabled for GitHub Apps.


I’m still getting a 403 for branch protection, but there’s a (i) next to it now - am I missing something, or does getting branch protection require different permission levels than getting a branch?


@greysteil that endpoint requires the Repository administration permission and is enabled for server-to-server requests. Let me know if you’ve got that permission and you’re unable to access it using an installation token.


Ah OK - that makes a lot of sense, thanks!