HOW TO

Invite multiple members to an ArcGIS Online group using the ArcGIS API for Python

First Published: July 20, 2026
Last Published: July 20, 2026

Summary

Bulk-inviting members to an ArcGIS Online group using the ArcGIS API for Python helps automate large or frequent group membership updates under consistent rules (such as role and expiration). This workflow has been validated in ArcGIS Online with both built-in and SAML logins.

Procedure

The script uses the ArcGIS API for Python to connect to ArcGIS Online and uses the group.invite_users() method to send group invitations. It retrieves the target group using its Group ID and bulk-invites a list of usernames with a specified group role and invitation expiration. After sending invitations, it uses group.get_members() to identify users who are currently group members (users, admins, or owner). Users not returned by get_members() are not currently members of the group, which may indicate a pending invitation, a declined or expired invitation, an invalid username, or another condition.

  1. Create a new group in ArcGIS Online. If a member from a different organization needs to be invited in the group, the group setting must allow external membership. “Who can be in this group?” = Any organization’s members.
  2. Import the GIS class from the arcgis.gis module in the ArcGIS API for Python, use the following core syntax. For better understanding refer to the Install and Setup documentation.
from arcgis.gis import GIS
  1. Sign in using a profile authenticated to the target organization
    1. Option 1: Use the active “home” profile (commonly used with SAML/SSO). Use this when your environment, for example, ArcGIS Pro, a Notebook environment, or a previously created profile, is already signed in to the organization.
gis = GIS("home")
  1. Option 2: Use built-in (username/password) authentication. Use this when signing in with a built-in ArcGIS Online account (username and password) rather than SAML/SSO authentication.
gis = GIS("https://www.arcgis.com", "USERNAME", "PASSWORD")
  1. Determine which ArcGIS Online group you want to invite users to. Make sure you are using an ArcGIS Online account with the necessary permissions to manage the group, such as the group owner, a group manager, or an organization administrator with appropriate group management privileges. Find the Group ID by viewing the group’s page in ArcGIS Online (you can locate it in the URL or in the group details). Then, use the gis.groups.get() method in the ArcGIS API for Python to retrieve the group. 
group = gis.groups.get("GroupID")   #Replace with the target group’s ID
  1. Prepare a list of ArcGIS Online usernames to invite (this can be a bulk list).
usernames = ["username1", "username2", "username3", "..."]  # your bulk list
  1. Send group invitations, specifying the group role and invitation expiration (in minutes).
Note:
Invited usernames must correspond to valid ArcGIS Online accounts. For groups that allow external membership, users from other ArcGIS Online organizations can also be invited. In such cases, the group must be configured to allow members from any organization, and the invited users must be permitted by their organization's policies to join groups outside their home organization.
invite_mem = group.invite_users(
    usernames=usernames,
    role="group_member",   # or "group_admin"
    expiration=10080       # minutes; default is 7 days
)
  1. Validate that the invitation request was submitted successfully. A successful response indicates the request was accepted, but individual users may still fail to join or accept the invitation.
if invite_mem:
    print(f"Invite request succeeded for: {', '.join(usernames)}")
else:
    raise RuntimeError("Invite request failed (invite_users returned False).")
  1. Retrieve the group’s current members via get_members() to verify membership status (users, admins, and owner) and building an accepted set by combining users, admins, and owner for quick membership lookup. Checks each invited username against current members and reports whether they are already in the group or still pending/not a member.
# Admin confirmation (accepted vs not yet accepted)
members = group.get_members()  # dict: {'users': [...], 'admins': [...], 'owner': '...'}

accepted = (
    set(members.get("users", []))
    | set(members.get("admins", []))
    | {members.get("owner")}
)

for u in usernames:
    if u in accepted:
        print(f"{u}: already a member (invite accepted or previously joined).")
    else:
        print(f"{u}: not a member yet (invite pending, declined, expired, or user not found).")

The following shows a sample of a full script:  

from arcgis.gis import GIS

gis = GIS("home")
group = gis.groups.get("GroupID")
usernames = ["username1", "username2", "username3", "..."]  # your bulk list

invite_mem = group.invite_users(
    usernames=usernames,
    role="group_member",   # or "group_admin"
    expiration=10080       # minutes; default is 7 days
)

# Send invitations
if invite_mem:
    print(f"Invite request succeeded for: {', '.join(usernames)}")
else:
    raise RuntimeError("Invite request failed (invite_users returned False).")

# Admin confirmation (accepted vs not yet accepted)
members = group.get_members()  # dict: {'users': [...], 'admins': [...], 'owner': '...'}
accepted = (
    set(members.get("users", []))
    | set(members.get("admins", []))
    | {members.get("owner")}
)

for u in usernames:
    if u in accepted:
        print(f"{u}: already a member (invite accepted or previously joined).")
    else:
        print(f"{u}: not a member yet (invite pending, declined, expired, or user not found).")

Article ID: 000042750

Software:
  • ArcGIS Online
  • ArcGIS API for Python

Get support with AI

Resolve your issue quickly with the Esri Support AI Chatbot.

Start chatting now

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Start chatting now

Go to download options