資料來源 API
概述
資料來源 (DataSource) 用於儲存外撥任務的聯絡人數據。通過此 API,可以管理資料來源的生命週期、上傳/下載聯絡人清單,以及進行聯絡人級別的 CRUD 操作。
資料來源列表
請求方式
http
GET /api/dataSource/list
Content-Type: application/json
Authorization: Bearer {accessToken}查詢參數
| 參數名 | 型別 | 必填 | 說明 |
|---|---|---|---|
pageNum | integer | 否 | 頁碼,預設值為 1 |
pageSize | integer | 否 | 每頁數量,預設值為 20 |
dataSourceName | string | 否 | 資料來源名稱 (支援模糊查詢) |
請求範例
bash
curl -X GET "https://api.aicc.com/api/dataSource/list?pageNum=1&pageSize=20" \
-H "Authorization: Bearer {accessToken}" \
-H "Content-Type: application/json"回應範例
json
{
"code": 0,
"message": "success",
"data": {
"total": 3,
"rows": [
{
"id": "1",
"dataSourceName": "2026年Q1活動名單",
"dataSourceDesc": "第一季度營銷活動的聯絡人清單",
"contactCount": 1000,
"createTime": "2026-02-01 10:00:00",
"updateTime": "2026-03-20 14:30:00"
},
{
"id": "2",
"dataSourceName": "VIP客戶名單",
"dataSourceDesc": "高價值客戶群體",
"contactCount": 250,
"createTime": "2026-01-15 09:00:00",
"updateTime": "2026-03-18 16:45:00"
}
]
}
}取得資料來源詳情
請求方式
GET /api/dataSource/detail/{id}
Content-Type: application/json
Authorization: Bearer {accessToken}路徑參數
| 參數名 | 型別 | 必填 | 說明 |
|---|---|---|---|
id | string | 是 | 資料來源 ID |
請求範例
bash
curl -X GET "https://api.aicc.com/api/dataSource/detail/1" \
-H "Authorization: Bearer {accessToken}" \
-H "Content-Type: application/json"回應範例
json
{
"code": 0,
"message": "success",
"data": {
"id": "1",
"dataSourceName": "2026年Q1活動名單",
"dataSourceDesc": "第一季度營銷活動的聯絡人清單",
"contactCount": 1000,
"createTime": "2026-02-01 10:00:00",
"updateTime": "2026-03-20 14:30:00"
}
}新增資料來源
請求方式
POST /api/dataSource/add
Content-Type: application/json
Authorization: Bearer {accessToken}請求參數
| 參數名 | 型別 | 必填 | 說明 |
|---|---|---|---|
dataSourceName | string | 是 | 資料來源名稱,長度 1-100 字元 |
dataSourceDesc | string | 否 | 資料來源說明 |
請求範例
json
{
"dataSourceName": "夏季促銷活動",
"dataSourceDesc": "2026年夏季營銷活動的客戶清單"
}成功回應範例
json
{
"code": 0,
"message": "success",
"data": {
"id": "3",
"dataSourceName": "夏季促銷活動",
"dataSourceDesc": "2026年夏季營銷活動的客戶清單",
"contactCount": 0,
"createTime": "2026-03-23 15:00:00"
}
}修改資料來源
請求方式
POST /api/dataSource/update
Content-Type: application/json
Authorization: Bearer {accessToken}請求參數
| 參數名 | 型別 | 必填 | 說明 |
|---|---|---|---|
id | string | 是 | 資料來源 ID |
dataSourceName | string | 否 | 資料來源名稱 |
dataSourceDesc | string | 否 | 資料來源說明 |
請求範例
json
{
"id": "3",
"dataSourceName": "2026年夏季促銷活動",
"dataSourceDesc": "已更新的說明"
}成功回應範例
json
{
"code": 0,
"message": "success",
"data": {
"id": "3",
"dataSourceName": "2026年夏季促銷活動",
"dataSourceDesc": "已更新的說明",
"contactCount": 0,
"updateTime": "2026-03-23 15:30:00"
}
}聯絡人列表
請求方式
GET /api/dataSource/{id}/contacts
Content-Type: application/json
Authorization: Bearer {accessToken}路徑參數
| 參數名 | 型別 | 必填 | 說明 |
|---|---|---|---|
id | string | 是 | 資料來源 ID |
查詢參數
| 參數名 | 型別 | 必填 | 說明 |
|---|---|---|---|
pageNum | integer | 否 | 頁碼,預設值為 1 |
pageSize | integer | 否 | 每頁數量,預設值為 20 |
phoneNumber | string | 否 | 電話號碼 (支援模糊查詢) |
請求範例
bash
curl -X GET "https://api.aicc.com/api/dataSource/1/contacts?pageNum=1&pageSize=20" \
-H "Authorization: Bearer {accessToken}" \
-H "Content-Type: application/json"回應範例
json
{
"code": 0,
"message": "success",
"data": {
"total": 1000,
"rows": [
{
"id": "contact_1",
"dataSourceId": "1",
"customerName": "王小明",
"phoneNumber": "0912345678",
"address": "台北市信義區",
"orderAmount": "5000",
"status": 0,
"callCount": 0,
"createTime": "2026-02-01 10:00:00"
},
{
"id": "contact_2",
"dataSourceId": "1",
"customerName": "李美香",
"phoneNumber": "0987654321",
"address": "台中市西屯區",
"orderAmount": "8000",
"status": 0,
"callCount": 0,
"createTime": "2026-02-01 10:00:00"
}
]
}
}新增聯絡人
請求方式
POST /api/dataSource/{id}/contact/add
Content-Type: application/json
Authorization: Bearer {accessToken}路徑參數
| 參數名 | 型別 | 必填 | 說明 |
|---|---|---|---|
id | string | 是 | 資料來源 ID |
請求參數
依照自定義欄位結構。必填欄位:
phoneNumber- 電話號碼
請求範例
json
{
"customerName": "張三",
"phoneNumber": "0912345678",
"address": "台北市松山區",
"orderAmount": "3000"
}成功回應範例
json
{
"code": 0,
"message": "success",
"data": {
"id": "contact_1001",
"dataSourceId": "1",
"customerName": "張三",
"phoneNumber": "0912345678",
"address": "台北市松山區",
"orderAmount": "3000",
"status": 0,
"createTime": "2026-03-23 15:00:00"
}
}修改聯絡人
請求方式
POST /api/dataSource/{id}/contact/update
Content-Type: application/json
Authorization: Bearer {accessToken}路徑參數
| 參數名 | 型別 | 必填 | 說明 |
|---|---|---|---|
id | string | 是 | 資料來源 ID |
請求參數
| 參數名 | 型別 | 必填 | 說明 |
|---|---|---|---|
contactId | string | 是 | 聯絡人 ID |
| 其他欄位 | - | 否 | 需要修改的欄位 |
請求範例
json
{
"contactId": "contact_1",
"customerName": "王小明 (已更新)",
"address": "台北市大安區"
}成功回應範例
json
{
"code": 0,
"message": "success",
"data": {
"id": "contact_1",
"dataSourceId": "1",
"customerName": "王小明 (已更新)",
"phoneNumber": "0912345678",
"address": "台北市大安區",
"updateTime": "2026-03-23 15:30:00"
}
}刪除聯絡人
請求方式
POST /api/dataSource/{id}/contact/delete
Content-Type: application/json
Authorization: Bearer {accessToken}路徑參數
| 參數名 | 型別 | 必填 | 說明 |
|---|---|---|---|
id | string | 是 | 資料來源 ID |
請求參數
| 參數名 | 型別 | 必填 | 說明 |
|---|---|---|---|
contactId | string | 是 | 聯絡人 ID |
請求範例
json
{
"contactId": "contact_1"
}成功回應範例
json
{
"code": 0,
"message": "success",
"data": null
}批次上傳聯絡人
請求方式
POST /api/dataSource/{id}/contact/batchImport
Content-Type: multipart/form-data
Authorization: Bearer {accessToken}路徑參數
| 參數名 | 型別 | 必填 | 說明 |
|---|---|---|---|
id | string | 是 | 資料來源 ID |
請求參數
| 參數名 | 型別 | 必填 | 說明 |
|---|---|---|---|
file | file | 是 | CSV 或 Excel 檔案,第一行為欄位標題 |
CSV 檔案格式範例
customerName,phoneNumber,address,orderAmount
王小明,0912345678,台北市信義區,5000
李美香,0987654321,台中市西屯區,8000
張三,0912111111,新竹市東區,3000回應範例
json
{
"code": 0,
"message": "success",
"data": {
"importCount": 3,
"successCount": 3,
"failCount": 0,
"details": []
}
}批次下載聯絡人
請求方式
GET /api/dataSource/{id}/contact/batchExport
Authorization: Bearer {accessToken}路徑參數
| 參數名 | 型別 | 必填 | 說明 |
|---|---|---|---|
id | string | 是 | 資料來源 ID |
查詢參數
| 參數名 | 型別 | 必填 | 說明 |
|---|---|---|---|
format | string | 否 | 匯出格式 (csv、excel),預設為 excel |
請求範例
bash
curl -X GET "https://api.aicc.com/api/dataSource/1/contact/batchExport?format=excel" \
-H "Authorization: Bearer {accessToken}" \
-o contacts.xlsx回應
直接返回檔案流,檔案名稱為 contacts_[timestamp].[format]
常見錯誤
| 錯誤碼 | 說明 | 解決方案 |
|---|---|---|
| 400 | 資料來源名稱為空 | 提供有效的資料來源名稱 |
| 404 | 資料來源不存在 | 確認資料來源 ID 是否正確 |
| 409 | 資料來源名稱已存在 | 使用不同的資料來源名稱 |
| 413 | 上傳檔案過大 | 分批上傳,每次不超過 10000 行 |
注意事項
- 電話號碼:必填欄位,聯絡人識別的主要依據
- 批次操作:建議每次上傳不超過 10000 行,避免超時
- 資料驗證:匯入前應驗證欄位格式,特別是必填欄位
- 重複檢查:系統會根據電話號碼檢查重複,建議事先檢查原始數據