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

List Entries

List credit ledger entries
v1.credit_grants.list_entries(CreditGrantListEntriesParams**kwargs) -> datalistnext_pagestrCreditGrantListEntriesResponse
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
next_pagestr
optional

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

sortliteral
optional
Literal["asc", "desc"]

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

Hide ParametersShow Parameters
"asc"
"desc"
credit_type_idslist
optional
List[str]

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

customer_idslist
optional
List[str]

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

ending_beforeunion
optional
Union[str, datetime]

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_onunion
optional
Union[str, datetime]

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

formatdate-time
Returns
CreditGrantListEntriesResponseclass
Hide ParametersShow Parameters
datalist
List[Data]
Hide ParametersShow Parameters
customer_idstr
formatuuid
ledgerslist
Hide ParametersShow Parameters
credit_typeidstrnamestrCreditTypeData
ending_balanceeffective_atdatetimeexcluding_pendingfloatincluding_pendingfloatDataLedgerEndingBalance

the effective balances at the end of the specified time window

Hide ParametersShow Parameters
effective_atdatetime

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

formatdate-time
excluding_pendingfloat

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_pendingfloat

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

entrieslist
List[amountfloatcreated_bystrcredit_grant_idstreffective_atdatetimereasonstrrunning_balancefloatinvoice_idstrCreditLedgerEntry]
Hide ParametersShow Parameters
amountfloat

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

created_bystr
credit_grant_idstr

the credit grant this entry is related to

formatuuid
effective_atdatetime
formatdate-time
reasonstr
running_balancefloat

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

invoice_idstr
optional

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_entrieslist
List[amountfloatcreated_bystrcredit_grant_idstreffective_atdatetimereasonstrrunning_balancefloatinvoice_idstrCreditLedgerEntry]
Hide ParametersShow Parameters
amountfloat

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

created_bystr
credit_grant_idstr

the credit grant this entry is related to

formatuuid
effective_atdatetime
formatdate-time
reasonstr
running_balancefloat

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

invoice_idstr
optional

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_atdatetimeexcluding_pendingfloatincluding_pendingfloatDataLedgerStartingBalance
Hide ParametersShow Parameters
effective_atdatetime

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

formatdate-time
excluding_pendingfloat

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

including_pendingfloat

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

next_pagestr
from datetime import datetime
from metronome import Metronome

client = Metronome(
    bearer_token="My Bearer Token",
)
response = client.v1.credit_grants.list_entries(
    credit_type_ids=["2714e483-4ff1-48e4-9e25-ac732e8f24f2"],
    customer_ids=["6a37bb88-8538-48c5-b37b-a41c836328bd"],
    ending_before=datetime.fromisoformat("2021-02-01T00:00:00"),
    starting_on=datetime.fromisoformat("2021-01-01T00:00:00"),
)
print(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"
}