Fetch customer credits ledger by external ID
The credits ledger provides auditing functionality over Orb's credits system with a list of actions that have taken place to modify a customer's credit balance. This paginated endpoint lists these entries, starting from the most recent ledger entry.
More details on using Orb's real-time credit feature are here.
There are four major types of modifications to credit balance, detailed below.
Increment
Credits (which optionally expire on a future date) can be added via the API (Add Ledger Entry). The ledger entry for such an action will always contain the total eligible starting and ending balance for the customer at the time the entry was added to the ledger.
Decrement
Deductions can occur as a result of an API call to create a ledger entry (see
Add Ledger Entry), or automatically as a result of incurring usage. Both ledger entries
present the decrement
entry type.
As usage for a customer is reported into Orb, credits may be deducted according to the customer's plan
configuration. An automated deduction of this type will result in a ledger entry, also with a starting and ending
balance. In order to provide better tracing capabilities for automatic deductions, Orb always associates each
automatic deduction with the event_id
at the time of ingestion, used to pinpoint why credit deduction took
place and to ensure that credits are never deducted without an associated usage event.
By default, Orb uses an algorithm that automatically deducts from the soonest expiring credit block first in order to ensure that all credits are utilized appropriately. As an example, if trial credits with an expiration date of 2 weeks from now are present for a customer, they will be used before any deductions take place from a non-expiring credit block.
If there are multiple blocks with the same expiration date, Orb will deduct from the block with the lower cost basis first (e.g. trial credits with a $0 cost basis before paid credits with a $5.00 cost basis).
It's also possible for a single usage event's deduction to span credit blocks. In this case, Orb will deduct from the next block, ending at the credit block which consists of unexpiring credits. Each of these deductions will lead to a separate ledger entry, one per credit block that is deducted from. By default, the customer's total credit balance in Orb can be negative as a result of a decrement.
Expiration change
The expiry of credits can be changed as a result of the API (See Add Ledger Entry). This will create a ledger entry that specifies the balance as well as the initial and target expiry dates.
Note that for this entry type, starting_balance
will equal ending_balance
, and the amount
represents the
balance transferred. The credit block linked to the ledger entry is the source credit block from which there was an
expiration change
Credits expiry
When a set of credits expire on pre-set expiration date, the customer's balance automatically reflects this change and adds an entry to the ledger indicating this event. Note that credit expiry should always happen close to a date boundary in the customer's timezone.
Void initiated
Credit blocks can be voided via the API. The amount
on this entry corresponds to the number of credits that were
remaining in the block at time of void. void_reason
will be populated if the void is created with a reason.
Void
When a set of credits is voided, the customer's balance automatically reflects this change and adds an entry to the ledger indicating this event.
Amendment
When credits are added to a customer's balance as a result of a correction, this entry will be added to the ledger to indicate the adjustment of credits.
Path Parameters
Query Parameters
Possible values: >= 1
and <= 1000
Default value: 20
Possible values: [increment
, decrement
, expiration_change
, credit_block_expiry
, void
, void_initiated
, amendment
]
Possible values: [committed
, pending
]
- 200
- 400
- 401
- 404
- 409
- 413
- 429
- 500
OK
Response Headers
Schema
- Array [
- ]
data object[] required
metadata object required
User specified key-value pairs for the resource. If not present, this defaults to an empty dictionary. Individual keys can be removed by setting the value to null
, and the entire metadata mapping can be cleared by setting metadata
to null
.
Possible values: [committed
, pending
]
customer object required
credit_block object required
Possible values: [increment
]
metadata object required
User specified key-value pairs for the resource. If not present, this defaults to an empty dictionary. Individual keys can be removed by setting the value to null
, and the entire metadata mapping can be cleared by setting metadata
to null
.
Possible values: [committed
, pending
]
customer object required
credit_block object required
Possible values: [decrement
]
metadata object required
User specified key-value pairs for the resource. If not present, this defaults to an empty dictionary. Individual keys can be removed by setting the value to null
, and the entire metadata mapping can be cleared by setting metadata
to null
.
Possible values: [committed
, pending
]
customer object required
credit_block object required
Possible values: [expiration_change
]
metadata object required
User specified key-value pairs for the resource. If not present, this defaults to an empty dictionary. Individual keys can be removed by setting the value to null
, and the entire metadata mapping can be cleared by setting metadata
to null
.
Possible values: [committed
, pending
]
customer object required
credit_block object required
Possible values: [credit_block_expiry
]
metadata object required
User specified key-value pairs for the resource. If not present, this defaults to an empty dictionary. Individual keys can be removed by setting the value to null
, and the entire metadata mapping can be cleared by setting metadata
to null
.
Possible values: [committed
, pending
]
customer object required
credit_block object required
Possible values: [void
]
metadata object required
User specified key-value pairs for the resource. If not present, this defaults to an empty dictionary. Individual keys can be removed by setting the value to null
, and the entire metadata mapping can be cleared by setting metadata
to null
.
Possible values: [committed
, pending
]
customer object required
credit_block object required
Possible values: [void_initiated
]
metadata object required
User specified key-value pairs for the resource. If not present, this defaults to an empty dictionary. Individual keys can be removed by setting the value to null
, and the entire metadata mapping can be cleared by setting metadata
to null
.
Possible values: [committed
, pending
]
customer object required
credit_block object required
Possible values: [amendment
]
pagination_metadata object required
{
"data": [
{},
{},
{},
{},
{},
{},
{}
],
"pagination_metadata": {
"has_more": true,
"next_cursor": "string"
}
}
Bad Request
Response Headers
Schema
Possible values: [https://docs.withorb.com/reference/error-responses#400-constraint-violation
]
Possible values: [400
]
Possible values: [https://docs.withorb.com/reference/error-responses#400-duplicate-resource-creation
]
Possible values: [400
]
Possible values: [https://docs.withorb.com/reference/error-responses#400-request-validation-errors
]
Possible values: [400
]
{}
Unauthorized
Response Headers
Schema
Possible values: [https://docs.withorb.com/reference/error-responses#401-authentication-error
]
Possible values: [401
]
{
"type": "https://docs.withorb.com/reference/error-responses#401-authentication-error",
"status": 401,
"detail": "string",
"title": "string"
}
Not Found
Response Headers
Schema
Possible values: [https://docs.withorb.com/reference/error-responses#404-feature-not-available
]
Possible values: [400
]
Possible values: [https://docs.withorb.com/reference/error-responses#404-resource-not-found
]
Possible values: [404
]
Possible values: [https://docs.withorb.com/reference/error-responses#404-url-not-found
]
Possible values: [404
]
{}
Conflict
Response Headers
Schema
Possible values: [https://docs.withorb.com/reference/error-responses#409-resource-conflict
]
Possible values: [409
]
{
"type": "https://docs.withorb.com/reference/error-responses#409-resource-conflict",
"status": 409,
"detail": "string",
"title": "string"
}
Request Entity Too Large
Response Headers
Schema
Possible values: [https://docs.withorb.com/reference/error-responses#413-request-too-large
]
Possible values: [413
]
Possible values: [https://docs.withorb.com/reference/error-responses#413-resource-too-large
]
Possible values: [413
]
Possible values: [https://docs.withorb.com/reference/error-responses#413-too-many-results
]
Possible values: [413
]
{}
Too Many Requests
Response Headers
Schema
Possible values: [https://docs.withorb.com/reference/error-responses#429-too-many-requests
]
Possible values: [429
]
{
"type": "https://docs.withorb.com/reference/error-responses#429-too-many-requests",
"status": 429,
"detail": "string",
"title": "string"
}
Internal Server Error
Response Headers
Schema
Possible values: [https://docs.withorb.com/reference/error-responses#500-internal-server-error
]
{
"type": "https://docs.withorb.com/reference/error-responses#500-internal-server-error",
"status": 0,
"detail": "string",
"title": "string"
}