Skip to Content
CamBillDocs

API reference

Every endpoint, generated from openapi.yaml.

Base URL https://cambill.cubis.tech. Send your key in X-API-Key. The machine-readable description is openapi.yaml. Amounts are integers in the minor unit. Errors are problem+json.

Payment intents

Create a payment intent

POST /v1/payment-intents

Idempotent on external_id. When the Bakong connector is on, the response carries a validated qr_string.

FieldTypeRequired
amountintegeryesMinor units
currencyUSD | KHRyes
external_idstring
customer_idstring
descriptionstring
metadatastring
expires_inintegerMinutes
success_urlstringWhere the payer returns after paying, on the hosted checkout and in the widget. https only, without credentials or a #fragment, and its origin must be listed in Checkout settings (return origins or embed origins), or the request fails with 400. The payer arrives with only ?payment_intent=<id> added: read the status from the API or the webhook before fulfilling.
cancel_urlstringWhere the payer returns on cancel or expiry. Same rules as success_url.

Returns 201 created. Errors: 400, 401, 409, 429.

Retrieve a payment intent

GET /v1/payment-intents/{id}

ParameterInType
idpathstring

Returns 200 ok. Errors: 404.

Retrieve only a payment intent's status

GET /v1/payment-intents/{id}/status

The cheapest read, for polling. It has its own, larger rate budget and does not sync with the bank.

ParameterInType
idpathstring

Returns 200 ok. Errors: 404.

Invoices

Create a draft invoice

POST /v1/invoices

Idempotent on external_id.

FieldTypeRequired
external_idstring
customerstringA saved customer's id. Their name, email and phone are copied onto the invoice.
customer_external_idstringOr your own id for a saved customer.
customer_namestring
customer_emailstring
customer_phonestring
customer_tax_idstringCopied from the saved customer when you send customer.
currencyUSD | KHRyes
linesobject[]yes
memostring
due_in_daysinteger
couponstringA coupon id or code. It must qualify now and is used up when the invoice is issued (the rules are checked again then). An unknown id or code answers 400.
metadataobjectUp to 20 keys (a-z 0-9 _ . -, 40 characters); values are plain text up to 500 characters.

Returns 201 created. Errors: 400, 403, 409.

Retrieve an invoice

GET /v1/invoices/{inv}

ParameterInType
invpathstring
expandquerycustomerInclude the saved customer

Returns 200 ok. Errors: 404.

Replace a draft

PUT /v1/invoices/{inv}

ParameterInType
invpathstring
FieldTypeRequired
external_idstring
customerstringA saved customer's id. Their name, email and phone are copied onto the invoice.
customer_external_idstringOr your own id for a saved customer.
customer_namestring
customer_emailstring
customer_phonestring
customer_tax_idstringCopied from the saved customer when you send customer.
currencyUSD | KHRyes
linesobject[]yes
memostring
due_in_daysinteger
couponstringA coupon id or code. It must qualify now and is used up when the invoice is issued (the rules are checked again then). An unknown id or code answers 400.
metadataobjectUp to 20 keys (a-z 0-9 _ . -, 40 characters); values are plain text up to 500 characters.

Returns 200 ok. Errors: 409.

Delete a draft

DELETE /v1/invoices/{inv}

An issued invoice is voided, never deleted.

ParameterInType
invpathstring

Returns 204 deleted. Errors: 409.

Issue an invoice

POST /v1/invoices/{inv}/finalize

Gives it a number and a link. Repeating it changes nothing. In live mode the business must be verified.

ParameterInType
invpathstring

Returns 200 ok. Errors: 403, 422, 429.

Void an invoice

POST /v1/invoices/{inv}/void

ParameterInType
invpathstring

Returns 200 ok. Errors: 409.

Copy an invoice into a new draft

POST /v1/invoices/{inv}/duplicate

ParameterInType
invpathstring

Returns 201 created.

An invoice's activity

GET /v1/invoices/{inv}/events

ParameterInType
invpathstring
pagequeryinteger
limitqueryinteger

Returns 200 ok.

The invoice as its page shows it

GET /v1/invoices/{inv}/document

ParameterInType
invpathstring

Returns 200 ok.

Customers

Create a customer

POST /v1/customers

external_id is your own id for them (a user or CRM id). It must be unique; a second create with it is 409.

FieldTypeRequired
external_idstringYour own id; letters, digits and _ . : @ -
namestring
emailstring
phonestringDigits, optionally starting with +, 6 to 15 long
tax_idstringTheir tax registration number (VAT TIN), printed on their invoices.
metadataobjectUp to 20 keys (a-z 0-9 _ . -, 40 characters); values are plain text up to 500 characters.

Returns 201 created. Errors: 400, 403, 409.

List customers

GET /v1/customers

ParameterInType
pagequeryinteger
limitqueryinteger
external_idquerystringExact match on your own id
emailquerystringExact match
qquerystringPrefix search on id, external id, name, email and phone

Returns 200 ok.

Retrieve a customer

GET /v1/customers/{cus}

ParameterInType
cuspathstring

Returns 200 ok. Errors: 404.

Replace a customer's details

PUT /v1/customers/{cus}

ParameterInType
cuspathstring
FieldTypeRequired
external_idstringYour own id; letters, digits and _ . : @ -
namestring
emailstring
phonestringDigits, optionally starting with +, 6 to 15 long
tax_idstringTheir tax registration number (VAT TIN), printed on their invoices.
metadataobjectUp to 20 keys (a-z 0-9 _ . -, 40 characters); values are plain text up to 500 characters.

Returns 200 ok. Errors: 404, 409.

Erase a customer

DELETE /v1/customers/{cus}

Erases their personal data (name, email, phone, metadata, external id). The id stays, so invoices that name it still read. An issued invoice keeps its own copy of the name, because an invoice is a financial record.

ParameterInType
cuspathstring

Returns 204 erased. Errors: 404.

Products

Create a product

POST /v1/products

FieldTypeRequired
namestringyes
descriptionstring
external_idstring
activebooleanArchive a product with false.
metadataobjectUp to 20 keys (a-z 0-9 _ . -, 40 characters); values are plain text up to 500 characters.

Returns 201 created. Errors: 400, 403.

List products

GET /v1/products

ParameterInType
pagequeryinteger
limitqueryinteger
qquerystringPrefix search
activequeryboolean

Returns 200 ok.

Retrieve a product

GET /v1/products/{prod}

ParameterInType
prodpathstring

Returns 200 ok. Errors: 404.

Update a product

PUT /v1/products/{prod}

ParameterInType
prodpathstring
FieldTypeRequired
namestringyes
descriptionstring
external_idstring
activebooleanArchive a product with false.
metadataobjectUp to 20 keys (a-z 0-9 _ . -, 40 characters); values are plain text up to 500 characters.

Returns 200 ok. Errors: 400, 404.

Prices

Create a price

POST /v1/prices

A price's amount never changes. To charge a different amount, create a new price and archive the old one.

FieldTypeRequired
productstringyes
currencyUSD | KHRyes
unit_amountintegeryesMinor units
typeone_time | recurring
intervalday | week | month | yearRequired for recurring
interval_countinteger
nicknamestring
metadataobjectUp to 20 keys (a-z 0-9 _ . -, 40 characters); values are plain text up to 500 characters.

Returns 201 created. Errors: 400, 403.

List prices

GET /v1/prices

ParameterInType
pagequeryinteger
limitqueryinteger
qquerystringPrefix search
activequeryboolean
productquerystring
typequeryone_time | recurring

Returns 200 ok.

Retrieve a price

GET /v1/prices/{price}

ParameterInType
pricepathstring

Returns 200 ok. Errors: 404.

Update a price

PUT /v1/prices/{price}

ParameterInType
pricepathstring
FieldTypeRequired
activeboolean
nicknamestring
metadataobjectUp to 20 keys (a-z 0-9 _ . -, 40 characters); values are plain text up to 500 characters.

Returns 200 ok. Errors: 400, 404.

Coupons

Create a coupon

POST /v1/coupons

FieldTypeRequired
namestringyes
codestringWhat a customer or you type to use it. Stored in capitals, unique. A coupon can also be named by its id.
percent_bpsinteger1000 = 10%
amount_offintegerMinor units
currencyUSD | KHR
durationonce | forever | repeating
duration_monthsinteger
max_redemptionsinteger0 means no limit
redeem_bystring
min_subtotalintegerMinor units; needs currency. The invoice must reach it before discount.
productsstring[]Only lines for these products are discounted. Leave out for all lines.
max_per_customerinteger0 means no limit. Needs a saved customer on the invoice.
first_time_onlybooleanOnly for a customer with no issued invoice yet. Needs a saved customer.
starts_atstring

Returns 201 created. Errors: 400, 403.

List coupons

GET /v1/coupons

ParameterInType
pagequeryinteger
limitqueryinteger
qquerystringPrefix search
activequeryboolean

Returns 200 ok.

Retrieve a coupon

GET /v1/coupons/{cpn}

ParameterInType
cpnpathstring

Returns 200 ok. Errors: 404.

Update a coupon

PUT /v1/coupons/{cpn}

ParameterInType
cpnpathstring
FieldTypeRequired
namestring
activeboolean
max_redemptionsinteger0 for no limit. Cannot go below the times it was used.
redeem_bystringMust be in the future.
clear_redeem_bybooleanRemove the redeem_by date.
codestring
min_subtotalinteger
productsstring[]
max_per_customerinteger
first_time_onlyboolean
starts_atstring
clear_starts_atboolean

Returns 200 ok. Errors: 400, 404.

List a coupon's redemptions

GET /v1/coupons/{cpn}/redemptions

The issued invoices that used the coupon, newest first.

ParameterInType
cpnpathstring
pagequeryinteger
limitqueryinteger

Returns 200 ok. Errors: 404.

Tax rates

Create a taxrate

POST /v1/tax_rates

A rate's percentage and whether it is inclusive never change. Create a new rate and archive the old one.

FieldTypeRequired
namestringyes
percent_bpsintegeryes1000 = 10%
inclusivebooleanThe price already includes this tax
is_defaultbooleanApplied to lines that name no tax

Returns 201 created. Errors: 400, 403.

List taxrates

GET /v1/tax_rates

ParameterInType
pagequeryinteger
limitqueryinteger
qquerystringPrefix search
activequeryboolean

Returns 200 ok.

Retrieve a taxrate

GET /v1/tax_rates/{txr}

ParameterInType
txrpathstring

Returns 200 ok. Errors: 404.

Update a taxrate

PUT /v1/tax_rates/{txr}

ParameterInType
txrpathstring
FieldTypeRequired
namestring
percent_bpsintegerTwo decimals: 1000 is 10%.
inclusiveboolean
activeboolean
is_defaultboolean

Returns 200 ok. Errors: 400, 404.

Delete a tax rate

DELETE /v1/tax_rates/{txr}

Only a rate no invoice was charged with. A rate that was used answers 409; archive it instead.

ParameterInType
txrpathstring

Returns 204 deleted. Errors: 404, 409.

Subscriptions

Subscribe a customer to recurring prices

POST /v1/subscriptions

Bills the customer by invoice each period, in advance. The first invoice is created now; each is issued automatically unless auto_issue is false. Nothing is charged: the customer pays each invoice from its link. All items must share one currency and billing interval.

FieldTypeRequired
customerstring
customer_external_idstring
itemsobject[]
days_until_dueinteger
auto_issuebooleanIssue each invoice as it is created
cancel_at_period_endboolean
couponstringA coupon id or code, on create. It discounts the periods its duration covers (once, N months, forever) and is used up once, by the first invoice.
metadataobjectUp to 20 keys (a-z 0-9 _ . -, 40 characters); values are plain text up to 500 characters.

Returns 201 created. Errors: 400, 403.

List subscriptions

GET /v1/subscriptions

Filters combine (all must match). An id or external id that matches nothing gives an empty list, not an error.

ParameterInType
pagequeryinteger
limitqueryinteger
customerquerystringA customer's CamBill id.
customer_external_idquerystringYour own id for the customer.
productquerystringA product's CamBill id: subscriptions with an item for any of its prices.
product_external_idquerystringYour own id for the product. The usual way for another system to pull its subscriptions.
pricequerystring
couponquerystringA coupon id or code
statusqueryactive | paused | canceled
expandquerycustomer | items | customer,itemscustomer and/or items: the same full object webhooks carry (customer_details, and items with their price and product).

Returns 200 ok.

Retrieve a subscription

GET /v1/subscriptions/{sub}

ParameterInType
subpathstring
expandquerycustomer | items | customer,itemscustomer and/or items: the same full object webhooks carry (customer_details, and items with their price and product).

Returns 200 ok. Errors: 404.

Change what happens from the next period

PUT /v1/subscriptions/{sub}

ParameterInType
subpathstring
FieldTypeRequired
customerstring
customer_external_idstring
itemsobject[]
days_until_dueinteger
auto_issuebooleanIssue each invoice as it is created
cancel_at_period_endboolean
couponstringA coupon id or code, on create. It discounts the periods its duration covers (once, N months, forever) and is used up once, by the first invoice.
metadataobjectUp to 20 keys (a-z 0-9 _ . -, 40 characters); values are plain text up to 500 characters.

Returns 200 ok. Errors: 409.

Pause billing

POST /v1/subscriptions/{sub}/pause

ParameterInType
subpathstring

Returns 200 ok. Errors: 409.

Resume billing from now

POST /v1/subscriptions/{sub}/resume

Periods missed while paused are not billed. The first invoice is created now.

ParameterInType
subpathstring

Returns 200 ok. Errors: 409.

Cancel now, or at the end of the period

POST /v1/subscriptions/{sub}/cancel

ParameterInType
subpathstring
FieldTypeRequired
at_period_endboolean

Returns 200 ok. Errors: 409.

Bill the next period now (test mode only)

POST /v1/subscriptions/{sub}/advance

Lets you test your integration without waiting a month. Answers 403 with a live key.

ParameterInType
subpathstring

Returns 200 ok. Errors: 403, 409.

Objects

Product

FieldTypeRequired
idstring
objectstring
modetest | live
namestring
descriptionstring
external_idstring
activeboolean
pricesobject[]The active prices. Only in the product list.
metadataobjectUp to 20 keys (a-z 0-9 _ . -, 40 characters); values are plain text up to 500 characters.
created_atstring
updated_atstring

Price

FieldTypeRequired
idstring
objectstring
modetest | live
productstring
currencystring
unit_amountinteger
typeone_time | recurring
recurringobject or null
nicknamestring
activeboolean
metadataobjectUp to 20 keys (a-z 0-9 _ . -, 40 characters); values are plain text up to 500 characters.
created_atstring

Coupon

FieldTypeRequired
idstring
objectstring
modetest | live
namestring
percent_bpsinteger
amount_offinteger
currencystring
durationstring
duration_monthsinteger
max_redemptionsinteger
times_redeemedinteger
activeboolean
redeem_bystring or null
starts_atstring or null
codestring
min_subtotalinteger
productsstring[]
max_per_customerinteger
first_time_onlyboolean
created_atstring

TaxRate

FieldTypeRequired
idstring
objectstring
modetest | live
namestring
percent_bpsinteger
inclusiveboolean
activeboolean
is_defaultboolean
created_atstring

Subscription

FieldTypeRequired
idstring
objectstring
modetest | live
customerstring
couponobject or null
statusactive | paused | canceled
itemsobject[]With expand, and in webhooks, each item also carries its price details and product.
currencystring
intervalstring
interval_countinteger
current_period_startstring or null
current_period_endstring or null
next_invoice_atstring or null
days_until_dueinteger
auto_issueboolean
cancel_at_period_endboolean
latest_invoiceobject or null
customer_detailsobjectWith expand, and in webhooks.
previous_attributesobjectIn subscription.* change events: the old values of what changed.
past_duebooleanThe latest invoice is open and past its due date
last_errorstringWhy the last invoice could not be issued
metadataobjectUp to 20 keys (a-z 0-9 _ . -, 40 characters); values are plain text up to 500 characters.
created_atstring
canceled_atstring or null

Customer

FieldTypeRequired
idstring
objectstring
modetest | live
external_idstring
namestring
emailstring
phonestring
tax_idstring
metadataobjectUp to 20 keys (a-z 0-9 _ . -, 40 characters); values are plain text up to 500 characters.
created_atstring
updated_atstring

PaymentIntent

FieldTypeRequired
idstring
objectstring
modetest | live
amountinteger
currencystring
statusrequires_payment_method | succeeded | expired
external_idstring
customer_idstring
descriptionstring
metadatastringThe free text you sent on create
bank_providerstringThe method that settled it; empty until paid
bank_tx_idstringThe bank's reference; empty until paid
receipt_nostringSet when it settles, e.g. RC-20261120-D2KWSH3Q
success_urlstringAs sent on create; omitted when unset
cancel_urlstringAs sent on create; omitted when unset
client_secretstring
payment_linkstring
qr_stringstringA validated Bakong KHQR
qr_methodstring
qr_expires_atstring
created_atstring
expires_atstring
settled_atstring or null

Invoice

FieldTypeRequired
idstring
objectstring
modetest | live
numberstringINV-000123, given when issued
statusdraft | open | paid | void
currencystring
subtotalintegerSum of the lines before discount and tax
discount_totalinteger
tax_totalintegerAll tax
totalintegersubtotal - discount_total + exclusive tax
tax_breakdownobject[]
couponobject or null
tax_idstringThe business's tax registration number
subscriptionstringThe subscription this invoice bills
period_startstring or nullStart of the billed period
period_endstring or nullEnd of the billed period (the next period starts here)
linesobject[]
memostring
metadataobjectUp to 20 keys (a-z 0-9 _ . -, 40 characters); values are plain text up to 500 characters.
customer_idstring
customerobject or nullOnly with ?expand=customer.
customer_namestring
customer_emailstring
customer_phonestring
customer_tax_idstring
external_idstring
hosted_invoice_urlstringThe payer's page; present once issued
payment_intent_idstring
suspendedboolean
reportsinteger
created_atstring
due_atstring or null
finalized_atstring or null
paid_atstring or null

ActivityEvent

FieldTypeRequired
idstring
sourceinvoice | payment
typestring
actor_typestring
detailsobject
created_atstring

On this page