Appearance
批量导入客户公海(异步)
接口信息
- 接口:
/agent-api/user/{user_id}/async_customer - 请求方式:
POST
路由参数
| 参数 | 类型 | 示例 | 解释 | 必填 |
|---|---|---|---|---|
| user_id | string | 5832d184-dd53-42a0-8ace-0bf8d660f4cc | 用户 id | 是 |
请求说明
- 此接口表示异步接口
- components 中的 id 为公海创建模板中输出的对应组件的 id 值,value 则为对应的要存储的公海的值
- 每次最多导入 200 条数据
请求参数
| 参数 | 类型 | 示例 | 解释 | 必填 |
|---|---|---|---|---|
| name | string | 联系人 1 | 联系人名称 | 否 |
| phone | string | 13012121211 | 号码 可开启加密 | 是 |
| string | 123456@qq.com | 邮箱 | 否 | |
| company | string | xxx 公司 | 公司 可开启加密 | 否 |
| sex | int | 0 | 姓名 (0:未知,1:男,2:女) | 否 |
| sort | int | 0 | 排序 | 是 |
| source_id | int | 0 | 信息来源 ID | 否 |
| industry_id | int | 0 | 信息行业 ID | 否 |
| grade_id | int | 0 | 客户等级 ID | 否 |
| components | array | [] | 组件数据 | 否 |
| extra | string | 0c51fc89-f6cf-405b-bb36-2c06900c3b5e | 额外数据,可用于标识第三方数据,可以不携带 | 否 |
| sub_user_id | string | 91f9254f-ca58-49af-be34-8370d7549d73 | 子账户 id(传递此参数则是对子账户操作) | 否 |
| encryption | bool | FALSE | 是否加密号码和公司(开启接口加密后有效) | 否 |
请求示例
json
{
"data": [
{
"name": "联系人1",
"phone": "13012121211",
"company": "xxx公司",
"email": "12345@qq.com",
"sex": 0,
"sort": 0,
"source_id": 1,
"industry_id": 2,
"grade_id": 1,
"extra": "0c51fc89-f6cf-405b-bb36-2c06900c3b5e",
"components": [
{
"id": "72544970-6cd6-44fd-8fd5-20b625bcbcf4",
"value": "小牛"
}
]
}
],
"encryption": false
}cURL
curl -X POST "https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/async_customer" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{
"data": [
{
"name": "联系人1",
"phone": "13012121211",
"company": "xxx公司",
"email": "12345@qq.com",
"sex": 0,
"sort": 0,
"source_id": 1,
"industry_id": 2,
"grade_id": 1,
"extra": "0c51fc89-f6cf-405b-bb36-2c06900c3b5e",
"components": [
{
"id": "72544970-6cd6-44fd-8fd5-20b625bcbcf4",
"value": "小牛"
}
]
}
],
"encryption": false
}'Go
package main
import (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
jsonData := []byte(`{
"data": [
{
"name": "联系人1",
"phone": "13012121211",
"company": "xxx公司",
"email": "12345@qq.com",
"sex": 0,
"sort": 0,
"source_id": 1,
"industry_id": 2,
"grade_id": 1,
"extra": "0c51fc89-f6cf-405b-bb36-2c06900c3b5e",
"components": [
{
"id": "72544970-6cd6-44fd-8fd5-20b625bcbcf4",
"value": "小牛"
}
]
}
],
"encryption": false
}`)
client := &http.Client{}
req, _ := http.NewRequest("POST", "https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/async_customer", bytes.NewBuffer(jsonData))
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Bearer YOUR_TOKEN")
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}JavaScript
const response = await fetch("https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/async_customer", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_TOKEN"
},
body: JSON.stringify({
data: [
{
name: "联系人1",
phone: "13012121211",
company: "xxx公司",
email: "12345@qq.com",
sex: 0,
sort: 0,
source_id: 1,
industry_id: 2,
grade_id: 1,
extra: "0c51fc89-f6cf-405b-bb36-2c06900c3b5e",
components: [
{
id: "72544970-6cd6-44fd-8fd5-20b625bcbcf4",
value: "小牛"
}
]
}
],
encryption: false
})
});
const data = await response.json();
console.log(data);Java
import java.net.HttpURLConnection;
import java.net.URL;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
public class Main {
public static void main(String[] args) throws Exception {
URL url = new URL("https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/async_customer");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Authorization", "Bearer YOUR_TOKEN");
conn.setDoOutput(true);
String jsonInput = "{\"data\":[{\"name\":\"联系人1\",\"phone\":\"13012121211\",\"company\":\"xxx公司\",\"email\":\"12345@qq.com\",\"sex\":0,\"sort\":0,\"source_id\":1,\"industry_id\":2,\"grade_id\":1,\"extra\":\"0c51fc89-f6cf-405b-bb36-2c06900c3b5e\",\"components\":[{\"id\":\"72544970-6cd6-44fd-8fd5-20b625bcbcf4\",\"value\":\"小牛\"}]}],\"encryption\":false}";
try (OutputStream os = conn.getOutputStream()) {
byte[] input = jsonInput.getBytes("utf-8");
os.write(input, 0, input.length);
}
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
StringBuilder response = new StringBuilder();
while ((line = br.readLine()) != null) {
response.append(line);
}
br.close();
System.out.println(response.toString());
}
}PHP
<?php
$ch = curl_init();
$data = [
"data" => [
[
"name" => "联系人1",
"phone" => "13012121211",
"company" => "xxx公司",
"email" => "12345@qq.com",
"sex" => 0,
"sort" => 0,
"source_id" => 1,
"industry_id" => 2,
"grade_id" => 1,
"extra" => "0c51fc89-f6cf-405b-bb36-2c06900c3b5e",
"components" => [
["id" => "72544970-6cd6-44fd-8fd5-20b625bcbcf4", "value" => "小牛"]
]
]
],
"encryption" => false
];
curl_setopt($ch, CURLOPT_URL, "https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/async_customer");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"Authorization: Bearer YOUR_TOKEN"
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>Python
import requests
import json
url = "https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/async_customer"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_TOKEN"
}
data = {
"data": [
{
"name": "联系人1",
"phone": "13012121211",
"company": "xxx公司",
"email": "12345@qq.com",
"sex": 0,
"sort": 0,
"source_id": 1,
"industry_id": 2,
"grade_id": 1,
"extra": "0c51fc89-f6cf-405b-bb36-2c06900c3b5e",
"components": [
{"id": "72544970-6cd6-44fd-8fd5-20b625bcbcf4", "value": "小牛"}
]
}
],
"encryption": False
}
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())C++
#include <iostream>
#include <curl/curl.h>
#include <string>
int main() {
CURL* curl = curl_easy_init();
if (curl) {
struct curl_slist* headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "Authorization: Bearer YOUR_TOKEN");
std::string json_data = R"({"data":[{"name":"联系人1","phone":"13012121211","company":"xxx公司","email":"12345@qq.com","sex":0,"sort":0,"source_id":1,"industry_id":2,"grade_id":1,"extra":"0c51fc89-f6cf-405b-bb36-2c06900c3b5e","components":[{"id":"72544970-6cd6-44fd-8fd5-20b625bcbcf4","value":"小牛"}]}],"encryption":false})";
curl_easy_setopt(curl, CURLOPT_URL, "https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/async_customer");
curl_easy_setopt(curl, CURLOPT_POST, 1L);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json_data.c_str());
CURLcode res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
return 0;
}返回示例
json
{
"code": 200,
"status": "success",
"message": "客户公海导入信息请在回调中查收",
"data": {
"unique_id": "afba23d9-4fd8-4dd9-a6b8-3837442abef3"
}
}字段说明
| 字段 | 说明 |
|---|---|
| unique_id | 本次回调的批次号,可使用查看回调数据去查询 |