4.5 Usage Activity API
Usage Activity records are used for metered billing and used in conjunction with a Plan that has one or more Usage based charges.
4.5.1. Retrieve Usage Activity:
The maximum number of Activity records that may be returned in a single call is 100. Quantities greater than this may be retrieved in batches by advancing the offset a page at a time.
Any of the above querystring parameters may be combined to filter the results
The "invoiceNumber" for the Activity is only assigned when it has been billed (i.e., Activity.status changes from 'Unbilled' to 'Processed'). Consequently this filter criteria can only be applied for billed activity records.
The 'beginDate' and 'endDate' may be used to filter on the Activity.chargeDate.
4.5.2. Create (Upload) Usage Activity:
Usage activity may be uploaded as a batch (with a maximum of 1000 records ber batch).There are 3 critical fields that are required for all Activity records. It is recommend that your calling programs send all the 3 fields if they are available.
The Customer may be specified by either the internal (BluBilling) customer id or the external customer reference number. If the order id/number is specified, then the customer can be inferred and therefore left blank.
The Order may be specified by either the order id or order number. See note #2 below for additional details, including the option to leave this blank. If the specified customer has only one active order (with order start and end dates that span the activity charge date), and this order contains the specified PriceCode, then this is automatically selected.
The Order Line Item is usually specified by specifying the PriceCode (configured in the Charges associated with the Plan). If the specified Order has only one line item, then this is automatically selected.
The example shows both forms of specifying the required fields.
The <extRefId> may be used to assign a correlation id that uniquely identifies the record to your organization.
The algorithm for automatically determining the Customer, Order, and OrderLineItem fields is:
If only the Customer and PriceCode details are provided, but not the Order details, then find any order having this PriceCode that is in active status and having order start and end dates that span the activity charge date. If no orders or multiple orders are found with this criteria, then an error is returned.
If only the Order details are provided, and the Order has only one OrderLineIItem of type UsageCharge, then the system uses this one. If multiple Usage-based Charges (or none) are found, then an error is returned.
BluBilling will update the <status> to "Processed" and assign the correct <amount> when the billing process runs based on the pricing configuration. However, if you populate the amount, then this value will be used.
The <chargeDate> indicates the date on which the charge is incurred and used by the billing run to determine which charges to process for a given billing period. It defaults to the current date if not provided.
You may verify that the usage activity has been uploaded correctly by logging into the system and using the "System >> Usage Activity" screen
4.5.3. Delete Individual Activity Records:
To delete a record (that has not yet been billed), use the HTTP DELETE call:
Note that records must be deleted one at a time. The singular form of "activity" is used in the URL (rather than "activities").