v1

latestOpenAPI 3.1.02026-07-222392081.7 MB
Customers > Credits

Create credits usage

Create a usage entry for a credit product. This will impact the balance of the customer by usage_retained.

post/v1/customers/{id}/credits/{productId}/usage

Path parameters

idstring required
productIdstring required

Request body

usage_retainednumber required

Value indicating the number of credits consumed.

event_idstring

Event ID corresponding to the credit consumption.

Example request

{
  "usage_retained": 41
}

Response

The created credit transaction

idstring required

Credit transaction ID.

product_idstring nullable required

ID of the product related to the transaction.

customer_idstring required

ID of the customer related to the transaction.

payment_method_idstring nullable required

ID of the payment method related to the transaction.

invoice_idstring nullable required

ID of the invoice related to the transaction.

event_idstring nullable required

ID of the event related to the credit consumption.

aggregator_idstring nullable required

ID of the aggregator that triggered this usage (for multi-aggregator credits).

expires_atstring date nullable required

Expiration date for credits linked to this transaction

type'topup' | 'usage' | 'expiration' required

Type of credit transaction.

source'app' | 'portal' | 'api' | 'system' required

Deprecated field, we recommend no longer using it.

amount_excluding_taxnumber nullable required

Monetary amount. Expressed in currency's smallest unit.

credit_countnumber required

Value of credits related to the transaction.

balance_afternumber required

Credit balance after the transaction.

created_atstring date-time required

Credit transaction creation date. UTC date time string in the ISO 8601 format.

updated_atstring date-time required

Credit transaction last edition date. UTC date time string in the ISO 8601 format.

Example response

{
  "id": "cdt_BPZ19obsBS2qyo",
  "product_id": "itm_3kXODDF42QXtnL",
  "price": {
    "id": "pri_0Jv8EbMDOGsHcn",
    "amount": 20000,
    "pack_size": 120
  },
  "customer_id": "cus_Typ0px2W0aiEtl",
  "payment_method_id": "pm_1xMpj5bwRqN7LM",
  "invoice_id": "inv_1eTaiytfA0i2Va",
  "type": "topup",
  "source": "system",
  "credit_count": 32,
  "balance_after": 2000,
  "created_at": "2024-10-13T07:00:01.860Z",
  "updated_at": "2024-10-13T07:00:01.860Z"
}