Add Users to a Group API
On this page
This API is used to add Users to a Group. A User that is added to a Group is called a member, a user can belong to one to many Groups.
Adding a User to a Group can be used to logically group users, Group members can be returned by the Search API by searching by the Group Id. Application Roles may also be managed by a Group membership. When a User becomes a member of a Group they will inherit the Application Roles assigned to the Group for their registered Applications. If a User is not registered for an Application the Application Roles for that Application will not be applied to the User.
Request#
Provide the Group Id and the Users to add in the request body.
OpenAPI Spec
Request Headers#
X-FusionAuth-TenantIdThe unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon other values in the request or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Request Body#
members[groupId] The key is the Id of the Group to which to add Users. The value is an array of objects which specify the Members to be added.
members[groupId][x].data An object that can hold any information about the Group Member that should be persisted.
members[groupId][x].id The unique Id of this Group Member. If not specified a secure random UUID will be generated.
members[groupId][x].userId The User Id to add as a Member of this Group.
{
"members": {
"1188edfc-cef3-4555-910e-181ddf6153c0": [
{
"data": {
"fruit": "orange"
},
"userId": "00000000-0000-0001-0000-000000000000"
}
]
}
}Response#
| Code | Description |
|---|---|
| 200 | The request succeeded. The response contains a JSON body. |
| 400 | The request was invalid or malformed. The response contains an Errors JSON object with the specific errors. FusionAuth also returns a 400 when the request needs a paid FusionAuth license and no license is present. |
| 401 | FusionAuth didn't authorize the request. The Authorization header is missing, the API key isn't valid, or the API key doesn't have permission for this endpoint and method. The response is empty. For more information, see Unauthorized Responses. |
| 500 | FusionAuth had an internal error and logged a stack trace in the FusionAuth log files. The response usually contains an Errors JSON object with the [Exception] general error code. On MySQL, a data field larger than the database column also returns 500. For more information, see Data Field Sizes. |
Response Body#
members[groupId][x].data An object that can hold any information about the Group Member that should be persisted.
members[groupId][x].id The unique Id of this Group Member. This is not the User Id, but a unique Id for the membership.
members[groupId][x].insertInstant The instant that this membership was created.
members[groupId][x].userId The User Id of the Group Member.
{
"members": {
"1188edfc-cef3-4555-910e-181ddf6153c0": [
{
"data": {
"fruit": "orange"
},
"id": "47ffe8c2-920a-49cc-bfa8-b84889db615e",
"insertInstant": 1503513015493,
"userId": "00000000-0000-0001-0000-000000000000"
}
]
}
}Related
API documentation for the FusionAuth Create a Group API.
API documentation for the FusionAuth Delete a Group API.
Learn about the APIs for creating, retrieving, updating and deleting groups.
API documentation for the FusionAuth Remove Users from a Group API.