Upload Usage Records

Make sure you have uploaded all the usage data to Zuora before generating and posting the invoice for a service period. If you import the usage data for the service period after the invoice has been posted, the newly imported usage data will not be billed.

Suppose that your customer ZUA (account_id= 2c92c0f974e9737a0175034cc0cc10c1) has subscribed to a usage-based price where they are charged based on the number of printers they used. The subscription number is A-S00000067, and this subscription contains only one subscription item where its number is C-00000162. Now you want to upload the usage record for this subscription.

Copy
Copied
curl --request POST \
     --url https://rest.apisandbox.zuora.com/v2/usage_records \
     --header 'Authorization: Bearer d8a8d32800054b49bee2ebf05ea91a31' \
     --header 'Content-Type: application/json' \
     --data '{
            "unit_of_measure": "Each",
            "quantity": "4",
            "subscription_number": "A-S00000067",
            "subscription_item_number":"C-00000162",
            "start_time": "2023-04-01T00:00:00+00:00",
            "account_id": "2c92c0f974e9737a0175034cc0cc10c1"
      }'

If the usage record is uploaded successfully, you will get the following 201 Created response:

Copy
Copied
{
	"id": "8ad08cbd87553d8c018755c7e8a61c4b",
	"created_by_id": "8ad09bce80507dab0180688bdabc20cb",
	"created_time": "2023-04-06T01:56:17-07:00",
	"custom_fields": {
		"Rate__c": "0"
	},
	"custom_objects": {},
	"account_number": "RC-00000093",
	"account_id": "2c92c0f974e9737a0175034cc0cc10c1",
	"description": "",
	"quantity": 4,
	"subscription_id": "",
	"unit_of_measure": "Each",
	"state": "pending"
}