POST /api/v1/intents
创建新的采购意图。
接口说明
- 需要认证 - 需要提供 X-App-Id、X-Timestamp、X-Signature 请求头
- 用途 - 提交采购需求,系统将自动处理采购流程
- 幂等性 - 非幂等接口,重复调用会创建多个意图
请求头
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
Content-Type | string | 是 | 固定值:application/json |
X-App-Id | string | 是 | 应用 ID |
X-Timestamp | string | 是 | 请求时间戳(毫秒) |
X-Signature | string | 是 | 请求签名 |
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
userId | string | 是 | 发起用户 ID,用于标识采购发起人 |
platform | string | 是 | 电商平台:TAOBAO(淘宝)/ JD(京东)/ PDD(拼多多) |
productUrl | string | 是 | 商品原始链接,必须是有效的商品详情页 URL |
title | string | 是 | 商品标题,最长 200 字符 |
price | number | 是 | 商品单价(元),必须大于 0 |
quantity | number | 是 | 采购数量,必须为正整数 |
recipientName | string | 是 | 收货人姓名,2-50 个字符 |
address | string | 是 | 收货详细地址,5-200 个字符 |
phone | string | 是 | 收货人联系电话,11 位手机号码 |
remarks | string | 否 | 备注信息,最长 500 字符 |
请求示例
cURL
curl -X POST "https://api.procure-core.com/api/v1/intents" \
-H "Content-Type: application/json" \
-H "X-App-Id: dev_app_local" \
-H "X-Timestamp: 1708851000000" \
-H "X-Signature: abc123..." \
-d '{
"userId": "user_001",
"platform": "TAOBAO",
"productUrl": "https://item.taobao.com/item.htm?id=123456",
"title": "Apple iPhone 15 Pro 256GB",
"price": 8999,
"quantity": 1,
"recipientName": "张三",
"address": "北京市朝阳区望京SOHO T1 1001",
"phone": "13800138000",
"remarks": "请在工作日送达"
}'TypeScript / JavaScript
import { ProcureClient } from '@procure-core/sdk';
const client = new ProcureClient({
appId: 'your_app_id',
appSecret: 'your_app_secret',
baseURL: 'https://api.procure-core.com'
});
const intent = await client.intents.create({
userId: 'user_001',
platform: 'TAOBAO',
productUrl: 'https://item.taobao.com/item.htm?id=123456',
title: 'Apple iPhone 15 Pro 256GB',
price: 8999,
quantity: 1,
recipientName: '张三',
address: '北京市朝阳区望京SOHO T1 1001',
phone: '13800138000',
remarks: '请在工作日送达'
});
console.log('采购意图 ID:', intent.id);Python
from procure_core import ProcureClient
client = ProcureClient(
app_id='your_app_id',
app_secret='your_app_secret',
base_url='https://api.procure-core.com'
)
intent = client.intents.create(
user_id='user_001',
platform='TAOBAO',
product_url='https://item.taobao.com/item.htm?id=123456',
title='Apple iPhone 15 Pro 256GB',
price=8999,
quantity=1,
recipient_name='张三',
address='北京市朝阳区望京SOHO T1 1001',
phone='13800138000',
remarks='请在工作日送达'
)
print(f'采购意图 ID: {intent.id}')响应参数
| 参数 | 类型 | 说明 |
|---|---|---|
code | number | 状态码,0 表示成功 |
message | string | 响应消息 |
data.id | string | 采购意图 ID,全局唯一 |
data.userId | string | 用户 ID |
data.platform | string | 电商平台 |
data.status | string | 状态:SUBMITTED(已提交) |
data.createdAt | string | 创建时间(ISO 8601 格式) |
data.updatedAt | string | 更新时间(ISO 8601 格式) |
响应示例
成功响应
{
"code": 0,
"message": "操作成功",
"data": {
"id": "intent_67890",
"userId": "user_001",
"platform": "TAOBAO",
"status": "SUBMITTED",
"createdAt": "2026-02-25T10:30:00.000Z",
"updatedAt": "2026-02-25T10:30:00.000Z"
}
}错误响应
参数验证失败:
{
"code": 40001,
"message": "参数验证失败",
"data": {
"errors": [
{
"field": "price",
"message": "价格必须大于 0"
},
{
"field": "phone",
"message": "手机号格式不正确"
}
]
}
}签名验证失败:
{
"code": 40101,
"message": "签名验证失败",
"data": null
}业务流程
创建采购意图后的处理流程:
- SUBMITTED(已提交) - 意图创建成功
- PROCESSING(处理中) - 系统正在处理采购
- COMPLETED(已完成) - 采购完成
- FAILED(失败) - 采购失败
可以通过 查询意图详情 接口查看当前状态。
常见错误
| 错误码 | 错误消息 | 解决方案 |
|---|---|---|
| 40001 | 参数验证失败 | 检查请求参数是否符合要求 |
| 40101 | 签名验证失败 | 检查签名算法和密钥是否正确 |
| 40102 | 时间戳无效 | 确保时间戳在 5 分钟内 |
| 40103 | App ID 不存在 | 检查 App ID 是否正确 |
| 42901 | 请求过于频繁 | 降低请求频率,等待后重试 |
| 50001 | 系统内部错误 | 稍后重试或联系技术支持 |
详细说明请参考 错误码文档。
注意事项
- 商品链接验证 - productUrl 必须是有效的商品链接,系统会爬取验证
- 价格一致性 - 如果实际价格与提交价格差异较大,可能影响采购
- 地址准确性 - 收货地址必须准确,避免配送问题
- 手机号验证 - 系统可能会通过手机号联系收货人
- 速率限制 - 单个 App ID 限制 10 次/秒