Add Users to a Group
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#
OpenAPI Spec
Request Headers#
X-FusionAuth-TenantIdStringoptionalThe 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 the request parameters 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]ArrayrequiredThe 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].dataObjectoptionalAn object that can hold any information about the Group Member that should be persisted.
members[groupId][x].idUUIDoptionalThe unique Id of this Group Member. If not specified a secure random UUID will be generated.
members[groupId][x].userIdUUIDrequiredThe User Id to add as a Member of this Group.
Example Request JSON
{
"members": {
"1188edfc-cef3-4555-910e-181ddf6153c0": [
{
"data": {
"fruit": "orange"
},
"userId": "00000000-0000-0001-0000-000000000000"
}
]
}
}
Response#
Response Codes| Code | Description |
|---|---|
| 200 | The request was successful. The response will contain a JSON body. |
| 400 | The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present. |
| 401 | You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See Authentication. |
| 500 | There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty. |
Response Body#
members[groupId][x].dataObjectAn object that can hold any information about the Group Member that should be persisted.
members[groupId][x].idUUIDThe unique Id of this Group Member. This is not the User Id, but a unique Id for the membership.
members[groupId][x].insertInstantLongThe instant that this membership was created.
members[groupId][x].userIdUUIDThe User Id of the Group Member.
Example Response JSON
{
"members": {
"1188edfc-cef3-4555-910e-181ddf6153c0": [
{
"data": {
"fruit": "orange"
},
"id": "47ffe8c2-920a-49cc-bfa8-b84889db615e",
"insertInstant": 1503513015493,
"userId": "00000000-0000-0001-0000-000000000000"
}
]
}
}