Search code examples
curlgithub-api

Add users to organization team with Github API


I'm trying to add multiple users to a team in a private group team using curl and the github API. However, something is off with my syntax and I'm not sure what it is.

I've tried:

curl --user "groupowner:password" -X PUT -d "" "https://api.github.com/orgs/ORGNAME/teams/TEAMNAME/members/USERNAMETOBEADDED/"

The github documentation, e.g., here is helpful, but I'm missing something.Looking here it seems that another syntax may be possible.


Solution

  • Getting rid of the trailing slash and using the team membership API should do the trick:

    curl --user "groupowner:password" -X PUT -d "" "https://api.github.com/teams/TEAMID/memberships/USERNAMETOBEADDED"