Send usage events
Sends a batch of 1 to 1,000 usage events from your server. Use a usage key, not a Comecero API token. The key sets the account and test or live mode. The whole JSON body is at most 1 MiB. Read every result: HTTP 200 can include rejected or conflicting events. Resend only retry results, or safely resend the same batch with the same operation ids. Billing uses the counted events; an event does not itself charge a customer. This route sends no CORS headers. See Send usage.
usageKeyAuthorizationBearer <token>A merchant usage key (apk_test_ or apk_live_), never a Comecero API token.
application/json- body
events*array<>1 <= items <= 1000Every event has a final answer (counted, duplicate, conflict or rejected).
application/json- response
counted?integerduplicate?integerconflict?integerrejected?integerretry?integerresults?array<>curl -X POST 'https://usage.comecero.com/v1/events' \ -H 'Content-Type: application/json' \ -d '{ "events": [ { "operation_id": "request_5501", "external_customer_id": "cust_8412", "metric_key": "ai_tokens", "quantity": "1250", "properties": { "model": "small" } } ]}'{ "counted": 1, "duplicate": 0, "conflict": 0, "rejected": 0, "retry": 0, "results": [ { "index": 0, "operation_id": "request_5501", "status": "counted" } ]}Buy prepaid credit POST
Makes an open invoice with one "Prepaid credit" line of `amount`, in the plan's currency, for the customer to pay through the normal invoice payment page. Once it is paid the credit is added to the subscription's usage plan, once whatever repeats. The credit is the line's price before tax, at most `amount`: where prices include tax, it is less than the total paid. The invoice says how much in `credit_purchase.credit_granted` (and in its line's `meta`). The first purchase makes the plan's credit and pays its meters from it. A refund or chargeback of the invoice takes back its share of the credit, as far as it is unused. Your shop must sell credit (`usage_customer_settings` on `/settings/subscription`). A shopper's token buys only for its own customer (`me` works, and needs a customer's login). Here `customer_id` is the Comecero customer id, not your own id. Send an `Idempotency-Key` header so a retry after a timeout never makes a second invoice: the same key with the same body answers the first invoice (`200`) for a day. A plan may have at most 20 unpaid credit invoices at once.
Overview
Next Page