> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://developer.gitiho.com/gitiho-business-api/lms/assign-khoá-học/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developer.gitiho.com/_mcp/server. # Assign khoá học POST https://example.gitiho.com/api/lms/assign-course Content-Type: application/json Gán một hoặc nhiều khoá học cho nhân sự trong cùng một lần gọi (batch). Thao tác **auto-confirm** (không cần bước xác nhận riêng) và **idempotent theo từng item** (nhân sự đã được assign khoá đó sẽ tự bỏ qua, không tính phí lần hai). **Body params:** | Param | Bắt buộc | Kiểu | Mô tả | |-------|----------|------|-------| | `items` | Có | array (1–100) | Danh sách cặp khoá – nhân sự cần assign | | `items[].course_id` | Có | int | ID khoá học (theo `course_id` platform ở endpoint danh mục) | | `items[].employer_id` | Có | int | ID nhân sự | | `deadline` | Không | date | Hạn hoàn thành áp cho các item trong batch | | `idempotency_key` | Không | string (max 64) | Không bắt buộc tự sinh. Nếu gửi, hệ thống hỗ trợ replay: cùng key đã xử lý sẽ trả lại kết quả cũ thay vì tạo/tính phí lại (kể cả khi hai request cùng key chạy đồng thời) | **Hành vi:** - Lỗi ở **mức order** (còn hoá đơn chưa thanh toán, thiếu credit…) sẽ làm **fail toàn bộ batch** và trả về mã lỗi tương ứng. - Nếu order hợp lệ, từng item được xử lý độc lập với trạng thái riêng. **Response gồm:** `order_id`, `status` (`assigned` khi tạo order thành công), `amount` (tổng phí), `invoice_id`, `replayed` (true nếu là kết quả replay theo idempotency_key), `summary` (`total` / `valid` / `invalid`), và `items[]` — mỗi item có `course_id`, `employer_id`, `status` (`assigned`, `skipped_already_assigned`, `invalid_employer`, `invalid_course`), `status_text` (diễn giải). Reference: https://developer.gitiho.com/gitiho-business-api/lms/assign-khoá-học ## Request ### Body (application/json) This endpoint expects an object. - `items` (list of AssignKhoaHọcLmsRequestItemsItem, required) - `deadline` (date, required) - `idempotency_key` (string, required) ## Types ### AssignKhoaHọcLmsRequestItemsItem - `course_id` (integer, required) - `employer_id` (integer, required) ## Examples **Request** ```json { "items": [ { "course_id": 123, "employer_id": 174 }, { "course_id": 123, "employer_id": 1048 } ], "deadline": "2026-09-30", "idempotency_key": "11111" } ``` **SDK Code** ```python import requests url = "https://example.gitiho.com/api/lms/assign-course" payload = { "items": [ { "course_id": 123, "employer_id": 174 }, { "course_id": 123, "employer_id": 1048 } ], "deadline": "2026-09-30", "idempotency_key": "11111" } headers = {"Content-Type": "application/json"} response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://example.gitiho.com/api/lms/assign-course'; const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"items":[{"course_id":123,"employer_id":174},{"course_id":123,"employer_id":1048}],"deadline":"2026-09-30","idempotency_key":"11111"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://example.gitiho.com/api/lms/assign-course" payload := strings.NewReader("{\n \"items\": [\n {\n \"course_id\": 123,\n \"employer_id\": 174\n },\n {\n \"course_id\": 123,\n \"employer_id\": 1048\n }\n ],\n \"deadline\": \"2026-09-30\",\n \"idempotency_key\": \"11111\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://example.gitiho.com/api/lms/assign-course") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Content-Type"] = 'application/json' request.body = "{\n \"items\": [\n {\n \"course_id\": 123,\n \"employer_id\": 174\n },\n {\n \"course_id\": 123,\n \"employer_id\": 1048\n }\n ],\n \"deadline\": \"2026-09-30\",\n \"idempotency_key\": \"11111\"\n}" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://example.gitiho.com/api/lms/assign-course") .header("Content-Type", "application/json") .body("{\n \"items\": [\n {\n \"course_id\": 123,\n \"employer_id\": 174\n },\n {\n \"course_id\": 123,\n \"employer_id\": 1048\n }\n ],\n \"deadline\": \"2026-09-30\",\n \"idempotency_key\": \"11111\"\n}") .asString(); ``` ```php request('POST', 'https://example.gitiho.com/api/lms/assign-course', [ 'body' => '{ "items": [ { "course_id": 123, "employer_id": 174 }, { "course_id": 123, "employer_id": 1048 } ], "deadline": "2026-09-30", "idempotency_key": "11111" }', 'headers' => [ 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://example.gitiho.com/api/lms/assign-course"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"items\": [\n {\n \"course_id\": 123,\n \"employer_id\": 174\n },\n {\n \"course_id\": 123,\n \"employer_id\": 1048\n }\n ],\n \"deadline\": \"2026-09-30\",\n \"idempotency_key\": \"11111\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = ["Content-Type": "application/json"] let parameters = [ "items": [ [ "course_id": 123, "employer_id": 174 ], [ "course_id": 123, "employer_id": 1048 ] ], "deadline": "2026-09-30", "idempotency_key": "11111" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://example.gitiho.com/api/lms/assign-course")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```