User Groups
API

User Groups API

Introduction

We usually interpret a user group as precisely what the name says: a group of users. For example, you may want to group users by their home country or any other characteristic. Read more about this topic in the user group feature guide.

Mutations

createUserGroup()

To create a user group, you simply need to define a name and reference.

mutation {
  createUserGroup(userGroup: { name: "xyz789", reference: "xyz789" }) {
    id
  }
}
ParameterTypeDescription
namestringThe name of the user group. For instance “My Team”
referencestringReference to an object on the project-side. This could be the ID of an entity in your database

addUsersToUserGroup()

To add users to a user group, you can use this mutation:

mutation {
  addUsersToUserGroup(userGroupId: "123", userIds: [])
}

Queries

userGroups()

To see user groups with users you run a query like this:

query {
  userGroups {
    data {
      name
      reference
      users {
        data {
          email
        }
      }
    }
  }
}

Another way to fetch users by a user group could look like:

query {
  users(filter: { userGroupId: { equalTo: "123" } }) {
    data {
      email
    }
  }
}