# Add multiple courses to multiple users

## Add multiple courses to multiple users

<mark style="color:green;">`POST`</mark> `https://abc.hoola.vn/manage/api/courses/add-multi-course-to-multi-user`

To avoid timeout requests and make it easier to track results, only add courses to a maximum of 100 accounts in one query.

#### Query Parameters

| Name  | Type   | Description                  |
| ----- | ------ | ---------------------------- |
| token | string | Account Authentication Token |

#### Request Body

| Name    | Type  | Description           |
| ------- | ----- | --------------------- |
| users   | array | An array of User ID   |
| courses | array | An array of Course ID |

{% tabs %}
{% tab title="200 Query successfully" %}

```javascript
// Response Code "00". Query successfully. 
// Return data:
{
    "respCode": "00",
    "validCourses": [
        {
            "_id": "2LnbF77cmzF5J8bHE",
            "title": "Trắc nghiệm"
        },
        {
            "_id": "vivPteJNNC2P94Es8",
            "title": "15 Thủ Pháp Thị Giác Trong Nhiếp Ảnh"
        }
    ],
    "result": [
        {
            "userId": "urs2vByNw9ETg9XYZ",
            "success": true,
            "status": "Success"
        },
        {
            "userId": "cc95fXX5PTX5qDR9R",
            "success": true,
            "status": "Success"
        },
        {
            "userId": "MPC5B5dsdYD9Ak283",
            "success": true,
            "status": "Success"
        },
        {
            "userId": "msnJmaPa7KmtEzz3q",
            "success": true,
            "status": "Success"
        }
    ],
    "msg": "4 tài khoản thêm khoá học thành công, 0 tài khoản thêm khoá học lỗi"
}
```

{% endtab %}

{% tab title="400 Missing parameter or malfunctioned parameter" %}

```javascript
// Response Code "02". No body request.
// Return data:
{
    "respCode": "02",
    "msg": "Không có body request"
}


// Response Code "03". No user arra parameter in the body request.
    "respCode": "03",
    "msg": "Không có tham số mảng users trong body request"
} 

// Response Code "04". User parameter in the body request is not an array.
{
        "respCode": "04",
    "msg": "Tham số users trong body request không phải là mảng"
} 


// Response Code "05". User parameter is an empty array
{
    "respCode": "05",
    "msg": "Tham số users trong body request là mảng rỗng"
} 


// Response Code "06". No course parameter in the body request.
// Return data:
{
    "respCode": "06",
    "msg": "Không có tham số mảng courses trong body request"
} 


// Response Code "07". Course parameter is not an array.
// Return data:
{
    "respCode": "07",
    "msg": "Tham số courses trong body request không phải là mảng"
} 


// Response Code "08". Course parameter is an empty array.
// Return data:
{
    "respCode": "07",
    "msg": "Tham số courses trong body request là mảng rỗng"
} 


// Response Code "09". Token not provided.
// Return data:
{
    "respCode": "07",
    "msg": "Không có token"
} 


// Response Code "13". Course parameter is not in the right format.
// Return data:
{
    "respCode": "13",
    "msg": "Mảng courses không đúng định dạng"
} 


// Response Code "14". Course not found.
// Return data:
{
    "respCode": "14",
    "msg": "Không tìm thấy khoá học"
} 


// Response Code "16". Cannot add courses to any account.
// Return data:
{
    "respCode": "16",
    "msg": "Không thêm được khoá học cho tài khoản nào"
} 
```

{% endtab %}

{% tab title="401 Fail to verify your account" %}

```javascript
// Response Code "11". Token is invalid or has expired.
// Return data:
{
    "respCode": "11",
    "msg": "Invalid token || Token has expired"
}
```

{% endtab %}

{% tab title="403 Your account is not authorized to perform the query." %}

```javascript
// Response Code "12". Your account is not authorized to perform the query.
// Return data:
{
    "respCode": "12",
    "msg": "Your account does not have permission"
}
```

{% endtab %}

{% tab title="405 Wrong request method" %}

```javascript
// Response Code "01". Wrong request method.
// Return data:
{
    "respCode": "01",
    "msg": "Request method should be POST"
}
```

{% endtab %}

{% tab title="500 Server error" %}

```javascript
// Response Code "10". Server not able to authenticate your account.
// Return data:
{
    "respCode": "10" 
    "msg": "Server not able to authenticate your account"
} 
```

{% endtab %}
{% endtabs %}

Example:

```javascript
// GET:
https://abc.hoola.vn/manage/api/courses/add-multi-course-to-multi-user?token=sdhg23797sdbv9186jdvk58

body: {
    users: ["msnJmaPa7KmtEzz3q", "cc95fXX5PTX5qDR9R", "urs2vByNw9ETg9XYZ", "MPC5B5dsdYD9Ak283"],
    courses: ["vivPteJNNC2P94Es8", "2LnbF77cmzF5J8bHE"]
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hoola.vn/english/api/add-multi-course-to-multi-user.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
