curl --request PUT \
--url https://api.brightdata.com/billing/autorecharge/regular \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"enabled": true,
"pmethod_id": "64f0c2a1e4b0a1b2c3d4e5f6",
"amount": 200
}
'{
"available": true,
"enabled": true,
"pmethod_id": "<string>",
"amount": 123,
"threshold": 123,
"limits": {
"min_amount": 123,
"max_amount": 123
}
}{
"error": "Amount should be at least $50",
"error_code": "amount_too_low"
}User authentication is requiredYour API key lacks the required permissions for this action. You can change your token permissions at https://brightdata.com/cp/setting/users<string>账户与状态
设置常规自动充值
使用 Bright Data 账号管理 API 的 PUT /billing/autorecharge/regular 开启或关闭常规自动充值,并设置扣款的支付方式和以美元计的充值金额。
PUT
/
billing
/
autorecharge
/
regular
curl --request PUT \
--url https://api.brightdata.com/billing/autorecharge/regular \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"enabled": true,
"pmethod_id": "64f0c2a1e4b0a1b2c3d4e5f6",
"amount": 200
}
'{
"available": true,
"enabled": true,
"pmethod_id": "<string>",
"amount": 123,
"threshold": 123,
"limits": {
"min_amount": 123,
"max_amount": 123
}
}{
"error": "Amount should be at least $50",
"error_code": "amount_too_low"
}User authentication is requiredYour API key lacks the required permissions for this action. You can change your token permissions at https://brightdata.com/cp/setting/users<string>PUT /billing/autorecharge/regular 端点开启或关闭 Bright Data 账户的常规自动充值,并设置扣款的支付方式和充值金额。数据集自动充值设置不会改变。
将您的 API key 粘贴到授权字段中。要获取 API key,请创建账号,并查看如何生成新的 API key?
此端点需要哪种 API key 权限?
PUT /billing/autorecharge/regular 需要 billing.write.pay.settings 权限。具有管理员或财务权限级别的 API key 拥有该权限。缺少该权限时,端点返回 HTTP 403 和纯文本消息。请在账户设置中管理 API key 权限。
如何开启常规自动充值?
发送enabled: true,并附带 pmethod_id 和 amount:
- 从
GET /billing/pmethods获取autorecharge_supported为true的支付方式 ID。 - 从
GET /billing/autorecharge的regular.limits获取允许的金额范围。 - 发送请求:
curl -X PUT "https://api.brightdata.com/billing/autorecharge/regular" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"enabled": true, "pmethod_id": "64f0c2a1e4b0a1b2c3d4e5f6", "amount": 200}'
threshold。
常规自动充值扣款多少?
当可用余额低于 ceil(amount / 4) 时开始充值。常规自动充值从不将余额补足到某个目标水平。扣款金额取决于当时的余额:
- 余额大于零:扣款金额正好为
amount - 余额为零或负数:扣款金额为
amount× ceil(欠款 /amount),最多为 10 ×amount
amount 设置为 200 时,可用余额低于 $50 时开始充值:
| 可用余额 | 扣款 |
|---|---|
| $30 | $200 |
| -$450 | $600(200 × ceil(450 / 200)) |
| -$5,000 | $2,000(上限为 10 × 200) |
充值金额有哪些规则?
amount 以美元计,必须满足:
- 为整数美元。否则端点返回
amount_not_whole - 不低于
limits.min_amount,所有账户均为 $50。否则端点返回amount_too_low - 不高于
limits.max_amount,该值取决于公司类型,也可以按账户调整。否则端点返回amount_too_high
GET /billing/autorecharge 读取账户的 limits.min_amount 和 limits.max_amount。
如何关闭常规自动充值?
只发送enabled: false,不附带其他字段:
curl -X PUT "https://api.brightdata.com/billing/autorecharge/regular" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"enabled": false}'
available 为 false。关闭常规自动充值不会关闭数据集自动充值。在 enabled: false 时发送 pmethod_id 或 amount 会返回 invalid_param。
PUT 如何更新设置?
请求体包含常规部分的全部设置,请求是幂等的。重复发送相同的请求体,设置保持不变。如只需修改金额,请发送enabled: true,附带当前的 pmethod_id 和新的 amount。
此端点可能返回哪些错误?
HTTP 400 和not_eligible 的 HTTP 403 返回包含 error 和 error_code 的 JSON:
| HTTP 状态码 | error_code | 原因 |
|---|---|---|
| 400 | invalid_param | 类型错误、未知字段、enabled: true 时缺少 pmethod_id 或 amount,或 enabled: false 时发送了这两个字段 |
| 400 | amount_too_low | amount 低于 limits.min_amount |
| 400 | amount_too_high | amount 高于 limits.max_amount |
| 400 | amount_not_whole | amount 不是整数美元 |
| 400 | pmethod_not_found | 账户中没有此 ID 的已激活支付方式 |
| 400 | pmethod_not_supported | 该支付方式不支持自动充值或尚未确认 |
| 400 | payment_required | 账户没有已完成的付款 |
| 403 | not_eligible | 账户不可使用自动充值(available: false),而请求中包含 enabled: true |
相关端点
授权
在 Authorization 头中使用您的 Bright Data API Key 作为 Bearer token。
认证方法:
- 从 Bright Data 账户设置获取您的 API Key: https://brightdata.com/cp/setting/users
- 在请求的 Authorization 头中包含 API Key
- 格式:
Authorization: Bearer YOUR_API_KEY
示例:
Authorization: Bearer b5648e1096c6442f60a6c4bbbe73f8d2234d3d8324554bd6a7ec8f3f251f07df
了解如何获取 Bright Data API Key: https://docs.brightdata.com/cn/api-reference/authentication#如何生成新的-api-key?
请求体
application/json
响应
新的常规自动充值设置
此页面对您有帮助吗?