Managing Credit
Credit entries track all credit-related transactions for a contact's wallet. This includes adding credit, spending credit (redemptions), removing credit, and converting between credit types.
Prerequisites
Before managing credit, ensure you have:
- Authenticated with a valid API token
- A contact with an associated wallet (see Managing Contacts)
Credit Concepts
| Credit Type | Description |
|---|---|
GLOBAL | Monetary credit values (e.g., store credit in currency) |
LOCAL | Non-monetary values (e.g., loyalty points) |
| Action | Description |
|---|---|
ADD | Credit added to the wallet |
SPEND | Credit spent (e.g., redemption) |
REMOVE | Credit manually removed |
Related types:
CreditType- Credit type enumCreditEntryType- Action type enum
Viewing Credit Entries
Credit entries are accessed through a contact's wallet via the account query.
Get Credit Entries for a Contact
query GetContactCreditEntries($uuid: String, $limit: Int, $offset: Int) {
account {
contacts(uuid: $uuid) {
uuid
email
wallet {
uuid
globalCreditBalance
localCreditBalance
creditEntries(limit: $limit, offset: $offset) {
uuid
action
creditType
amount
createdAt
}
}
}
}
}
Get Credit Entries for All Contacts
query GetAllCreditEntries($contactLimit: Int, $entryLimit: Int) {
account {
contacts(limit: $contactLimit) {
uuid
email
wallet {
globalCreditBalance
localCreditBalance
creditEntries(limit: $entryLimit) {
uuid
action
creditType
amount
createdAt
}
}
}
}
}
Get Credit Balances Only
query GetCreditBalances {
account {
contacts {
uuid
email
wallet {
globalCreditBalance
localCreditBalance
shopifyCreditBalance
}
}
}
}
Related types:
Wallet- Wallet object with balance fields andcreditEntriesCreditEntry- Credit entry object fields
Creating Credit Entries
Use the addCreditEntry mutation to add, spend, or remove credit:
mutation AddCreditEntry($creditEntry: AddCreditEntryInput!) {
addCreditEntry(creditEntry: $creditEntry) {
success
creditEntry {
uuid
action
creditType
amount
}
errors
}
}
Variables - Add Global Credit:
{
"creditEntry": {
"action": "ADD",
"creditType": "GLOBAL",
"amount": 25.00,
"walletUuid": "wallet-uuid-here"
}
}
Variables - Add Local Credit (Points):
{
"creditEntry": {
"action": "ADD",
"creditType": "LOCAL",
"amount": 500,
"walletUuid": "wallet-uuid-here"
}
}
Variables - Remove Credit:
{
"creditEntry": {
"action": "REMOVE",
"creditType": "GLOBAL",
"amount": 10.00,
"walletUuid": "wallet-uuid-here"
}
}
Related types:
AddCreditEntryInput- Input fieldsAddCreditEntryResponse- Response type
Converting Credit
Use the convertCredit mutation to convert between credit types (e.g., points to store credit):
mutation ConvertCredit($credit: ConvertCreditInput!) {
convertCredit(credit: $credit) {
success
creditEntry {
uuid
action
creditType
amount
}
errors
}
}
Variables:
{
"credit": {
"walletUuid": "wallet-uuid-here",
"amount": 100,
"conversionRate": 0.01,
"from": "LOCAL",
"to": "GLOBAL"
}
}
This example converts 100 local points to 1.00 global credit (100 × 0.01 = 1.00).
Related types:
ConvertCreditInput- Input fieldsConvertCreditResponse- Response type
Next Steps
- Managing Contacts - Create and manage contacts
- Creating a Redemption - Generate redemption codes