# Add users to groups in bulk

Adds many people to one or more user groups and returns a token identifying
the queued job. The work happens in the background, so a `200` means the
request was accepted, not that every membership exists yet. People already
in a group are skipped rather than duplicated.
`entity` says what the ids you send refer to, and it is the field that makes
this endpoint worth using: with `user` you send user ids directly, and with
the other values you send shift, shift-assignment, event-registration or
role-offer-application ids instead and the people attached to those records
are the ones added. That is how "add everyone rostered on this shift to a
group" is expressed.
`applyTo` of `selected` takes the ids in `selected`. `applyTo` of `all` takes
every record of that `entity` type on the account, narrowed by `filter` if
you send one - so an `all` with no filter is a very wide request, and worth
running against the corresponding listing first to see what it selects.
Three of the `entity` types are scoped to a parent record through
`identifiers`, and two of them insist on it: `event_user` requires
`identifiers.event_id` and `role_offer_user` requires
`identifiers.role_offer_id`, while `event_shift` and `event_shift_user` accept
`identifiers.event_id` and `identifiers.shift_id` respectively to narrow the
selection but do not require them. `entity` of `user` ignores `identifiers`
entirely.

Endpoint: PUT /api/v2/user/group/user
Version: 2.0.0
Security: default

## Header parameters:

  - `Rosterfy-Platform` (string)

## Request fields (application/json):

  - `applyTo` (string, required)
    Which records to act on: `selected` or `all`.

  - `selected` (array)
    IDs of the records named by `entity`. Needed when `applyTo` is `selected`.

  - `identifiers` (object)
    Narrows the chosen `entity` to one parent record. See the description.

  - `identifiers.event_id` (integer)
    Required when `entity` is `event_user`; optional for `event_shift`.

  - `identifiers.shift_id` (integer)
    Optional when `entity` is `event_shift_user`.

  - `identifiers.role_offer_id` (integer)
    Required when `entity` is `role_offer_user`.

  - `filter` (array)
    The filter structure the matching listing accepts. Used when `applyTo` is `all`.

  - `group_id` (array, required)
    IDs of the groups to add the users to. Every group named here receives every user the request selects.

  - `entity` (string, required)
    What the ids in `selected` refer to. `user` for user ids; the other values take the users attached to the named records instead - `event_shift` for shifts, `event_shift_user` for shift assignments, `event_user` for event registrations, `role_offer_user` for role offer applications.

## Response 200 fields (application/json):

  - `queue` (string)

## Response 422 fields (application/json):

  - `message` (string)

  - `errors` (object)

  - `errors.group_id` (array)

