const apiInstance = new Fastly.BillingApi();
Note
All URIs are relative to https://api.fastly.com
Method | HTTP request | Description |
---|---|---|
getInvoice | GET /billing/v2/year/{year}/month/{month} | Get an invoice |
getInvoiceById | GET /billing/v2/account_customers/{customer_id}/invoices/{invoice_id} | Get an invoice |
getInvoiceMtd | GET /billing/v2/account_customers/{customer_id}/mtd_invoice | Get month-to-date billing estimate |
getInvoice({ month, year })
Get the invoice for a given year and month. Can be any month from when the Customer was created to the current month.
const options = {
month: 05, // required
year: 2020, // required
};
apiInstance.getInvoice(options)
.then((data) => {
console.log(data, "API called successfully.");
})
.catch((error) => {
console.error(error);
});
Name | Type | Description | Notes |
---|---|---|---|
month | String | 2-digit month. | |
year | String | 4-digit year. |
getInvoiceById({ customer_id, invoice_id })
Get the invoice for the given invoice_id.
const options = {
customer_id: "customer_id_example", // required
invoice_id: 4183280, // required
};
apiInstance.getInvoiceById(options)
.then((data) => {
console.log(data, "API called successfully.");
})
.catch((error) => {
console.error(error);
});
Name | Type | Description | Notes |
---|---|---|---|
customer_id | String | Alphanumeric string identifying the customer. | |
invoice_id | Number |
getInvoiceMtd({ customer_id, [month, ][year] })
Get the current month-to-date estimate. This endpoint has two different responses. Under normal circumstances, it generally takes less than 5 seconds to generate but in certain cases can take up to 60 seconds. Once generated the month-to-date estimate is cached for 4 hours, and is available the next request will return the JSON representation of the month-to-date estimate. While a report is being generated in the background, this endpoint will return a 202 Accepted
response. The full format of which can be found in detail in our billing calculation guide. There are certain accounts for which we are unable to generate a month-to-date estimate. For example, accounts who have parent-pay are unable to generate an MTD estimate. The parent accounts are able to generate a month-to-date estimate but that estimate will not include the child accounts amounts at this time.
const options = {
customer_id: "customer_id_example", // required
month: 05,
year: 2020,
};
apiInstance.getInvoiceMtd(options)
.then((data) => {
console.log(data, "API called successfully.");
})
.catch((error) => {
console.error(error);
});
Name | Type | Description | Notes |
---|---|---|---|
customer_id | String | Alphanumeric string identifying the customer. | |
month | String | 2-digit month. | [optional] |
year | String | 4-digit year. | [optional] |