- Create invites that assign roles in Discord’s UI
- Create invites that assign roles through the API
- Create targeted invites for specific groups of users through the API
Understanding Community Invites Features
Community invites extend Discord’s existing invite system with two powerful features designed for game integrations:Role Assignment
You can assign roles for an invite through both the Discord UI and the API. If you’re assigning roles through the UI, jump ahead to the Creating Role Invites in Discord section. When using the API, therole_ids parameter lets you specify one or more Discord roles that will be automatically assigned when a player accepts the invite. No manual role management needed.
Example use cases:
- Giving roles to supporters
- Giving roles related to characters or achievements from your game
- Giving roles that have permissions to access channels
Once a user accepts an invite and receives the roles, those roles remain even after the invite expires or is deleted. You’ll need to remove roles manually (via a bot or Discord’s interface).
Targeted Invites
Setting which users that are allowed to accept an invite can only be done through the Discord API. Thetarget_users_file parameter accepts a CSV file containing Discord user IDs. Only users in that list can see and accept the invite.
Example use cases:
- Preventing invite sharing for exclusive achievements (for example, create a unique invite for a player with a 100% completion role)
- When combined with roles to give out mod/admin privileges
- Combined with roles to give special roles/channel access to paying supporters
max_age, max_uses, and more.
Creating Role Invites in Discord
Before diving into API integration, you can create role-assigning invites directly in Discord’s UI. This is perfect for server admins and community managers who want to create invites for specific purposes without writing code.Prerequisites
Before you begin, make sure you have:- A Discord server for testing
- User permissions for Create Invite, Manage Server, and Manage Roles
How to Create a Role Invite
- Open your Discord server and right-click the channel you want to create an invite for
- Select “Invite To Channel”
- Open your Discord server and click the server name
- Select “Invite To Server”
- Click “Edit invite link”
- Under “Roles (Optional)”, select one or more roles to auto-assign
- Configure other settings like expiration time and max uses
- Click “Generate a New Link”
- Share the invite link - anyone who accepts it will automatically receive the selected roles

Important Notes
- Users who accept the invite will receive the selected roles even if they’re already in your server
- Roles persist after the invite expires or is deleted
- You need Create Instant Invite and Manage Roles permissions to create role invites
- You can only assign roles in an invite that are lower than your highest role
Role Granting Invite Example: Auto-Assigning Player Roles
In this example, we’ll show you how to grant roles as part of an invite using the channel invite API. We’ll take a look at what a game developer could do to connect their game back to their Discord server.Prerequisites
Before you begin, make sure you have:- A Discord server for testing
- Developer Mode enabled on your account (so you can copy role, channel, and user IDs)
- A Discord app with a bot token (create one in the Developer Portal)
- Node.js installed, or the ability to make HTTP requests from your bot or app
- Bot permissions for:
- Create Instant Invite (required to create invites)
- Manage Roles (required for automatic role assignment with
role_ids)
Coding the Invite
When players join your Discord server from your game, you can give them a Player role for access to game-specific channels. Here’s how to create an invite that does this automatically:What’s Happening
role_idsarray: Contains the Discord role IDs to assign when the invite is accepted (we’re only assigning one in this example, but you can assign any number of roles using this array)- Response: Returns an invite object with a
codeyou can share
Testing It Out
Right click the channel for the invite and click “Copy Channel ID” then paste it in
CHANNEL_ID in the script
Target Users Example: Creating Targeted Supporter Invites
In this example, we’ll show you how to only allow specific users to accept an invite using the channel invite API. We’ll take a look at what a game developer or streamer could do to grant special roles and channels in their community for supporters.Prerequisites
Before you begin, make sure you have:- A Discord server for testing
- Developer Mode enabled on your account (so you can copy role, channel, and user IDs)
- A Discord app with a bot token (create one in the Developer Portal)
- Node.js installed, or the ability to make HTTP requests from your bot or app
- Bot permissions for:
- Create Instant Invite (required to create invites)
- Manage Guild (required for targeted invites with
target_users_file) - Manage Roles (required for automatic role assignment with
role_ids)
Coding the Invite
If you run a subscription service for your game or community, you can create exclusive invites that only your paying supporters can accept. Those roles can grant access to channels that other users in the server can’t see. Here’s how to create an invite that grants a role to specific users:What’s Happening
target_users_file: A CSV file containing Discord user IDs of paying supporters. Only these users can see and accept the invite.role_idsarray: Assigns the Supporter role automatically, giving them access to exclusive channels- FormData: Required when uploading files, the other parameters go in
payload_json
When using only JSON parameters like
role_ids, use Content-Type: application/json. When uploading target_users_file, you must use multipart/form-data.Setting Up the Supporter Role
For the best experience, configure your Supporter role with these permissions:- Create a Supporter role in your Discord server
- Create a private channel (#supporter-polls or #supporter-chat)
- Right click the channels and “Edit Channel” to set the channel permissions so only users with the Supporter role can view and message in it
- View Channel for the supporter exclusive channels
- Send Messages and Add Reactions
Testing It Out
Right click the channel for the invite and click “Copy Channel ID” then paste it in
SUPPORTER_CHANNEL_ID in the scriptRight click each user you want to be able to accept the invite and click “Copy User ID” then paste that in
activeSupporterIds in the scriptShare the
discord.gg/... link with one of the users you added to activeSupporterIds and one that you didn’t
