更新 Smart Batch
更新由已认证客户拥有的现有 SmartBatch 字段。你可以更新 name、status、executor,或替换 rows。当请求中提供 rows 时,服务器会重新计算 totalRows、completedRows、failedRows 和 partialRows,并同步外部行快照。
若要将批次切换为 "paused" 状态,请使用专用的暂停 Smart Batch 接口。仅当批次当前处于 "draft"、"pending" 或 "cancelled" 状态时,修改 executor 才会生效。
接口
PUT https://api.verifik.co/v2/smart-batches/{id}
此接口也可通过 Smart-Agent 代理 https://ai.verifik.co/v2/smart-batches/{id} 访问,需使用你自己的客户专属 Authorization: Bearer <VERIFIK_JWT>。共享 x402 执行会被拒绝并返回 403 Forbidden。
请求头
| 名称 | 值 | 描述 |
|---|---|---|
Content-Type | application/json | 请求载荷格式。 |
Authorization | Bearer <VERIFIK_JWT> | 客户作用域的 JWT(authUser.clientId)。 |
参数
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
id | string | 是 | 要更新的 SmartBatch ObjectId。 |
请求体
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
name | string | 否 | 更新后的批次显示名称。最多 150 个字符。 |
status | string | 否 | 允许的值:"draft"、"pending"、"processing"、"completed"、"failed" 或 "cancelled"。如需设为 "paused",请使用 POST /v2/smart-batches/{id}/pause。 |
executor | string | 否 | 允许的值:"queue"、"featureRunner" 或 "browser"。仅当当前批次状态为 "draft"、"pending" 或 "cancelled" 时生效。 |
rows | object[] | 否 | 用于替换的行列表。包装格式需包含 rowIndex 和 inputData,并可选传入 status、results、errors 和 processedAt;扁平格式行会自动标准化。 |
未知请求体键将被 Joi 校验拒绝,并返回 409 MissingParameter。
请求示例
- Node.js
- PHP
- Python
- Go
- cURL
import axios from "axios";
const run = async () => {
const batchId = "6801a2b3c4d5e6f7a8b9c0d3";
const { data } = await axios.put(
`https://api.verifik.co/v2/smart-batches/${batchId}`,
{
name: "Colombia Onboarding — Updated",
executor: "queue",
rows: [
{
rowIndex: 0,
inputData: {
documentType: "CC",
documentNumber: "1032386359",
},
status: "pending",
},
],
},
{
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${process.env.VERIFIK_JWT}`,
},
}
);
console.log(data);
};
run();
<?php
$batchId = "6801a2b3c4d5e6f7a8b9c0d3";
$payload = [
"name" => "Colombia Onboarding — Updated",
"executor" => "queue",
"rows" => [
[
"rowIndex" => 0,
"inputData" => [
"documentType" => "CC",
"documentNumber" => "1032386359",
],
"status" => "pending",
],
],
];
$ch = curl_init("https://api.verifik.co/v2/smart-batches/" . $batchId);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"Authorization: Bearer " . getenv("VERIFIK_JWT"),
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
import os
import requests
batch_id = "6801a2b3c4d5e6f7a8b9c0d3"
url = f"https://api.verifik.co/v2/smart-batches/{batch_id}"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {os.getenv('VERIFIK_JWT')}",
}
payload = {
"name": "Colombia Onboarding — Updated",
"executor": "queue",
"rows": [
{
"rowIndex": 0,
"inputData": {
"documentType": "CC",
"documentNumber": "1032386359",
},
"status": "pending",
}
],
}
response = requests.put(url, json=payload, headers=headers)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"os"
)
func main() {
batchID := "6801a2b3c4d5e6f7a8b9c0d3"
body, _ := json.Marshal(map[string]interface{}{
"name": "Colombia Onboarding — Updated",
"executor": "queue",
"rows": []map[string]interface{}{
{
"rowIndex": 0,
"inputData": map[string]string{
"documentType": "CC",
"documentNumber": "1032386359",
},
"status": "pending",
},
},
})
req, _ := http.NewRequest("PUT", "https://api.verifik.co/v2/smart-batches/"+batchID, bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+os.Getenv("VERIFIK_JWT"))
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
var out map[string]interface{}
json.NewDecoder(resp.Body).Decode(&out)
fmt.Println(out)
}
curl -X PUT "https://api.verifik.co/v2/smart-batches/6801a2b3c4d5e6f7a8b9c0d3" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $VERIFIK_JWT" \
-d '{
"name": "Colombia Onboarding — Updated",
"executor": "queue",
"rows": [
{
"rowIndex": 0,
"inputData": {
"documentType": "CC",
"documentNumber": "1032386359"
},
"status": "pending"
}
]
}'
响应示例
- 200 OK
- 401
- 403
- 404
- 409
- 422
{
"data": {
"_id": "6801a2b3c4d5e6f7a8b9c0d3",
"batchConfiguration": "6801a2b3c4d5e6f7a8b9c0d4",
"client": "507f1f77bcf86cd799439013",
"name": "Colombia Onboarding — Updated",
"status": "draft",
"executor": "queue",
"source": "smart_batch",
"headlessRun": false,
"creditsSpent": 0,
"rows": [
{
"rowIndex": 0,
"inputData": {
"documentType": "CC",
"documentNumber": "1032386359"
},
"status": "pending",
"results": {},
"errors": []
}
],
"totalRows": 1,
"completedRows": 0,
"failedRows": 0,
"partialRows": 0,
"createdAt": "2026-11-24T19:58:00.000Z",
"updatedAt": "2026-11-24T20:06:00.000Z"
}
}
{
"message": "Unauthorized",
"code": "Unauthorized"
}
{
"message": "Shared x402 execution is forbidden on this endpoint",
"code": "Forbidden"
}
{
"message": "not_found",
"code": "NotFound"
}
{
"message": "\"status\" must be one of [draft, pending, processing, completed, failed, cancelled]",
"code": "MissingParameter"
}
{
"message": "UnprocessableEntity",
"code": "UnprocessableEntity"
}
注意事项
PUT /v2/smart-batches/{id}不接受"paused"状态;请改用暂停 Smart Batch。- 除非批次当前处于
"draft"、"pending"或"cancelled"状态,否则对executor的更新将被忽略。 - 若要在不替换现有行的前提下向现有批次追加新行,请使用向 Smart Batch 追加行。