(More info about usage in guide attached)
Below is a basic example of creating usage in Younium. Usage in Younium needs to be keyed on one of the following levels, from least to most specific:
- Account
- Order / Subscription
- Product
- Charge
The example below uses the account as key, which will make the usage eligible for invoicing on any order/subscription, product and charge for the Account. This scenario could be enough if the accounts only have one active order at a time. If the case is that accounts have multiple orders active simultaneously, usage must be keyed on at least the order level. In this scenario, the custom field externalAccountId is used as key field for account lookup.
The unit is the second part of linking a usage item to a charge. The unit must match the unit on the charge for the usage to be linked during invoicing. In the example below, the field unit is used as key.
Create usage
POST
https://apisandbox.younium.com/v1/usage
{
fromDate: '2019-01-01',
description: 'Usage description',
quantity: 10,
source: 'Source where the usage was produced',
account: {
key: 'externalAccountId',
externalAccountId: '123456'
},
unit: {
key: ‘unit’,
unit: 'pcs'
}
}
Update usage
PATCH
https://apisandbox.younium.com/v1/usage
A usage item can only be updated if it has not yet been processed. A usage item becomes processed as soon it is linked to an invoice in Younium.
The below example uses the id of a usage item as key, and update the quantity to 20.
{
key: 'id',
id: '73DF28A7-858F-4981-FB73-08D5540C3504',
quantity: 20
}
Delete Usage
DELETE
https://apisandbox.younium.com/v1/usage
Usage items can only be deleted in Younium as long as they have not yet been processed.
The example below uses the id field of a usage item as key for delete.
{
key: 'id',
id: '73DF28A7-858F-4981-FB73-08D5540C3504'
}