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

List Entries

List credit ledger entries
client.V1.CreditGrants.ListEntries(ctx, params) (*DataarrayNextPagestringV1CreditGrantListEntriesResponse, error)
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
paramsNextPagefieldSortfieldCreditTypeIDsfieldCustomerIDsfieldEndingBeforefieldStartingOnfieldV1CreditGrantListEntriesParams
Hide ParametersShow Parameters
NextPagefield
optional
param.Field[string]

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

Sortfield
optional

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

Hide ParametersShow Parameters
V1CreditGrantListEntriesParamsSortAscconst
"asc"
V1CreditGrantListEntriesParamsSortDescconst
"desc"
CreditTypeIDsfield
optional
param.Field[[]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.

CustomerIDsfield
optional
param.Field[[]string]

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

EndingBeforefield
optional
param.Field[Time]

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
StartingOnfield
optional
param.Field[Time]

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

formatdate-time
Returns
V1CreditGrantListEntriesResponsestruct
Hide ParametersShow Parameters
Hide ParametersShow Parameters
CustomerIDstring
formatuuid
Hide ParametersShow Parameters
CreditTypeIDstringNamestringCreditTypeData
EndingBalanceEffectiveAtTimeExcludingPendingfloat64IncludingPendingfloat64V1CreditGrantListEntriesResponseDataLedgersEndingBalance

the effective balances at the end of the specified time window

Hide ParametersShow Parameters
EffectiveAtTime

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

formatdate-time
ExcludingPendingfloat64

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

IncludingPendingfloat64

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

Entriesarray
[]Amountfloat64CreatedBystringCreditGrantIDstringEffectiveAtTimeReasonstringRunningBalancefloat64InvoiceIDstringCreditLedgerEntry
Hide ParametersShow Parameters
Amountfloat64

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

CreatedBystring
CreditGrantIDstring

the credit grant this entry is related to

formatuuid
EffectiveAtTime
formatdate-time
Reasonstring
RunningBalancefloat64

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

InvoiceIDstring
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
PendingEntriesarray
[]Amountfloat64CreatedBystringCreditGrantIDstringEffectiveAtTimeReasonstringRunningBalancefloat64InvoiceIDstringCreditLedgerEntry
Hide ParametersShow Parameters
Amountfloat64

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

CreatedBystring
CreditGrantIDstring

the credit grant this entry is related to

formatuuid
EffectiveAtTime
formatdate-time
Reasonstring
RunningBalancefloat64

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

InvoiceIDstring
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
StartingBalanceEffectiveAtTimeExcludingPendingfloat64IncludingPendingfloat64V1CreditGrantListEntriesResponseDataLedgersStartingBalance
Hide ParametersShow Parameters
EffectiveAtTime

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

formatdate-time
ExcludingPendingfloat64

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

IncludingPendingfloat64

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

NextPagestring
package main

import (
  "context"
  "fmt"
  "time"

  "github.com/Metronome-Industries/metronome-go"
  "github.com/Metronome-Industries/metronome-go/option"
)

func main() {
  client := metronome.NewClient(
    option.WithBearerToken("My Bearer Token"),
  )
  response, err := client.V1.CreditGrants.ListEntries(context.TODO(), metronome.V1CreditGrantListEntriesParams{
    CreditTypeIDs: metronome.F([]string{"2714e483-4ff1-48e4-9e25-ac732e8f24f2"}),
    CustomerIDs: metronome.F([]string{"6a37bb88-8538-48c5-b37b-a41c836328bd"}),
    EndingBefore: metronome.F(time.Now()),
    StartingOn: metronome.F(time.Now()),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", 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"
}