# 创建来源


**应用场景**

1.支持通过本接口创建自定义来源。

```
POST https://qw-openapi-tx.dustess.com/source/v1/create?accessToken=

Content-Type: application/json
```

**接口限制**：每分钟调用600次；

**请求参数**

| 参数名      | 类型       | 说明                                        | 是否必须 |
| ----------- | ---------- | ------------------------------------------- | -------- |
| parentCode  | `String`   | 来源父节点id，为空时代表创建一级来源        | false    |
| names       | `String[]` | 来源名称 传递多个代表创建多个来源、不能重名 | true     |
| isToAnother | `Bool`     | 是否可以修改为其他来源                      | False    |
| isEnable    | `Bool`     | 是否启用                                    | false    |

**请求示例**
`json` - Request-Example:


```json
{
    "parentCode": "",
    "names": [
        "添加一个试试"
    ],
    "isToAnother": false,
    "isEnable": true
}
```

**响应参数**

| 参数名                   | 类型     | 说明                              |
| ------------------------ | -------- | --------------------------------- |
| success                  | `Bool`   | 请求成功失败标识                  |
| code                     | `Int`    | 响应码                            |
| msg                      | `String` | 响应信息                          |
| data                     | `Object` | 数据信息                          |
| data.list                | `Array`  | 数组                              |
| data.list.ancestors      | `Array`  | 祖先节点来源                      |
| data.list.isEnable       | `Bool`   | 是否启用                          |
| data.list.isLeaf         | `Bool`   | 是否叶子节点                      |
| data.list.isRoot         | `Bool`   | 是否根节点                        |
| data.list.isToAnother    | `Bool`   | 是否可以修改其他来源              |
| data.list.name           | `String` | 来源名称                          |
| data.list.sourceCode     | `String` | 来源code                          |
| data.list.sourceRootCode | `String` | 根节点来源code                    |
| data.list.sourceType     | `Int`    | 来源类型 1=预设来源 2= 自定义来源 |
| traceId                  | `String` | 上下文链路id                      |

**成功响应示例**

`json` - Response-Example:

```json
{
    "code": 0,
    "data": {
        "list": [
            {
                "ancestors": [],
                "isEnable": true,
                "isLeaf": true,
                "isRoot": true,
                "isToAnother": false,
                "name": "测试0001",
                "sourceCode": "083",
                "sourceRootCode": "083",
                "sourceType": 2
            }
        ]
    },
    "msg": "OK",
    "success": true,
    "traceId": "e214d088-c097-981f-a2a3-3cfe23ddeaef"
}
```

**失败响应示例**

`json` - Response-Example:

```json
{
    "code": 20110211,
    "data": {},
    "msg": "来源名称已存在：[测试0001]",
    "success": false,
    "traceId": "a769cf5a-ec9e-9cef-a05c-a99a2347dbb6"
}
```
