# 创建并分配任务

### 域名
* https://api.incsapp.com

### 请求路由
* /external/tasks

### 请求方式
* **POST**

### 请求头
* Content-Type: application/json
* Authorization: Bearer a06b3b2d7f762....

### 请求参数
#### 请求参数列表

|参数名|类型| 必填| 描述|
|-|-|-|-|
|name|string|是|任务名称，限256字符
|description|string|否|任务描述，限256字符
|type|int|是|任务类型，这里固定为3（消息任务类型）
|auth_id|int|是|incs开通的 whatsapp 授权id
|user_phone|string|是|任务对象手机号，必须是区号开头的纯数字格式，例如："6281512341234"
|user_name|string|否|任务对象名称
|assignee_username|string|是|任务被分配人账号
|task_module_info|object|否|任务聊天窗口展示信息的定制化展示，见下述示例

#### 请求示例

```json
{
    "name": "by api",
    "type": 3,
    "auth_id": 30058,
    "description": "123",
    "user_name": "路人A",
    "user_phone": "6281512345678",
    "assignee_username": "incs_1",
    "task_module_info": {
        "module_id": "019d3dcd-f5a8-70e7-aff8-c54bde267f38", // 定制模块ID，该模块类型固定传此ID
        "total_amount": "20000.00",
        "orders": [
                {
                    "order_number": "WD20260401001",
                    "username": "张三",
                    "phone_number": "13800138000",
                    "loan_amount": "",
                    "due_amount": "",
                    "next_due_date": "2026-04-15",
                    "confirm_loan_time": "2026-03-01 10:00:00"
                },
                {
                    "order_number": "WD20260401002",
                    "username": "李四",
                    "phone_number": "13900139000",
                    "loan_amount": "3000",
                    "due_amount": "1500",
                    "next_due_date": "2026-04-20",
                    "confirm_loan_time": "2026-03-10 14:30:00"
                }
            ]
    }
}
```



### 响应
#### 成功响应示例
```json
{
    "status": "success",
    "code": 200,
    "message": "",
    "data": {
        "id": 239, // 任务id
        "creation_id": 106, // 任务批次id
        "auth_id": 30058,
        "name": "test api 1",
        "description": "2sfsdfsdfd",
        "type": 3,
        "user_name": "路人B",
        "user_phone": "6281512340001",
        "assignee_username": "incs_1",
        "conversation_id": 1023, // 分配的会话id
        "status": 0,
        "created_at": "2026-04-16 17:44:48",
        "updated_at": "2026-04-16 17:44:51",
        "logs": []
    },
    "error": {}
}
```
#### 失败响应示例
```json
{
    "status": "error",
    "code": 400,
    "message": "User is in an incomplete task.", // 用户被分配任务还未完成
    "data": {},
    "error": {}
}
```