Doubts regarding Github API


1)How to add an user to Github Organization by mail id(not by Username) using Github API?

2)How to add multiple users to Github Organization by mail-id/usernames using API?

3)Is there a way that can we directly add an user to a team those without having organization access?


:wave: hello there @prasad-1729, and welcome to the GitHub Support Community!

Thanks for asking these great questions. I hope what’s shared in this thread by the community and myself will increase more confidence in using our platform to do your work. :v:

The REST API has an endpoint for creating an organization invitation: it allows an organization owner to invite people to their organization by using their GitHub user ID or their email address. It may be worth checking out the associated code samples for making this request.

There’s not a single endpoint for adding multiple users to a GitHub organization, though you could write a script that makes one request for each person that you’d like to invite to that organization.

First, it’s possible to add organization members to a team. People with owner permissions can also invite non-members to join a team (and thus, the organization). There’s an API endpoint for adding or updating team membership for a user, including the associated code samples for doing so.

If you’re interested in adding outside collaborators to repositories in your organization without making them an organization member, that’s possible too! For context, an outside collaborator is a person who isn’t explicitly a member of your organization, but who has Read, Write, or Admin permissions to one or more repositories in your organization. The REST API has an endpoint for adding a repository collaborator and the associated code samples may be worth checking out as well. I hope this helps!

1 Like