Skip to main content
POST
/
companies
/
{company_id}
/
credits
/
consume
Consume Credits
curl --request POST \
  --url https://api.maplebilling.com/api/v1/companies/{company_id}/credits/consume \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "customer_id": "<string>",
  "type": "<string>",
  "amount": {
    "currency": "<string>",
    "value_in_cents": 123
  },
  "credit_id": "<unknown>",
  "item_id": "<unknown>",
  "note": "<unknown>",
  "units": "<unknown>"
}
'
{
  "total_amount": {},
  "total_units": {},
  "total_units_with_meta": {}
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Headers

Idempotency-Key
string

The idempotency key that will be used to ensure the request is only performed once

Path Parameters

company_id
string
required

The company ID with the prefix 'cmp_'.

Body

application/json
customer_id
string
required

The customer ID to consume credits

type
string
required

The type of the credit to be consumed, can be one of AMOUNT or UNITS

amount
object

The amount to be consumed

credit_id
null | string

The specific credit ID to consume

item_id
null | string

The billable item ID whose units are to be consumed

note
null | string

Add any notes attached to the credit consumption

units
null | number

The units to consume

Required range: x >= 0

Response

200 - application/json

OK

total_amount
object
total_units
object
total_units_with_meta
object