Skip to main content

kobana billing credits

Commands of kobana billing credits. Every global option (Global options) applies here.

CommandHTTPDescription
credits listGET /v1/creditsList credits
credits createPOST /v1/creditsAdd credit
credits updatePUT /v1/creditsUpsert credit
credits getGET /v1/credits/{id}Get credit
credits deleteDELETE /v1/credits/{id}Delete credit

credits list​

List credits

kobana billing credits list [OPTIONS]

GET /v1/credits

Returns a paginated list of credits in the current organization. By default, expired credits are omitted — use usage or include_expired to include them.

Query parameters

NameTypeRequiredDescription
pageintegernoPage (starts at 1). Default: 1.
per_pageintegernoItems per page. Default: 20. Maximum: 100.
sort_bystringnoSort field. Default depends on the resource.
sort_orderstringnoSort direction. Default: desc. Values: asc, desc.
person_idstringnoFilter by associated person UUID.
person_document_numberstringnoFilter by person CPF/CNPJ (exact match).
person_name_containsstringnoFilter by person name (partial search, case-insensitive).
billing_account_idstringnoFilter credits by billing account.
company_idstringnoFilter credits by the linked company.
typestringnoFilter by credit type: promotional, adjustment, refund or manual. Values: promotional, adjustment, refund, manual.
usagestringnoFilter by usage state — available (remaining balance and not expired), used (fully consumed) or expired (past expiration). Values: available, used, expired.
include_expiredstringnoIncludes expired credits when true. Ignored when usage is set. Values: true, false.
created_afterstringnoStart of creation date range (YYYY-MM-DD).
created_beforestringnoEnd of creation date range (YYYY-MM-DD).
amount_minnumber,nullnoMinimum credit amount in BRL (inclusive).
amount_maxnumber,nullnoMaximum credit amount in BRL (inclusive).
amount_remaining_minnumber,nullnoMinimum remaining balance in BRL (inclusive).
amount_remaining_maxnumber,nullnoMaximum remaining balance in BRL (inclusive).
expires_afterstringnoLower bound for expires_at (YYYY-MM-DD, inclusive).
expires_beforestringnoUpper bound for expires_at (YYYY-MM-DD, inclusive).

Responses

HTTPDescription
200Paginated list of credits.
404Resource not found in the current organization.

credits create​

Add credit

kobana billing credits create [OPTIONS]

POST /v1/credits

Adds a credit to a billing account. The amount is credited to the BillingAccount balance and becomes available to settle future invoices. When company_id is provided, the credit can only be applied to invoices from the same company.

Request body

NameTypeRequiredDescription
billing_account_idstring (uuid)yesUUID of the billing account that will receive the credit.
typestringyesCredit type: promotional, adjustment, refund or manual. Values: promotional, adjustment, refund, manual.
amountnumberyesCredit amount in BRL (float, up to 4 decimal places). Must be a positive integer.
external_idstringnoIdentifier in your external system, for idempotency/sync.
company_idstring (uuid)noOptional UUID of the company the credit is tied to. When set, restricts credit application to invoices from the same company.
descriptionstringnoFree-form description (up to 500 characters) — shown in the statement and audit log.
expires_atstring (date-time)noExpiration date and time (ISO8601). After this date the remaining balance is discarded.
custom_metadataobjectnoCustom metadata validated against the organization schema.

More fields and nested objects: kobana schema billing.credits.create.

Responses

HTTPDescription
201Credit created.
400Request body failed validation.
404Resource not found in the current organization.
422Request body failed validation.

credits update​

Upsert credit

kobana billing credits update [OPTIONS]

PUT /v1/credits

Takes the same body as POST, plus id and public_id, and dedups on id, public_id, external_id and the resource's natural keys, in that order, stopping at the first key that finds a record. A match is updated and returns 200; otherwise the record is created and returns 201. The POST's required fields are required only when no record is found, and updates are partial: absent fields keep their stored value.

Request body

NameTypeRequiredDescription
billing_account_idstring (uuid)noUUID of the billing account that will receive the credit.
external_idstringnoIdentifier in your external system, for idempotency/sync.
company_idstring (uuid)noOptional UUID of the company the credit is tied to. When set, restricts credit application to invoices from the same company.
typestringnoCredit type: promotional, adjustment, refund or manual. Values: promotional, adjustment, refund, manual.
amountnumbernoCredit amount in BRL (float, up to 4 decimal places). Must be a positive integer.
descriptionstringnoFree-form description (up to 500 characters) — shown in the statement and audit log.
expires_atstring (date-time)noExpiration date and time (ISO8601). After this date the remaining balance is discarded.
custom_metadataobjectnoCustom metadata validated against the organization schema.
idstring (uuid)noRecord UUID. Used only to locate it — never written.
public_idstring (uuid)noPublic UUID of the record, used to locate it.

More fields and nested objects: kobana schema billing.credits.update.

Responses

HTTPDescription
200Record updated.
201Record created.
400Request body failed validation.
404Resource not found in the current organization.
422Request body failed validation.

credits get​

Get credit

kobana billing credits get [ID] [OPTIONS]

GET /v1/credits/{id}

Path arguments: id

Responses

HTTPDescription
200Credit detail.
404Resource not found in the current organization.

credits delete​

Delete credit

kobana billing credits delete [ID] [OPTIONS]

DELETE /v1/credits/{id}

Removes the credit and reverses the matching balance on the billing account. Only allowed if no cents of the credit have been consumed — otherwise the API responds with 400.

Path arguments: id

Responses

HTTPDescription
200Credit deleted.
400Request body failed validation.
404Resource not found in the current organization.