# Tạo lịch trình

Lưu tác vụ theo lịch trình điện thoại đám mây.
templateParameter Parameter Specification
1. **Parameter Source**
Parameter keys must be extracted from the `parameter` field returned by the following APIs:

- Get market template pages
- Get Personal template pages

1. **Data Structure**

- Submit parameters in JSON object format: `{"key1": "value1", "key2": "value2"}`
- Final parameter values must be deserialized according to business logic before use

1. **Common Type Parameters**
For the following parameter types, pass values directly in the corresponding format:

- string: `{"name": "John"}`
- decimal / number: `{"amount": 100.50}`
- boolean: `{"enabled": true}`

1. **Media Type Parameters**
For media parameters such as image (pic) or video (video), in addition to basic information, a fixed key `"__Extra__"` must be included. Example format:


```json
{
    "__Extra__": {
        "pic": {
            "name": "pic_name",
            "size": 204800
        },
        "video": {
            "name": "video_name",
            "size": 204800000
        }
    },
    "pic": "https://get.morelogin.com/prod/cloudPhoneTaskVideo/1556061681934880/1c62314c7e2b4d298abe8d5452d7c050/test.png",
    "video": "https://get.morelogin.com/pre/cloudPhoneTaskVideo/1542431036481556/4c4fed83685345ae8f1505fbe0c2f123/baby.mp4"
}
```
1. **Parameter Configuration Example**
The following example demonstrates how to configure the `templateParameter` parameter when saving a plan using a market template:

- **Step 1: Retrieve Template Parameters**
Call the Market Template API:
`GET /api/cloudphone/rpa/template/market/page`
Extract the `parameter` field from the response, for example:


```json
"parameter": "{\"videoDownloadUrl\":{\"type\":\"video\",\"extra\":{\"name\":\"Select Video\",\"type\":\"video\",\"required\":true,\"defaultValue\":{\"enabled\":false},\"index\":1,\"sizeLimit\":{\"value\":200,\"unit\":\"MB\"},\"formatType\":[\"mp4\",\"mov\"]}},\"videoDescription\":{\"type\":\"string\",\"extra\":{\"name\":\"Video Caption\",\"type\":\"string\",\"required\":false,\"charValid\":{\"enabled\":true,\"value\":1000},\"multiline\":{\"enabled\":true,\"value\":3},\"defaultValue\":{\"enabled\":false},\"index\":2}},\"coverUrl\":{\"type\":\"image\",\"extra\":{\"name\":\"Cover Image\",\"type\":\"image\",\"required\":false,\"defaultValue\":{\"enabled\":false},\"index\":3,\"sizeLimit\":{\"value\":5,\"unit\":\"MB\"},\"formatType\":[\"jpg\",\"png\",\"jpeg\"]}},\"enableAIGC\":{\"type\":\"boolean\",\"extra\":{\"name\":\"AI Label\",\"type\":\"boolean\",\"required\":false,\"defaultValue\":{\"enabled\":false},\"index\":4}},\"productId\":{\"type\":\"string\",\"extra\":{\"name\":\"Product ID\",\"type\":\"string\",\"required\":false,\"charValid\":{\"enabled\":true,\"value\":50},\"placeholder\":\"Product ID only supports digits, with a maximum of 50 characters.\",\"defaultValue\":{\"enabled\":false},\"index\":5}},\"productTitle\":{\"type\":\"string\",\"extra\":{\"name\":\"Product Title\",\"type\":\"string\",\"required\":false,\"charValid\":{\"enabled\":true,\"value\":30},\"defaultValue\":{\"enabled\":false},\"index\":6}},\"getLeads\":{\"type\":\"boolean\",\"extra\":{\"name\":\"Get Leads\",\"type\":\"boolean\",\"required\":false,\"defaultValue\":{\"enabled\":false},\"index\":7}},\"comment\":{\"type\":\"string\",\"extra\":{\"name\":\"Comment\",\"type\":\"string\",\"required\":false,\"charValid\":{\"enabled\":true,\"value\":200},\"multiline\":{\"enabled\":true,\"value\":3},\"defaultValue\":{\"enabled\":false},\"index\":8}}}"
```
- **Step 2: Build the Parameter JSON**
Construct the JSON object according to the parameter requirements:


```json
{
  "__Extra__": {
    "videoDownloadUrl": {
      "name": "video_name.mp4",
      "size": 204800000
    }
  },
  "videoDownloadUrl": "https://get.morelogin.com/pre/cloudPhoneTaskVideo/1542431036481556/4c4fed83685345ae8f1505fbe0c2f123/baby.mp4"
}
```
- **Step 3: Escape the JSON String**
Convert the JSON object into an escaped string format:


```json
"{\"__Extra__\": {\"videoDownloadUrl\": {\"name\": \"video_name.mp4\",\"size\": 204800000}},\"videoDownloadUrl\": \"https://get.morelogin.com/pre/cloudPhoneTaskVideo/1542431036481556/4c4fed83685345ae8f1505fbe0c2f123/baby.mp4\"}"
```
- **Step 4: API Call**
Pass the escaped string as the value of the `templateParameter` parameter to the target API.

Endpoint: POST /cloudphone/rpa/task/save
Version: 1.0.0

## Request fields (application/json):

  - `taskName` (string, required)
    Tên tác vụ

  - `templateId` (integer, required)
    ID mẫu

  - `templateType` (string, required)
    Loại mẫu. PERSONAL:cá nhân; MARKET:thị trường

  - `taskType` (string, required)
    Loại tác vụ. TEMPORARY hoặc SCHEDULED

  - `notes` (string)
    Ghi chú kế hoạch

  - `cloudPhoneConfigs` (array, required)
    Bộ sưu tập cấu hình lịch trình điện thoại đám mây

  - `cloudPhoneConfigs.cloudPhoneId` (integer, required)
    ID điện thoại đám mây

  - `cloudPhoneConfigs.triggerTime` (string, required)
    Thời gian thực hiện tác vụ, múi giờ UTC+0

  - `cloudPhoneConfigs.templateParameter` (string, required)
    Các tham số mẫu được xác định trong mẫu cá nhân hoặc mẫu thị trường. Các tham số trong mẫu được xác định là:{"Test":{"extra":{"type":"string","required":true,"multiline":{"enabled":false},"name":"Test","index":1},"type":"string"}} Khi yêu cầu tham số, tham số được truyền là:{"Test":"xxxx"}

  - `scheduleConfig` (object, required)
    Cấu hình lịch trình tác vụ

  - `scheduleConfig.endTime` (string, required)
    ngày-giờ

  - `scheduleConfig.scheduleType` (string, required)
    Loại lịch trình. ONCE:một lần; DAILY:hàng ngày

## Response 200 fields (application/json):

  - `code` (integer, required)
    Mã phản hồi, 0 cho biết thành công, >0 cho biết thất bại

  - `msg` (string, required)
    Thông báo lỗi

  - `requestId` (string, required)
    ID theo dõi yêu cầu

  - `data` (integer, required)
    ID lịch trình

