创建成本中心
接口
POST https://api.verifik.co/v2/cost-centers
在账户上创建一个成本中心。管理成本中心不消耗积分。
请求头
| 名称 | 值 |
|---|---|
| Content-Type | application/json |
| Authorization | Bearer <token> |
请求体参数
name
类型: string
必填: 是
显示名称,最多 120 个字符。
code
类型: string
必填: 是
将在 x-cost-center 中发送的值。字母、数字、.、- 和 _,最多 60 个字符。每个账户唯一。
country
类型: string
必填: 是
ISO-2 国家代码,例如 ES。
active
类型: boolean
必填: 否
默认为 true。
请求示例
- cURL
- Node.js
- Python
curl -X POST "https://api.verifik.co/v2/cost-centers" \
-H "Authorization: Bearer $VERIFIK_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name":"西班牙运营","code":"SPAIN-OPS","country":"ES"}'
const axios = require("axios");
const config = {
method: "post",
url: "https://api.verifik.co/v2/cost-centers",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_ACCESS_TOKEN"
},
data: {
name: "西班牙运营",
code: "SPAIN-OPS",
country: "ES"
}
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
import os
import requests
response = requests.post(
"https://api.verifik.co/v2/cost-centers",
headers={
"Authorization": f"Bearer {os.environ['VERIFIK_TOKEN']}",
"Content-Type": "application/json",
},
json={"name": "西班牙运营", "code": "SPAIN-OPS", "country": "ES"},
)
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-14T17:37:30.469Z"
}
}
data 是新的成本中心对象。
错误响应
账户上已存在的代码:
{
"message": "cost_center_code_taken",
"code": "Conflict"
}
缺少或无效的字段,例如 name、code 或 country:
{
"message": "\"name\" is required",
"code": "MissingParameter"
}