更新成本中心
接口
PUT https://api.verifik.co/v2/cost-centers/{id}
更新一个成本中心。只发送要更改的字段。已经记录的请求仍保留当时的成本中心。
请求头
| 名称 | 值 |
|---|---|
| Content-Type | application/json |
| Authorization | Bearer <token> |
路径参数
id
类型: string
必填: 是
成本中心 id。
请求体参数
name
类型: string
必填: 否
显示名称,最多 120 个字符。
code
类型: string
必填: 否
新的请求头值。字母、数字、.、- 和 _,最多 60 个字符。每个账户唯一。
country
类型: string
必填: 否
ISO-2 国家代码。
active
类型: boolean
必填: 否
true 重新启用,false 则不再分配给新请求。
请求示例
- cURL
- Node.js
- Python
curl -X PUT "https://api.verifik.co/v2/cost-centers/6acfbdda92451bac5d0a7ebe" \
-H "Authorization: Bearer $VERIFIK_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name":"西班牙运营","active":true}'
const axios = require("axios");
const config = {
method: "put",
url: "https://api.verifik.co/v2/cost-centers/6acfbdda92451bac5d0a7ebe",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_ACCESS_TOKEN"
},
data: {
name: "西班牙运营",
active: true
}
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
import os
import requests
response = requests.put(
"https://api.verifik.co/v2/cost-centers/6acfbdda92451bac5d0a7ebe",
headers={
"Authorization": f"Bearer {os.environ['VERIFIK_TOKEN']}",
"Content-Type": "application/json",
},
json={"name": "西班牙运营", "active": True},
)
print(response.json())
响应示例
- 200 OK
{
"data": {
"_id": "6acfbdda92451bac5d0a7ebe",
"client": "69c2b824295cd7d276e478ad",
"name": "西班牙运营",
"code": "SPAIN-OPS",
"country": "ES",
"active": true,
"createdAt": "2026-10-14T17:37:30.469Z",
"updatedAt": "2026-10-14T18:02:11.120Z"
}
}
data 是更新后的成本中心对象。
错误响应
未知 id:
{
"message": "cost_center_not_found",
"code": "NotFound"
}
账户上另一个中心已经使用的 code:
{
"message": "cost_center_code_taken",
"code": "Conflict"
}