Skip to main content

kobana billing coupons

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

CommandHTTPDescription
coupons listGET /v1/couponsList coupons
coupons createPOST /v1/couponsCreate coupon
coupons updatePUT /v1/couponsUpsert coupon
coupons getGET /v1/coupons/{id}Get coupon
coupons deleteDELETE /v1/coupons/{id}Delete coupon
coupons deactivatePOST /v1/coupons/{id}/deactivateDeactivate coupon
coupons redemptionsGET /v1/coupons/{id}/redemptionsList coupon redemptions

coupons list​

List coupons

kobana billing coupons list [OPTIONS]

GET /v1/coupons

Returns a paginated list of the current organization's coupons.

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.
is_activestringnoFilter by status: true returns only active coupons; false, only inactive. Values: true, false.
searchstringnoFree-text search across code and name.
discount_typestringnoFilter by discount type: percentage or fixed_amount. Values: percentage, fixed_amount.
codestringnoFilter by exact coupon code.
min_purchase_minnumber,nullnoMinimum value of min_purchase (in BRL) to filter coupons.
min_purchase_maxnumber,nullnoMaximum value of min_purchase (in BRL) to filter coupons.
max_discount_minnumber,nullnoMinimum value of max_discount (in BRL) to filter coupons.
max_discount_maxnumber,nullnoMaximum value of max_discount (in BRL) to filter coupons.
valid_from_fromstringnoReturns coupons whose validity start date is on or after this date (YYYY-MM-DD).
valid_from_tostringnoReturns coupons whose validity start date is on or before this date (YYYY-MM-DD).
valid_until_fromstringnoReturns coupons whose expiration date is on or after this date (YYYY-MM-DD).
valid_until_tostringnoReturns coupons whose expiration date is on or before this date (YYYY-MM-DD).
created_afterstringnoReturns coupons created on or after this date (YYYY-MM-DD).
created_beforestringnoReturns coupons created on or before this date (YYYY-MM-DD).

Responses

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

coupons create​

Create coupon

kobana billing coupons create [OPTIONS]

POST /v1/coupons

Creates a discount coupon. The code must be unique per organization. Use discount_type=percentage with discount_value between 0 and 100, or discount_type=fixed_amount with discount_value in BRL (float, up to 4 decimal places).

Request body

NameTypeRequiredDescription
codestringyesPublic coupon code — unique per organization.
namestringyesInternal coupon name.
discount_typestringyesDiscount type: percentage or fixed_amount. Values: percentage, fixed_amount.
discount_valuenumberyesDiscount value. For percentage, integer between 0 and 100. For fixed_amount, amount in BRL (float, up to 4 decimal places).
external_idstringnoIdentifier in your external system, for idempotency/sync.
descriptionstringnoOptional description.
currencystringnoISO 4217 currency. Default: BRL.
min_purchasenumbernoMinimum invoice amount, in BRL (float, up to 4 decimal places), for the coupon to be applicable.
max_discountnumbernoAbsolute discount cap, in BRL (float, up to 4 decimal places).
usage_limitintegernoMaximum total redemptions across the organization. Omit for unlimited.
usage_limit_per_userintegernoMaximum redemptions per billing account. Omit for unlimited.
valid_fromstringnoStart of the validity window (ISO 8601 — date or date-time).
valid_untilstringnoEnd of the validity window (ISO 8601 — date or date-time).
applies_toobjectno
excludesobjectno
custom_metadataobjectnoArbitrary client-defined metadata (key/value).

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

Responses

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

coupons update​

Upsert coupon

kobana billing coupons update [OPTIONS]

PUT /v1/coupons

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
codestringnoPublic coupon code — unique per organization.
external_idstringnoIdentifier in your external system, for idempotency/sync.
namestringnoInternal coupon name.
descriptionstringnoOptional description.
discount_typestringnoDiscount type: percentage or fixed_amount. Values: percentage, fixed_amount.
discount_valuenumbernoDiscount value. For percentage, integer between 0 and 100. For fixed_amount, amount in BRL (float, up to 4 decimal places).
currencystringnoISO 4217 currency. Default: BRL.
min_purchasenumbernoMinimum invoice amount, in BRL (float, up to 4 decimal places), for the coupon to be applicable.
max_discountnumbernoAbsolute discount cap, in BRL (float, up to 4 decimal places).
usage_limitintegernoMaximum total redemptions across the organization. Omit for unlimited.
usage_limit_per_userintegernoMaximum redemptions per billing account. Omit for unlimited.
valid_fromstringnoStart of the validity window (ISO 8601 — date or date-time).
valid_untilstringnoEnd of the validity window (ISO 8601 — date or date-time).
applies_toobjectno
excludesobjectno
custom_metadataobjectnoArbitrary client-defined metadata (key/value).
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.coupons.update.

Responses

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

coupons get​

Get coupon

kobana billing coupons get [ID] [OPTIONS]

GET /v1/coupons/{id}

Path arguments: id

Responses

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

coupons delete​

Delete coupon

kobana billing coupons delete [ID] [OPTIONS]

DELETE /v1/coupons/{id}

Deletes the coupon permanently. Allowed only while the coupon has no recorded redemptions — otherwise use POST /coupons/{id}/deactivate to preserve history.

Path arguments: id

Responses

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

coupons deactivate​

Deactivate coupon

kobana billing coupons deactivate [ID] [OPTIONS]

POST /v1/coupons/{id}/deactivate

Deactivates the coupon: new redemptions are blocked, but previous redemptions are preserved.

Path arguments: id

Responses

HTTPDescription
200Coupon deactivated.
404Resource not found in the current organization.

coupons redemptions​

List coupon redemptions

kobana billing coupons redemptions [ID] [OPTIONS]

GET /v1/coupons/{id}/redemptions

Returns a paginated list of the coupon's recorded redemptions.

Path arguments: id

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.

Responses

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