Skip to content
  • Auto
  • Light
  • Dark
Talk to an expert

List Entries

List credit ledger entries
client.v1.creditGrants.listEntries(CreditGrantListEntriesParamsparams?, RequestOptionsoptions?): dataarraynext_pageunionCreditGrantListEntriesResponse
post/v1/credits/listEntries

Fetches a list of credit ledger entries. Returns lists of ledgers per customer. Ledger entries are returned in chronological order. Ledger entries associated with voided credit grants are not included.

Parameters
paramsnext_pagestringsortunioncredit_type_idsarraycustomer_idsarrayending_beforestringstarting_onstringCreditGrantListEntriesParams
Hide ParametersShow Parameters
next_pagestring
optional

Query param: Cursor that indicates where the next page of results should start.

sortunion
optional
"asc" | "desc"

Query param: Ledgers sort order by date, asc or desc. Defaults to asc.

Hide ParametersShow Parameters
"asc"
"desc"
credit_type_idsarray
optional
Array<string>

Body param: A list of Metronome credit type IDs to fetch ledger entries for. If absent, ledger entries for all credit types will be returned.

customer_idsarray
optional
Array<string>

Body param: A list of Metronome customer IDs to fetch ledger entries for. If absent, ledger entries for all customers will be returned.

ending_beforestring
optional

Body param: If supplied, ledger entries will only be returned with an effective_at before this time. This timestamp must not be in the future. If no timestamp is supplied, all entries up to the start of the customer's next billing period will be returned.

formatdate-time
starting_onstring
optional

Body param: If supplied, only ledger entries effective at or after this time will be returned.

formatdate-time
Returns
CreditGrantListEntriesResponse
Hide ParametersShow Parameters
dataarray
Array<Data>
Hide ParametersShow Parameters
customer_idstring
formatuuid
ledgersarray
Array<Ledger>
Hide ParametersShow Parameters
credit_typeidstringnamestringCreditTypeData
ending_balanceeffective_atstringexcluding_pendingnumberincluding_pendingnumberEndingBalance

the effective balances at the end of the specified time window

Hide ParametersShow Parameters
effective_atstring

the ending_before request parameter (if supplied) or the current billing period's end date

formatdate-time
excluding_pendingnumber

the ending balance, including the balance of all grants that have not expired before the effective_at date and deductions that happened before the effective_at date

including_pendingnumber

the excluding_pending balance plus any pending invoice deductions and expirations that will happen by the effective_at date

entriesarray
Array<amountnumbercreated_bystringcredit_grant_idstringeffective_atstringreasonstringrunning_balancenumberinvoice_idunionCreditLedgerEntry>
Hide ParametersShow Parameters
amountnumber

an amount representing the change to the customer's credit balance

created_bystring
credit_grant_idstring

the credit grant this entry is related to

formatuuid
effective_atstring
formatdate-time
reasonstring
running_balancenumber

the running balance for this credit type at the time of the ledger entry, including all preceding charges

invoice_idunion
optional
string | null

if this entry is a deduction, the Metronome ID of the invoice where the credit deduction was consumed; if this entry is a grant, the Metronome ID of the invoice where the grant's paid_amount was charged

formatuuid
pending_entriesarray
Array<amountnumbercreated_bystringcredit_grant_idstringeffective_atstringreasonstringrunning_balancenumberinvoice_idunionCreditLedgerEntry>
Hide ParametersShow Parameters
amountnumber

an amount representing the change to the customer's credit balance

created_bystring
credit_grant_idstring

the credit grant this entry is related to

formatuuid
effective_atstring
formatdate-time
reasonstring
running_balancenumber

the running balance for this credit type at the time of the ledger entry, including all preceding charges

invoice_idunion
optional
string | null

if this entry is a deduction, the Metronome ID of the invoice where the credit deduction was consumed; if this entry is a grant, the Metronome ID of the invoice where the grant's paid_amount was charged

formatuuid
starting_balanceeffective_atstringexcluding_pendingnumberincluding_pendingnumberStartingBalance
Hide ParametersShow Parameters
effective_atstring

the starting_on request parameter (if supplied) or the first credit grant's effective_at date

formatdate-time
excluding_pendingnumber

the starting balance, including all posted grants, deductions, and expirations that happened at or before the effective_at timestamp

including_pendingnumber

the excluding_pending balance plus any pending activity that has not been posted at the time of the query

next_pageunion
string | null
import Metronome from '@metronome/sdk';

const client = new Metronome({
  bearerToken: 'My Bearer Token',
});

const response = await client.v1.creditGrants.listEntries({
  credit_type_ids: ['2714e483-4ff1-48e4-9e25-ac732e8f24f2'],
  customer_ids: ['6a37bb88-8538-48c5-b37b-a41c836328bd'],
  ending_before: '2021-02-01T00:00:00Z',
  starting_on: '2021-01-01T00:00:00Z',
});

console.log(response.data);
200 Example
{
  "data": [
    {
      "customer_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
      "ledgers": [
        {
          "credit_type": {
            "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
            "name": "name"
          },
          "ending_balance": {
            "effective_at": "2019-12-27T18:11:19.117Z",
            "excluding_pending": 0,
            "including_pending": 0
          },
          "entries": [
            {
              "amount": 0,
              "created_by": "created_by",
              "credit_grant_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
              "effective_at": "2019-12-27T18:11:19.117Z",
              "reason": "Automated invoice deduction",
              "running_balance": 0,
              "invoice_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
            }
          ],
          "pending_entries": [
            {
              "amount": 0,
              "created_by": "created_by",
              "credit_grant_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
              "effective_at": "2019-12-27T18:11:19.117Z",
              "reason": "Automated invoice deduction",
              "running_balance": 0,
              "invoice_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
            }
          ],
          "starting_balance": {
            "effective_at": "2019-12-27T18:11:19.117Z",
            "excluding_pending": 0,
            "including_pending": 0
          }
        }
      ]
    }
  ],
  "next_page": "next_page"
}