BuffMoneyBuffMoney
参考

API 参考。

每个 endpoint、每个参数、每个响应码。从 /api/openapi 提供的 OpenAPI 3.1 spec 自动渲染。

版本: 1.0.0-alpha

基础 URL

https://www.buffmoney.com

认证

所有 endpoint 都需要 Bearer token 认证。在 /merchant/developer 创建 API key 后,token 格式如下,放进 Authorization 头:

Authorization: Bearer bm_<env>_<keyId>.<secret>

envsandboxlive。沙箱 key 注册后立即可用;生产 key 需 KYB 审核通过。

Endpoints

POST/api/v1/usage-events

Ingest usage events

Batch up to 500 usage events at a time. Events are deduped by `(merchantId, idempotencyKey)`. The optional `Idempotency-Key` request header (different from per-event idempotency) caches the whole-response for 24h so retries replay safely.

参数

字段位于类型说明
Idempotency-Key 可选headerstringOptional. Caches the full HTTP response for 24h so duplicate requests with the same body produce the same response.

请求体

必填 application/json

See schema: UsageEventBatch

响应

StatusDescriptionBody
200Batch processed (mixed accept / duplicate / reject possible).
401Missing or invalid API key.Error
403Scope or merchant status check failed.Error
409Idempotency replay with a different body.Error
413Batch exceeds 500 events.Error
422Validation failure or all events rejected.Error
POST/api/v1/invoices/{invoiceId}/checkout

Create or reuse a payment order for an invoice

参数

字段位于类型说明
invoiceId 必填pathstring

请求体

可选 application/json

(inline)

object
字段类型说明
channel 可选"wechat" | "alipay"

响应

StatusDescriptionBody
200Payment order created or reused.CheckoutResponse
401Authentication failure.Error
403Invoice belongs to a different merchant.Error
404Invoice not found.Error
409Invoice already paid / void / refunded.Error
501Channel not yet supported.Error

对象 Schema

UsageEventInput

object
字段类型说明
customerExternalId 必填stringThe merchant's own customer identifier.
idempotencyKey 必填stringPer-event idempotency key, unique within the merchant.
metric 必填"tokens_input" | "tokens_output" | "image_generation" | "agent_run" | "storage_gb"
quantity 必填stringNon-negative integer encoded as a decimal string.
occurredAt 必填string (date-time)
dimensions 可选object

UsageEventBatch

object
字段类型说明
events 必填array<UsageEventInput>

UsageEventResult

object
字段类型说明
idempotencyKey 可选string
status 可选"accepted" | "duplicate" | "rejected"
eventId 可选string
reason 可选string

Invoice

object
字段类型说明
_id 可选string
invoiceNumber 可选string
status 可选"draft" | "finalized" | "payment_pending" | "paid" | "void" | "refunded"
pricingCurrency 可选string
collectionCurrency 可选string
settlementCurrency 可选string
subtotalMinor 可选string
collectionAmountMinor 可选string
platformFeeMinor 可选string
netSettlementMinor 可选string
periodStart 可选string (date-time)
periodEnd 可选string (date-time)

CheckoutResponse

object
字段类型说明
paymentOrderId 可选string
channel 可选"wechat" | "alipay"
status 可选string
amountMinor 可选string
currency 可选string
expiresAt 可选string (date-time)
checkout 可选object

Error

object
字段类型说明
ok 可选boolean
error 可选string
message 可选string