Buy prepaid credit
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.
AuthorizationBearer <token>A secret, trusted or limited token. See Authentication.
customer_id*stringThe Comecero customer id, or me.
Idempotency-Key?stringMakes a retry harmless: the same request again with the same key (after a timeout, say) changes nothing more and answers as the first one did. 1 to 128 printable ASCII characters, sent once (400, reference UbV150); an empty header counts as none. Use a new random key, such as a UUID, for each change you mean to make. The same key with another body is refused (409, reference UbV151).
^[ -~]{0,128}$length <= 128application/json- body
subscription_id*stringThe customer's subscription whose plan the credit is for (subscription_id of a customer_usage). At most 100 characters.
1 <= length <= 100amount*stringThe credit to buy, as a decimal string above 0 in the plan's currency, no finer than the currency allows ("20", "12.50"). It must be from the larger of the smallest sale and the shop's min to the shop's max, and at most 1000000000, with at most 6 decimal places (zeros after them are fine).
^(?=[^1-9]*[1-9])(?:0*[0-9]{0,9}(?:\.[0-9]{0,6}0*)?|0*1000000000(?:\.0*)?)$A retry: this Idempotency-Key already made an invoice for the same subscription and amount, and this is that invoice as it is now (it may be paid by then). Nothing new is made.
application/json- response
A bill you send to a customer, who pays it from a link. A new invoice is a draft (draft: true): you can change it freely and the customer cannot see it. Publishing it (draft: false) fires invoice:published and, unless you ask otherwise, emails the customer a payment link. When the invoice is paid in full it closes (open: false) and becomes an order with the same id. Money fields are in the invoice currency unless the field name starts with settlement_.
object?"invoice"The object type. Always invoice.
"invoice"url?stringThe full URL of this invoice.
uridate_created?stringWhen the invoice was created.
date-timedate_modified?stringWhen the invoice was last changed.
date-timedate_due?|When payment is due. Required before the invoice can be published.
date-timepast_due?booleanTrue when date_due has passed and the invoice is still unpaid, scheduled, pending, failed or waiting for a retry.
invoice_id?stringThe invoice id. It is also the order_id of the order the invoice becomes when paid.
test?booleanTrue for a test invoice.
account_id?stringThe account the invoice belongs to.
order_id?stringThe id the order will have once the invoice is paid. Same as invoice_id.
open?booleanTrue while the invoice can still be changed or paid. It turns false when the invoice is paid in full.
payment_status?stringWhere payment stands. unpaid: nothing paid yet. scheduled: Comecero will charge the customer's saved payment method automatically (autopay_at). processing or pending: a payment is under way. completed: paid in full. failed or retry: the last automatic payment failed. cancelled and refunded follow the order.
"unpaid""scheduled""processing""pending""completed""failed""retry""cancelled""refunded"currency?stringThe currency the customer pays in, a three-letter ISO 4217 code.
subtotal?numberThe sum of the item subtotals after item discounts.
subtotal_original?numberThe sum of the item subtotals before discounts.
shipping?numberShipping after discounts.
shipping_original?numberShipping before discounts.
discount?numberThe discount on the whole invoice, apart from item discounts.
item_discounts?numberThe sum of all item discounts.
total_discounts?numberdiscount plus item_discounts.
total_discounts_percent?numberThe total discount as a fraction of the original total.
tax?numberTax after discounts.
tax_original?numberTax before discounts.
total?numberThe amount the customer pays.
total_original?numbersubtotal_original plus shipping_original plus tax_original.
tax_inclusive?booleanTrue when item prices already include tax.
total_payments?numberThe amount paid so far.
total_remaining?numbertotal minus total_payments: what is still to pay.
discount_on_gross?booleanTrue when discounts are taken from the tax-inclusive price.
autopay?booleanTrue when the invoice is to be charged automatically to the customer's saved payment method on the due date, once it is published.
for_subscription_proration?booleanTrue when Comecero made this invoice for a mid-term subscription change.
autopay_at?|When the automatic payment will run. Null when the invoice is not scheduled for automatic payment.
date-timesettlement_currency?stringThe currency you are paid out in. This and the other settlement_ fields are not returned to limited tokens.
settlement_subtotal?numbersubtotal in the settlement currency.
settlement_subtotal_original?numbersubtotal_original in the settlement currency.
settlement_shipping?numbershipping in the settlement currency.
settlement_shipping_original?numbershipping_original in the settlement currency.
settlement_discount?numberdiscount in the settlement currency.
settlement_item_discounts?numberitem_discounts in the settlement currency.
settlement_total_discounts?numbertotal_discounts in the settlement currency.
settlement_tax?numbertax in the settlement currency.
settlement_tax_original?numbertax_original in the settlement currency.
settlement_total?numbertotal in the settlement currency.
customer_ip_address?|The customer's IP address, when known.
customer_ip_country?|The country of customer_ip_address, a two-letter ISO 3166 code.
referrer?|Where the sale came from, as you set it.
affiliate_id?|The affiliate credited with the sale, as you set it.
promotion_code?|The coupon code applied to the invoice.
items_count?integerThe number of items.
items_quantity?numberThe sum of the item quantities.
draft?booleanTrue while the invoice is a draft. A draft cannot be paid and limited tokens cannot see it. Once published, an invoice cannot go back to draft.
items?array<>The items on the invoice.
shipping_item?|The shipping line, or null when the invoice has no shipping.
customer?|The customer the invoice is for, or null when none is set yet. Before an invoice is published, the customer must have every field your payment settings require.
order?||Once the invoice is closed and paid, a link to its order, or the order itself when you expand order. Null while the invoice is open. Left out when the token may not read orders.
payments?|A link to the invoice's payments, or the list of payments when you expand payments on a single invoice. Left out when the token may not read payments.
subscription?||For a subscription renewal invoice, a link to the subscription, or the subscription itself when you expand subscription. Null otherwise. Left out when the token may not read subscriptions.
credit_purchase?On an invoice for prepaid credit, one a customer opened (POST /customers/{customer_id}/credit_purchases) or an automatic top-up's: what it buys. The credit is added once the invoice is paid. Such an invoice is never changed (422, UbV152; 409, UbV165 for a top-up's). Left out on other invoices.
subscription_date_period_start?|For a renewal invoice, the start of the billing period it covers. Left out when the token may not read subscriptions.
date-timesubscription_date_period_end?|For a renewal invoice, the end of the billing period it covers. Left out when the token may not read subscriptions.
date-timepromotions?|A link to the promotions applied to the invoice, or the list when you expand promotions on a single invoice.
options?|A link to the payment options for the invoice, or the options themselves when you expand options on a single invoice.
meta?|Your own data for this invoice, up to 2,048 characters as JSON.
formatted?Only when you send formatted=true. The money and date fields above as display text in the customer's language.
curl -X POST 'https://api.comecero.com/api/v1/customers/string/credit_purchases' \ -H 'Idempotency-Key: 3f2b6c1e-9d4a-4e8b-a1f7-5c0d2e9b8a64' \ -H 'Content-Type: application/json' \ -d '{ "subscription_id": "SB0123456789", "amount": "25"}'{ "object": "invoice", "url": "https://api.comecero.com/api/v1/invoices/4827-KTPMW-640", "invoice_id": "4827-KTPMW-640", "date_created": "2026-11-15T12:00:00Z", "date_modified": "2026-11-15T12:00:00Z", "currency": "USD", "subtotal": 25, "total": 25, "total_remaining": 25, "open": true, "draft": false, "items": [ { "object": "invoice_item", "item_id": "1", "invoice_id": "4827-KTPMW-640", "name": "Prepaid credit", "quantity": 1, "currency": "USD", "price": 25, "total": 25, "meta": { "credit_granted": "25" } } ], "subscription": null, "credit_purchase": { "subscription_id": "SB0123456789", "amount": "25", "credit_granted": "25", "source": "manual" }}List a customer's automatic top-ups GET
One subscription's top-ups, newest first, a page at a time: what each charged, how it went, and its invoice. No gateway answers or vault ids. A shopper's token reads only its own customer (`me` works).
Send usage events POST
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](/docs/usage-billing/send-usage).