> 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/editor-5/write-operations/assign-users-to-opportunities.md).

# Assign users to opportunities

The endpoint assigns one or more users to one or more opportunities. If multiple `user_ids` are provided, multiple users are assigned. If multiple `opportunity_ids` are provided, each user is assigned to each opportunity.

The endpoint only accepts published opportunities that belong to your institution. If an assignment already exists, it is returned with `"created": false`; otherwise a new enrollment is created. All assigned enrollments are set to approved status.

The API additionally triggers: opportunity assignment notifications to users\
chat user creation for the assigned enrollments

**Endpoint**\
`POST /api/opportunities/bulk-assign/`

**Payload sample**

```json
{
  "user_ids": [
    "06d9d2da-e99d-4c9a-9f95-c9acd55e9ee1",
    "de89a718-51f6-46e2-800f-56709879f179",
    "5a8046f9-e698-49b7-b69f-a732ff13502b"
  ],
  "opportunity_ids": [
    "a167ac3f-952e-417d-85e6-6d4f74306950"
  ]
}
```

**Response sample**

```json
{
  "assignment_count": 3,
  "created_count": 3,
  "existing_count": 0,
  "enrollments": [
    {
      "id": "3b4e9461-8b34-4d5b-9c3d-48f6f85f0f01",
      "user_id": "06d9d2da-e99d-4c9a-9f95-c9acd55e9ee1",
      "opportunity_id": "a167ac3f-952e-417d-85e6-6d4f74306950",
      "created": true
    },
    {
      "id": "61a1f40d-1f5a-49f0-b3e7-34ac3f5dc6d7",
      "user_id": "de89a718-51f6-46e2-800f-56709879f179",
      "opportunity_id": "a167ac3f-952e-417d-85e6-6d4f74306950",
      "created": true
    },
    {
      "id": "a3cc6f4c-d0ed-44e5-9a94-c2e30d540f70",
      "user_id": "5a8046f9-e698-49b7-b69f-a732ff13502b",
      "opportunity_id": "a167ac3f-952e-417d-85e6-6d4f74306950",
      "created": true
    }
  ]
}
```
