BuffMoneyBuffMoney
Reference

API reference.

Every endpoint, every parameter, every response code. Generated from the OpenAPI 3.1 spec served at /api/openapi.

Version: 1.0.0-alpha

Base URL

https://www.buffmoney.com

Authentication

All endpoints require a Bearer token. Create an API key at /merchant/developer; place the token in the Authorization header:

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

env is sandbox or live. Sandbox keys work right after signup; live keys unlock after KYB approval.

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.

Parameters

FieldinTypeNotes
Idempotency-Key optionalheaderstringOptional. Caches the full HTTP response for 24h so duplicate requests with the same body produce the same response.

Request body

required application/json

See schema: UsageEventBatch

Responses

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

Parameters

FieldinTypeNotes
invoiceId requiredpathstring

Request body

optional application/json

(inline)

object
FieldTypeNotes
channel optional"wechat" | "alipay"

Responses

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

Object schemas

UsageEventInput

object
FieldTypeNotes
customerExternalId requiredstringThe merchant's own customer identifier.
idempotencyKey requiredstringPer-event idempotency key, unique within the merchant.
metric required"tokens_input" | "tokens_output" | "image_generation" | "agent_run" | "storage_gb"
quantity requiredstringNon-negative integer encoded as a decimal string.
occurredAt requiredstring (date-time)
dimensions optionalobject

UsageEventBatch

object
FieldTypeNotes
events requiredarray<UsageEventInput>

UsageEventResult

object
FieldTypeNotes
idempotencyKey optionalstring
status optional"accepted" | "duplicate" | "rejected"
eventId optionalstring
reason optionalstring

Invoice

object
FieldTypeNotes
_id optionalstring
invoiceNumber optionalstring
status optional"draft" | "finalized" | "payment_pending" | "paid" | "void" | "refunded"
pricingCurrency optionalstring
collectionCurrency optionalstring
settlementCurrency optionalstring
subtotalMinor optionalstring
collectionAmountMinor optionalstring
platformFeeMinor optionalstring
netSettlementMinor optionalstring
periodStart optionalstring (date-time)
periodEnd optionalstring (date-time)

CheckoutResponse

object
FieldTypeNotes
paymentOrderId optionalstring
channel optional"wechat" | "alipay"
status optionalstring
amountMinor optionalstring
currency optionalstring
expiresAt optionalstring (date-time)
checkout optionalobject

Error

object
FieldTypeNotes
ok optionalboolean
error optionalstring
message optionalstring