Knowledge Center

Knowledge Center > API > REST API > REST API Reference > Usage > Get usage

Get usage

This REST API reference describes how to retrieve usage details for an account. Usage data is returned in reverse chronological order.

Request

  • Production: GET https://api.zuora.com/rest/v1/usage/accounts/{account-key}
  • API Sandbox: GET https://apisandbox-api.zuora.com/rest/v1/usage/accounts/{account-key}

Request parameters

account-key

required

path

Account number or account ID

pageSize

optional

query

Number of rows to return.  Maximum is 40; default is 20.

Response

success

Contains true if successful, otherwise false.

processId

Internal process ID to assist Zuora support. Only returned if 

success is false.

reasons

Information on one or more reasons for the result. Only returned if success is false.

code

Eight-digit numeric error code

message

Description of the error

Usage

Contains one or more usage items:

id

Unique ID for the usage item

accountID

Customer account ID

accountNumber

Customer account number

accountName

Customer account name

subscriptionNumber

Number of the subscription covering this usage

chargeNumber

Number of the rate-plan charge that pays for this usage

unitOfMeasure

Unit used to measure consumption, as configured in the web-based UI at Z-Billing > Settings

quantity

Number of units used

submissionDateTime

Date when usage was submitted

startDateTime

Start date of the time period in which usage is tracked. Zuora uses this field value to determine the usage date.

status

Possible values are: Importing, Pending, Processed.

sourceName

Source of the usage data. Possible values are: Import, API.

cf_txtn__c

One or more custom fields

cf_pkn__c

One or more custom fields

nextPage

URL for requesting the next page of the response, if it exists; otherwise absent

Examples

HTTP/JSON request:

GET https://api.zuora.com/rest/v1/usage/accounts/A00001115?pageSize=10

JSON response:

{
  "usage": [
    {
      "chargeNumber": null,
      "sourceName": "Import",
      "quantity": 4.0,
      "unitOfMeasure": "UOM",
      "accountName": "subscribeCallYan_1",
      "id": "2c92c8953dac2b1c013dae0a263f35dd",
      "subscriptionNumber": null,
      "startDateTime": "2012-02-05 00:00:00",
      "accountNumber": "A00001115",
      "status": "Pending",
      "submissionDateTime": "2013-03-27 15:48:53",
      "accountId": "2c92a0f9391832b10139183e277a0042"
    },
    {
      "chargeNumber": null,
      "sourceName": "Import",
      "quantity": 4.0,
      "unitOfMeasure": "UOM",
      "accountName": "subscribeCallYan_1",
      "id": "2c92c8943db2ae51013dcce116b00f4b",
      "subscriptionNumber": null,
      "startDateTime": "2012-02-05 00:00:00",
      "accountNumber": "A00001115",
      "status": "Pending",
      "submissionDateTime": "2013-04-02 15:32:16",
      "accountId": "2c92a0f9391832b10139183e277a0042"
    },
    {
      "chargeNumber": null,
      "sourceName": "Import",
      "quantity": 3.0,
      "unitOfMeasure": "UOM",
      "accountName": "subscribeCallYan_1",
      "id": "2c92c8953dac2b1c013dae0a263f35dc",
      "subscriptionNumber": null,
      "startDateTime": "2012-02-04 00:00:00",
      "accountNumber": "A00001115",
      "status": "Pending",
      "submissionDateTime": "2013-03-27 15:48:53",
      "accountId": "2c92a0f9391832b10139183e277a0042"
    },
    {
      "chargeNumber": null,
      "sourceName": "Import",
      "quantity": 3.0,
      "unitOfMeasure": "UOM",
      "accountName": "subscribeCallYan_1",
      "id": "2c92c8943db2ae51013dcce116b00f4a",
      "subscriptionNumber": null,
      "startDateTime": "2012-02-04 00:00:00",
      "accountNumber": "A00001115",
      "status": "Pending",
      "submissionDateTime": "2013-04-02 15:32:16",
      "accountId": "2c92a0f9391832b10139183e277a0042"
    },
    {
      "chargeNumber": null,
      "sourceName": "Import",
      "quantity": 2.0,
      "unitOfMeasure": "UOM",
      "accountName": "subscribeCallYan_1",
      "id": "2c92c8953dac2b1c013dae0a263e35db",
      "subscriptionNumber": null,
      "startDateTime": "2012-02-03 00:00:00",
      "accountNumber": "A00001115",
      "status": "Pending",
      "submissionDateTime": "2013-03-27 15:48:53",
      "accountId": "2c92a0f9391832b10139183e277a0042"
    },
    {
      "chargeNumber": null,
      "sourceName": "Import",
      "quantity": 2.0,
      "unitOfMeasure": "UOM",
      "accountName": "subscribeCallYan_1",
      "id": "2c92c8943db2ae51013dcce116af0f49",
      "subscriptionNumber": null,
      "startDateTime": "2012-02-03 00:00:00",
      "accountNumber": "A00001115",
      "status": "Pending",
      "submissionDateTime": "2013-04-02 15:32:16",
      "accountId": "2c92a0f9391832b10139183e277a0042"
    },
    {
      "chargeNumber": null,
      "sourceName": "Import",
      "quantity": 1.0,
      "unitOfMeasure": "UOM",
      "accountName": "subscribeCallYan_1",
      "id": "2c92c8953dac2b1c013dae0a263e35da",
      "subscriptionNumber": null,
      "startDateTime": "2012-02-02 00:00:00",
      "accountNumber": "A00001115",
      "status": "Pending",
      "submissionDateTime": "2013-03-27 15:48:53",
      "accountId": "2c92a0f9391832b10139183e277a0042"
    },
    {
      "chargeNumber": null,
      "sourceName": "Import",
      "quantity": 1.0,
      "unitOfMeasure": "UOM",
      "accountName": "subscribeCallYan_1",
      "id": "2c92c8943db2ae51013dcce116af0f48",
      "subscriptionNumber": null,
      "startDateTime": "2012-02-02 00:00:00",
      "accountNumber": "A00001115",
      "status": "Pending",
      "submissionDateTime": "2013-04-02 15:32:16",
      "accountId": "2c92a0f9391832b10139183e277a0042"
    },
    {
      "chargeNumber": null,
      "sourceName": "Import",
      "quantity": 4.0,
      "unitOfMeasure": "UOM",
      "accountName": "subscribeCallYan_1",
      "id": "2c92c8953dac2b1c013dae0a263e35d9",
      "subscriptionNumber": null,
      "startDateTime": "2012-01-05 00:00:00",
      "accountNumber": "A00001115",
      "status": "Pending",
      "submissionDateTime": "2013-03-27 15:48:53",
      "accountId": "2c92a0f9391832b10139183e277a0042"
    },
    {
      "chargeNumber": null,
      "sourceName": "Import",
      "quantity": 4.0,
      "unitOfMeasure": "UOM",
      "accountName": "subscribeCallYan_1",
      "id": "2c92c8943db2ae51013dcce116af0f47",
      "subscriptionNumber": null,
      "startDateTime": "2012-01-05 00:00:00",
      "accountNumber": "A00001115",
      "status": "Pending",
      "submissionDateTime": "2013-04-02 15:32:16",
      "accountId": "2c92a0f9391832b10139183e277a0042"
    }
  ],
  "success": true,
  "nextPage": "https://api.zuora.com/rest/v1/usage/accounts/A00001115?page=2&pageSize=10"
}

CURL request:

##
## Query Usage
##
echo
echo "=============Get Payments by Account Key============="
echo
curl -i -k -H "apiAccessKeyId:$USER_NAME" -H "apiSecretAccessKey:$PASSWORD" -H "Accept:application/json" -X GET $BASE_URL/v1/usage/accounts/A00000001

JSON response:

{
  "usage": [
    {
      "chargeNumber": null,
      "sourceName": "Import",
      "quantity": 4.0,
      "unitOfMeasure": "UOM",
      "accountName": "subscribeCallYan_1",
      "id": "2c92c8953dac2b1c013dae0a263f35dd",
      "subscriptionNumber": null,
      "startDateTime": "2012-02-05 00:00:00",
      "accountNumber": "A00001115",
      "status": "Pending",
      "submissionDateTime": "2013-03-27 15:48:53",
      "accountId": "2c92a0f9391832b10139183e277a0042"
    },
    {
      "chargeNumber": null,
      "sourceName": "Import",
      "quantity": 4.0,
      "unitOfMeasure": "UOM",
      "accountName": "subscribeCallYan_1",
      "id": "2c92c8943db2ae51013dcce116b00f4b",
      "subscriptionNumber": null,
      "startDateTime": "2012-02-05 00:00:00",
      "accountNumber": "A00001115",
      "status": "Pending",
      "submissionDateTime": "2013-04-02 15:32:16",
      "accountId": "2c92a0f9391832b10139183e277a0042"
    },
    {
      "chargeNumber": null,
      "sourceName": "Import",
      "quantity": 3.0,
      "unitOfMeasure": "UOM",
      "accountName": "subscribeCallYan_1",
      "id": "2c92c8953dac2b1c013dae0a263f35dc",
      "subscriptionNumber": null,
      "startDateTime": "2012-02-04 00:00:00",
      "accountNumber": "A00001115",
      "status": "Pending",
      "submissionDateTime": "2013-03-27 15:48:53",
      "accountId": "2c92a0f9391832b10139183e277a0042"
    },
    {
      "chargeNumber": null,
      "sourceName": "Import",
      "quantity": 3.0,
      "unitOfMeasure": "UOM",
      "accountName": "subscribeCallYan_1",
      "id": "2c92c8943db2ae51013dcce116b00f4a",
      "subscriptionNumber": null,
      "startDateTime": "2012-02-04 00:00:00",
      "accountNumber": "A00001115",
      "status": "Pending",
      "submissionDateTime": "2013-04-02 15:32:16",
      "accountId": "2c92a0f9391832b10139183e277a0042"
    },
    {
      "chargeNumber": null,
      "sourceName": "Import",
      "quantity": 2.0,
      "unitOfMeasure": "UOM",
      "accountName": "subscribeCallYan_1",
      "id": "2c92c8953dac2b1c013dae0a263e35db",
      "subscriptionNumber": null,
      "startDateTime": "2012-02-03 00:00:00",
      "accountNumber": "A00001115",
      "status": "Pending",
      "submissionDateTime": "2013-03-27 15:48:53",
      "accountId": "2c92a0f9391832b10139183e277a0042"
    },
    {
      "chargeNumber": null,
      "sourceName": "Import",
      "quantity": 2.0,
      "unitOfMeasure": "UOM",
      "accountName": "subscribeCallYan_1",
      "id": "2c92c8943db2ae51013dcce116af0f49",
      "subscriptionNumber": null,
      "startDateTime": "2012-02-03 00:00:00",
      "accountNumber": "A00001115",
      "status": "Pending",
      "submissionDateTime": "2013-04-02 15:32:16",
      "accountId": "2c92a0f9391832b10139183e277a0042"
    },
    {
      "chargeNumber": null,
      "sourceName": "Import",
      "quantity": 1.0,
      "unitOfMeasure": "UOM",
      "accountName": "subscribeCallYan_1",
      "id": "2c92c8953dac2b1c013dae0a263e35da",
      "subscriptionNumber": null,
      "startDateTime": "2012-02-02 00:00:00",
      "accountNumber": "A00001115",
      "status": "Pending",
      "submissionDateTime": "2013-03-27 15:48:53",
      "accountId": "2c92a0f9391832b10139183e277a0042"
    },
    {
      "chargeNumber": null,
      "sourceName": "Import",
      "quantity": 1.0,
      "unitOfMeasure": "UOM",
      "accountName": "subscribeCallYan_1",
      "id": "2c92c8943db2ae51013dcce116af0f48",
      "subscriptionNumber": null,
      "startDateTime": "2012-02-02 00:00:00",
      "accountNumber": "A00001115",
      "status": "Pending",
      "submissionDateTime": "2013-04-02 15:32:16",
      "accountId": "2c92a0f9391832b10139183e277a0042"
    },
    {
      "chargeNumber": null,
      "sourceName": "Import",
      "quantity": 4.0,
      "unitOfMeasure": "UOM",
      "accountName": "subscribeCallYan_1",
      "id": "2c92c8953dac2b1c013dae0a263e35d9",
      "subscriptionNumber": null,
      "startDateTime": "2012-01-05 00:00:00",
      "accountNumber": "A00001115",
      "status": "Pending",
      "submissionDateTime": "2013-03-27 15:48:53",
      "accountId": "2c92a0f9391832b10139183e277a0042"
    },
    {
      "chargeNumber": null,
      "sourceName": "Import",
      "quantity": 4.0,
      "unitOfMeasure": "UOM",
      "accountName": "subscribeCallYan_1",
      "id": "2c92c8943db2ae51013dcce116af0f47",
      "subscriptionNumber": null,
      "startDateTime": "2012-01-05 00:00:00",
      "accountNumber": "A00001115",
      "status": "Pending",
      "submissionDateTime": "2013-04-02 15:32:16",
      "accountId": "2c92a0f9391832b10139183e277a0042"
    }
  ],
  "success": true,
  "nextPage": "https://api.zuora.com/rest/v1/usage/accounts/A00001115?page=2&pageSize=10"
}
Last modified
07:56, 6 Feb 2016

Tags

Classifications

(not set)