> For the complete documentation index, see [llms.txt](https://docs.vomevolunteer.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.vomevolunteer.com/resources/groups/write-operations.md).

# Write Operations

These endpoints create groups, and add or remove profiles as members.

#### Endpoints

```plaintext
POST api/groups/bulk-create/
POST api/groups/assign/
POST api/groups/unassign/
```

## Create groups

Accepts a single object or a list of objects. A name that already exists in your organization is skipped and reported back, so re-running the same import cannot grow a second group with the same name that nobody can tell apart afterwards.

```plaintext
POST api/groups/bulk-create/
```

* **name** (`string`, required): The name of the group.
* **description** (`string`): An optional description.

#### Example Request Payload

```json
[
    {
        "name": "Acme Corp Volunteer Team",
        "description": "Employees volunteering through our corporate partnership"
    }
]
```

#### Example Response

```json
{
    "created": [
        {
            "id": "64fd9793-0b67-4b02-a163-f2a7216292af",
            "name": "Acme Corp Volunteer Team",
            "description": "Employees volunteering through our corporate partnership"
        }
    ],
    "skipped": []
}
```

{% hint style="info" %}
Groups created through the API are Public, open for anyone to join, and have their group chat turned **off**. To use different settings, or to turn on the group chat, open the group in Vome and edit it there.
{% endhint %}

## Add profiles to groups

Adds every listed profile to every listed group as an active member.

```plaintext
POST api/groups/assign/
```

* **user\_ids** (`array`, required): The profiles to add, by Vome ID. A single **user\_id** is also accepted.
* **group\_ids** (`array`, required): The groups to add them to, by ID. A single **group\_id** is also accepted.
* **role** (`integer`): `0` for Member, `1` for Leader.

#### Example Request Payload

```json
{
    "user_ids": ["a9a1028f-93a6-401d-9867-1fe59aa2d830"],
    "group_ids": ["64fd9793-0b67-4b02-a163-f2a7216292af"],
    "role": 1
}
```

{% hint style="warning" %}
Leave **role** out if you are re-running an import. When you omit it, the role of anyone who is already a member is left exactly as it is. If you send `"role": 0` on every run, you will demote your group leaders to members.
{% endhint %}

Someone who was previously removed from a group is reactivated rather than added twice.

#### Example Response

```json
{
    "assigned": [
        {
            "user_id": "a9a1028f-93a6-401d-9867-1fe59aa2d830",
            "assigned_group_ids": ["64fd9793-0b67-4b02-a163-f2a7216292af"]
        }
    ],
    "skipped_user_ids": []
}
```

## Remove profiles from groups

Removes every listed profile from every listed group. The body is the same shape as the add endpoint, and **role** is ignored.

```plaintext
POST api/groups/unassign/
```

The membership is marked as removed rather than deleted, which is what happens when an admin removes someone in the app, so the record of when they joined survives.

#### Example Response

```json
{
    "removed": [
        {
            "user_id": "a9a1028f-93a6-401d-9867-1fe59aa2d830",
            "removed": 1
        }
    ],
    "skipped_user_ids": []
}
```
