> For the complete documentation index, see [llms.txt](https://docs.moocit.fr/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.moocit.fr/api/api-endpoints.md).

# Bulk enroll

## Bulk enroll

<mark style="color:green;">`POST`</mark> `https://your-platform-url.com/api/bulk_enroll/v1/bulk_enroll/`

Cet endpoint permet d'inscrire ou désinscrire un apprenants à un ou plusieurs cours.\
\
Permissions : Être administrateur du cours pour lequel vous souhaitez inscrire les utilisateurs.

#### Headers

| Name                           | Type   | Description           |
| ------------------------------ | ------ | --------------------- |
| Access-Control-Request-Headers | string | authorization         |
| Authorization                  | string | Bearer \<auth\_token> |
| Content-Type                   | string | application/json      |

{% tabs %}
{% tab title="200 Cake successfully retrieved." %}

```
{    "name": "Cake's name",    "recipe": "Cake's recipe name",    "cake": "Binary cake"}
```

{% endtab %}

{% tab title="404 Could not find a cake matching this query." %}

```
{    "message": "Ain't no cake like that."}
```

{% endtab %}
{% endtabs %}

## Bulk enrollment

*Inscrire un ou plusieurs utilisateurs dans un ou plusieurs cours.*

### Request example

```
POST /api/bulk_enroll/v1/bulk_enroll/ {
            "auto_enroll": true,
            "email_students": true,
            "action": "enroll",
            "courses": "course-v1:edX+Demo+123,course-v1:edX+Demo2+456",
            "cohorts": "cohortA,cohortA",
            "identifiers": "brandon@example.com,yamilah@example.com"
        }
```

### POST Parameters

| Key             | Comments                                                                                                                                                                                                           |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| auto\_enroll    | When set to `true`, students will be enrolled as soon as they register.                                                                                                                                            |
| email\_students | When set to `true`, students will be sent email notifications upon enrollment.                                                                                                                                     |
| action          | Can either be set to "enroll" or "unenroll". This determines the behavior                                                                                                                                          |
| cohorts         | Optional. If provided, the number of items in the list should be equal to the number of courses. first cohort coressponds with the first course and so on. The learners will be added to the corresponding cohort. |

### Response Values&#x20;

If the supplied course data is valid and the enrollments were successful, an HTTP 200 "OK" response is returned. The HTTP 200 response body contains a list of response data for each enrollment. If a cohorts list is provided, additional 'cohort' keys will be added to the 'before' and 'after' states.

```
{
    "action": "unenroll",
    "courses": {
        "course-v1:edX+DemoX+Demo_Course": {
            "action": "unenroll",
            "results": [
                {
                    "identifier": "test-email@example.com",
                    "after": {
                        "enrollment": true,
                        "allowed": false,
                        "user": true,
                        "auto_enroll": false
                    },
                    "before": {
                        "enrollment": false,
                        "allowed": false,
                        "user": true,
                        "auto_enroll": false
                    }
                }
            ],
            "auto_enroll": true
        }
    },
    "email_students": false,
    "auto_enroll": true
}
```
