> ## 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.

# Remove User from User Group

> Use the API to remove users from a user group

## Overview

The `removeUserFromUserGroup` mutation removes a member from one of your team's user groups, identified by their email address. The requesting user must be a team admin.

## Arguments

<ParamField path="group_id" type="String" required>
  The unique identifier of the user group.
</ParamField>

<ParamField path="user_email" type="String" required>
  The email address of the user to remove from the group.
</ParamField>

## Usage Example

To remove a user from 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 removeUserFromUserGroup($groupId: String!, $userEmail: String!) {
  removeUserFromUserGroup(group_id: $groupId, user_email: $userEmail) {
    id
    name
    handle
    members {
      user_id
      email
    }
  }
}
```

<RequestExample>
  ```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!) { removeUserFromUserGroup(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!) {
  		removeUserFromUserGroup(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!) {
          removeUserFromUserGroup(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 RemoveUserFromUserGroup($group_id: String!, $user_email: String!) { removeUserFromUserGroup(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();
      }
  }

  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "data": {
      "removeUserFromUserGroup": {
        "id": "your_group_id",
        "name": "Sales Team",
        "handle": "sales-team",
        "members": []
      }
    }
  }
  ```
</ResponseExample>

## Error Codes

List of possible error codes that may be returned by the `removeUserFromUserGroup` mutation. Full list of error codes can be found [here](/miscellaneous/error-codes).

<Accordion title="object_not_found">
  <p>The user group could not be found, no user matches the provided `user_email`, or the user is not a member of the group.</p>
</Accordion>

<Accordion title="invalid_arguments">
  <p>The provided `user_email` is not a valid email address.</p>
</Accordion>

<Accordion title="require_elevated_privilege">
  <p>The user does not have admin privileges to manage user groups.</p>
</Accordion>

<Accordion title="forbidden">
  <p>You do not have access to this user group.</p>
</Accordion>

<Accordion title="paid_required">
  <p>Managing user groups requires a Business plan or higher.</p>
</Accordion>

## Audit Trail

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

## Additional Resources

<CardGroup cols={2}>
  <Card title="User Groups" icon="link" href="/graphql-api/query/user-groups">
    Querying list of user groups
  </Card>

  <Card title="Add User to User Group" icon="link" href="/graphql-api/mutation/add-user-to-user-group">
    Adding a user to a user group
  </Card>
</CardGroup>
