> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fireflies.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Add User to User Group

> Use the API to add users to a user group

## Overview

The `addUserToUserGroup` mutation adds a teammate to one of your team's user groups, identified by their email address. The requesting user must be a team admin.

## Arguments

**group\_id** `String` *required*

The unique identifier of the user group.

**user\_email** `String` *required*

The email address of the user to add to the group.

## Usage Example

To add a user to a user group, provide the group's ID and the user's email as arguments to the mutation. Here's an example of how this mutation could be used:

```graphql theme={null}
mutation addUserToUserGroup($groupId: String!, $userEmail: String!) {
  addUserToUserGroup(group_id: $groupId, user_email: $userEmail) {
    id
    name
    handle
    members {
      user_id
      email
    }
  }
}
```

```bash curl theme={null}
curl -X POST https://api.fireflies.ai/graphql \
	-H "Content-Type: application/json" \
	-H "Authorization: Bearer your_api_key" \
	-d '{
		"query": "mutation($group_id: String!, $user_email: String!) { addUserToUserGroup(group_id: $group_id, user_email: $user_email) { id name handle members { user_id email } } }",
		"variables": {
			"group_id": "your_group_id",
			"user_email": "user@example.com"
		}
	}'
```

```javascript javascript theme={null}
const axios = require('axios');

const url = 'https://api.fireflies.ai/graphql';
const headers = {
  'Content-Type': 'application/json',
  Authorization: 'Bearer your_api_key'
};

const data = {
  query: `mutation Mutation($groupId: String!, $userEmail: String!) {
		addUserToUserGroup(group_id: $groupId, user_email: $userEmail) {
		  id
		  name
		  handle
		  members {
			user_id
			email
		  }
		}
	  }`,
  variables: { groupId: 'your_group_id', userEmail: 'user@example.com' }
};

axios
  .post(url, data, { headers: headers })
  .then(result => {
    console.log(result.data);
  })
  .catch(e => {
    console.log(JSON.stringify(e));
  });
```

```python python theme={null}
import requests

url = 'https://api.fireflies.ai/graphql'

headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer your_api_key'
}

data = {
    'query': '''
      mutation($group_id: String!, $user_email: String!) {
        addUserToUserGroup(group_id: $group_id, user_email: $user_email) {
          id
          name
          handle
          members {
            user_id
            email
          }
        }
      }
    ''',
    'variables': {
        'group_id': "your_group_id",
        'user_email': "user@example.com"
    }
}

response = requests.post(url, headers=headers, json=data)

if response.status_code == 200:
    print(response.json()['data'])
else:
    print(response.text)
```

```java java theme={null}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpRequest.BodyPublishers;

public class ApiRequest {
    public static void main(String[] args) {
        HttpClient client = HttpClient.newHttpClient();
        String jsonRequest = "{\"query\": \"mutation AddUserToUserGroup($group_id: String!, $user_email: String!) { addUserToUserGroup(group_id: $group_id, user_email: $user_email) { id name handle members { user_id email } } }\", \"variables\": {\"group_id\": \"your_group_id\", \"user_email\": \"user@example.com\"}}";
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.fireflies.ai/graphql"))
            .header("Content-Type", "application/json")
            .header("Authorization", "Bearer your_api_key")
            .POST(BodyPublishers.ofString(jsonRequest))
            .build();

        client.sendAsync(request, HttpResponse.BodyHandlers.ofString())
            .thenApply(HttpResponse::body)
            .thenAccept(System.out::println)
            .join();
    }
}

```

```json Response theme={null}
{
  "data": {
    "addUserToUserGroup": {
      "id": "your_group_id",
      "name": "Sales Team",
      "handle": "sales-team",
      "members": [
        {
          "user_id": "user_id",
          "email": "user@example.com"
        }
      ]
    }
  }
}
```

## Error Codes

List of possible error codes that may be returned by the `addUserToUserGroup` mutation. Full list of error codes can be found [here](https://docs.fireflies.ai/miscellaneous/error-codes.md).

> [accordion] object\_not\_found
>
> The user group or teammate could not be found, or no user matches the provided `user_email`.

> [accordion] not\_in\_team
>
> The user you are trying to add is not in your team.

> [accordion] invalid\_arguments
>
> The provided `user_email` is not a valid email address.

> [accordion] require\_elevated\_privilege
>
> The user does not have admin privileges to manage user groups.

> [accordion] bad\_request
>
> The user is already a member of the user group.

> [accordion] forbidden
>
> You do not have access to this user group.

> [accordion] paid\_required
>
> Managing user groups requires a Business plan or higher.

## Audit Trail

A successful call records a [`USER_GROUP_MEMBER_ADDED`](https://docs.fireflies.ai/graphql-api/query/audit-events) audit event carrying the `group_id` in its metadata, so membership changes are queryable after the fact.

## Additional Resources

> [card] [User Groups](https://docs.fireflies.ai/graphql-api/query/user-groups.md)
>
> Querying list of user groups

> [card] [Remove User from User Group](https://docs.fireflies.ai/graphql-api/mutation/remove-user-from-user-group.md)
>
> Removing a user from a user group


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.