# Credits tools

[All tool areas](/docs/tools.md). Each tool acts within your access.

## Credits

### get_credit_liability

Get what the business owes in money-like credits, per issuing entity and currency, over local dates (the organization's time zone, up to 366 days): outstanding at the start, issued, redeemed (net of refunds back to them), voided, expired, and outstanding at the end (start + issued − redeemed − voided − expired = end). Counts session_moved, session_canceled, gift_certificate_voided, voucher_refunded, and guest_change: value given instead of money back. Goodwill and service recovery are free discounts, not money owed, and never counted. A refund that pushes an expired credit's expiry out brings its remaining balance back as negative expired from that moment, without rewriting a past period. Narrow with `entityId`. Needs orders:amounts and bookings:read where the source booking is; a location-limited member sees only credits from bookings there. `columns` and `rows` give the same figures as a table, to export as a CSV.

Reads · Members of an organization · Needs bookings:read, orders:amounts

#### Input

- `from` — string; required. First local date, inclusive format: "date"
- `to` — string; required. Last local date, inclusive, up to 366 days after `from` format: "date"
- `entityId` — string; optional. The entity's id, from get_setup

#### Output

- `from` — string; required. 
- `to` — string; required. 
- `canExport` — boolean; required. Whether the organization's plan includes CSV export (Growth and up): the screen offers the download only then. The rows are the same either way
- `columns` — array; required. 
  - `columns[]` — object; optional. 
    - `columns[].key` — string; required. 
    - `columns[].label` — string; required. 
    - `columns[].kind` — string; required.  Allowed: "money", "count", "date", "text"
- `rows` — array; required. 
  - `rows[]` — object; optional. 
    - `rows[].entityId` — string; required. 
    - `rows[].entityName` — string; required. 
    - `rows[].currency` — string; required. 
    - `rows[].outstandingAtStart` — integer; required. Minor units (cents) in the row's currency minimum: -9007199254740991; maximum: 9007199254740991
    - `rows[].issued` — integer; required. Minor units (cents) in the row's currency minimum: -9007199254740991; maximum: 9007199254740991
    - `rows[].redeemed` — integer; required. Paid with them, less what refunds gave back to them minimum: -9007199254740991; maximum: 9007199254740991
    - `rows[].voided` — integer; required. Minor units (cents) in the row's currency minimum: -9007199254740991; maximum: 9007199254740991
    - `rows[].expired` — integer; required. Balances whose expiry passed; negative when a later refund revives an expired balance minimum: -9007199254740991; maximum: 9007199254740991
    - `rows[].outstandingAtEnd` — integer; required. outstandingAtStart + issued − redeemed − voided − expired minimum: -9007199254740991; maximum: 9007199254740991

### issue_credit

Give a booking's guest a credit: stored value with a code, a liability of the entity that sold the booking, in its currency, to use on a later booking (redeeming comes with gift certificates). For `service_recovery` (making up for something that went wrong) or `goodwill`; a session moved or called off gives its credits through move_session and cancel_session. `amount` in minor units. The guest is emailed its code and amount (the creditEmail setting). It expires after creditExpiryMonths (by default never). Managers and front desk are capped per order by the refundCaps setting, counting what they've refunded and credited on it. Needs orders:amounts as well as refunds:create. Undo voids it while it's unused. To give money back to the card use refund_order; for free value with no booking, issue_gift_certificate. Returns a preview to confirm.

Changes · Members of an organization · Needs refunds:create

#### Input

- `orderId` — string; required. The order's id, from list_bookings or list_orders
- `amount` — integer; required. Minor units (cents) in the location's currency exclusiveMinimum: 0
- `reason` — string; required. service_recovery: made right after something went wrong; goodwill: a gesture Allowed: "service\_recovery", "goodwill"
- `note` — string; optional. What it's for, in staff's words, for the activity log and list_credits. Never shown to the guest minLength: 1; maxLength: 500

#### Output

- `id` — string; required. 
- `code` — string; required. What the guest quotes to use it. In full only to someone who may give a credit there (refunds:create and orders:amounts); masked (•••• and its last 4) otherwise, since whoever reads it can spend it
- `status` — string; required.  Allowed: "active", "voided", "expired"
- `reason` — string; required. session_moved, session_canceled: given instead of a refund when the session moved or was called off; service_recovery, goodwill: staff's own; gift_certificate_voided: Given because the gift certificate it was paid with had been cancelled; voucher_refunded: a refund reached what a third party's voucher paid, which can't be handed back, so that part is this credit (the refund's creditId); guest_change: the guest cancelled, removed seats, or moved to a cheaper date on their manage link, and the booking's refund policy gives refunds as credit, so what would have gone back to the card is this credit (the refunds' creditId) Allowed: "session\_moved", "session\_canceled", "service\_recovery", "goodwill", "gift\_certificate\_voided", "voucher\_refunded", "guest\_change"
- `entityId` — string; required. The entity it's a liability of
- `currency` — string; required. 
- `amount` — integer or null; required. Minor units, as issued; null without orders:amounts minimum: -9007199254740991; maximum: 9007199254740991
- `balance` — integer or null; required. What's left to use; null without orders:amounts minimum: -9007199254740991; maximum: 9007199254740991
- `customerId` — string; required. 
- `customerName` — string; required. First name only without customers:contact
- `orderId` — string or null; required. 
- `orderCode` — string or null; required. 
- `sessionId` — string or null; required. 
- `note` — string or null; required. Staff's own words; null without orders:amounts
- `expiresAt` — string or null; required.  format: "date-time"
- `createdAt` — string; required.  format: "date-time"

### list_credits

List credits (stored value given to guests: a session moved or called off, goodwill, service recovery), newest first: code, status (active, voided, expired), reason, amount and balance, the customer, and the order and session it came from. Find them by `customerId`, `orderId`, or `code` (as the guest quotes it, any case), or page through all with `before`. Amounts and staff's note need orders:amounts; the code itself shows in full only to someone who may give a credit there (refunds:create as well), and is masked to its last 4 otherwise, since whoever reads it can spend it. Full names need customers:contact. Someone limited to a location sees credits from bookings there.

Reads · Members of an organization · Needs bookings:read

#### Input

- `customerId` — string; optional. The customer's id, from list_customers
- `orderId` — string; optional. The order's id, from list_bookings or list_orders
- `code` — string; optional.  minLength: 4; maxLength: 32
- `before` — string; optional. The credit's id, from list_credits
- `limit` — integer; optional. The most results to return (default 50) minimum: 1; maximum: 200; default: 50

#### Output

- `credits` — array; required. 
  - `credits[]` — object; optional. 
    - `credits[].id` — string; required. 
    - `credits[].code` — string; required. What the guest quotes to use it. In full only to someone who may give a credit there (refunds:create and orders:amounts); masked (•••• and its last 4) otherwise, since whoever reads it can spend it
    - `credits[].status` — string; required.  Allowed: "active", "voided", "expired"
    - `credits[].reason` — string; required. session_moved, session_canceled: given instead of a refund when the session moved or was called off; service_recovery, goodwill: staff's own; gift_certificate_voided: Given because the gift certificate it was paid with had been cancelled; voucher_refunded: a refund reached what a third party's voucher paid, which can't be handed back, so that part is this credit (the refund's creditId); guest_change: the guest cancelled, removed seats, or moved to a cheaper date on their manage link, and the booking's refund policy gives refunds as credit, so what would have gone back to the card is this credit (the refunds' creditId) Allowed: "session\_moved", "session\_canceled", "service\_recovery", "goodwill", "gift\_certificate\_voided", "voucher\_refunded", "guest\_change"
    - `credits[].entityId` — string; required. The entity it's a liability of
    - `credits[].currency` — string; required. 
    - `credits[].amount` — integer or null; required. Minor units, as issued; null without orders:amounts minimum: -9007199254740991; maximum: 9007199254740991
    - `credits[].balance` — integer or null; required. What's left to use; null without orders:amounts minimum: -9007199254740991; maximum: 9007199254740991
    - `credits[].customerId` — string; required. 
    - `credits[].customerName` — string; required. First name only without customers:contact
    - `credits[].orderId` — string or null; required. 
    - `credits[].orderCode` — string or null; required. 
    - `credits[].sessionId` — string or null; required. 
    - `credits[].note` — string or null; required. Staff's own words; null without orders:amounts
    - `credits[].expiresAt` — string or null; required.  format: "date-time"
    - `credits[].createdAt` — string; required.  format: "date-time"
- `nextBefore` — string or null; required. 

### void_credit

Void a credit that hasn't been used: its code stops working and its whole amount is taken back, with `note` (staff's words, for the activity log; never shown to the guest). A credit given as a guest's refund (their booking's refund policy gives refunds as a credit, or a voucher's part of a refund) takes that refund back too, so the booking reads as not refunded that much: for when the card was also refunded in the payment provider (the refund_exceeded alert). A credit that has paid for anything, even in part, can't be voided. Needs refunds:create and orders:amounts where the credit's booking is. Can't be undone. Returns a preview to confirm.

Changes · Members of an organization · Needs refunds:create

#### Input

- `creditId` — string; required. The credit's id, from list_credits
- `note` — string; required. Why it's voided, in staff's words, for the activity log. Never shown to the guest minLength: 1; maxLength: 500

#### Output

- `id` — string; required. 
- `code` — string; required. What the guest quotes to use it. In full only to someone who may give a credit there (refunds:create and orders:amounts); masked (•••• and its last 4) otherwise, since whoever reads it can spend it
- `status` — string; required.  Allowed: "active", "voided", "expired"
- `reason` — string; required. session_moved, session_canceled: given instead of a refund when the session moved or was called off; service_recovery, goodwill: staff's own; gift_certificate_voided: Given because the gift certificate it was paid with had been cancelled; voucher_refunded: a refund reached what a third party's voucher paid, which can't be handed back, so that part is this credit (the refund's creditId); guest_change: the guest cancelled, removed seats, or moved to a cheaper date on their manage link, and the booking's refund policy gives refunds as credit, so what would have gone back to the card is this credit (the refunds' creditId) Allowed: "session\_moved", "session\_canceled", "service\_recovery", "goodwill", "gift\_certificate\_voided", "voucher\_refunded", "guest\_change"
- `entityId` — string; required. The entity it's a liability of
- `currency` — string; required. 
- `amount` — integer or null; required. Minor units, as issued; null without orders:amounts minimum: -9007199254740991; maximum: 9007199254740991
- `balance` — integer or null; required. What's left to use; null without orders:amounts minimum: -9007199254740991; maximum: 9007199254740991
- `customerId` — string; required. 
- `customerName` — string; required. First name only without customers:contact
- `orderId` — string or null; required. 
- `orderCode` — string or null; required. 
- `sessionId` — string or null; required. 
- `note` — string or null; required. Staff's own words; null without orders:amounts
- `expiresAt` — string or null; required.  format: "date-time"
- `createdAt` — string; required.  format: "date-time"
