# Balance

This function requests that a gift card's balance, masked card number, expiration date, and discount percentage be returned. Merchants may be required to pay a fee for an inquiry request depending on their processor agreement.
**Integration Methods:**
- Host Direct
- Locally Installed UTG
- Commerce Engine For On Premise
- Commerce Engine For Cloud

See the [Integration Methods](/guides/quickstart#integration-methods) and [URLs Section](/guides/quickstart#urls) sections of the Development Quick Start guide for details regarding each processing option.
See the [JSON Body Schemas](/guides/quickstart#json-body-schemas) for more details on the various JSON body formats.

Endpoint: POST /giftcards/balance
Version: 1.7.65
Security: AccessToken

## Header parameters:

  - `InterfaceVersion` (string, required)
    Refers to the version of the program or application that is sending requests to Shift4. The following special characters are not allowed&colon;  $ % &colon; ^ - ~ < > , ? “ ” ‘ ’ { } [ ] \ + =

  - `InterfaceName` (string, required)
    Refers to the name of the program or application that is sending requests to Shift4. This should be the name of the program that you purchased or created. The following special characters are not allowed&colon;  $ % &colon; ^ - ~ ` < > , ? “ ” ‘ ’ { } [ ] \ + =

  - `CompanyName` (string, required)
    Refers to the vendor or partner that designed and certified the interface. The information you use in this field should match what Shift4 has on file or what was agreed upon in your Integration Plan. The following special characters are not allowed&colon;  $ % &colon; ^ - ~ ` < > , ? “ ” ‘ ’ { } [ ] \ + =

  - `AccessToken` (string, required)
    A security credential used to authenticate API requests and all [i4Go®](https://s4-myportal.s3.amazonaws.com/downloads/documentation/i4go/i4go%20technical%20reference%20guide.pdf) authorizeClient/preauthorizeClient requests. An Access Token is the alias for the merchant account and interface being used. The Access Token is required in all requests except an [Access Token Exchange](/apis/payments-platform-rest/openapi/credentials/accesstokenexchange) request, which generates an Access Token using an `authToken` and `clientGuid`.

## Request fields (application/json):

  - `dateTime` (string, required)
    The date and time in ISO 8601 format including the timezone offset (yyyy-mm-ddThh:mm:ss.nnn+hh:mm).
Must be sent as the local date/time of the merchant. For example, a request processed at a merchant in the Pacific time zone at 9:18am on April 15th 2021 would be sent as 2021-04-15T09:18:23.283-07:00
    Example: 2024-05-21T09:18:23.283-07:00

  - `card` (object, required)

  - `card.present` (string, required)
    **Conditional: Send in the initial authorization/sale request**
Indicates whether a card was present (‘Y’) or not (‘N’) at the time a transaction took place. This should be set appropriately in the initial authorization/sale request.  In subsequent requests, this field should be left blank or should not be sent.
**Note:** Subsequent request here does not apply to the secondary request for card on file type transactions or reuse of the same card. An example of a subsequent request would be a capture after an authorization. You would not include `card.present` in the capture, which is the subsequent request. Another example is when performing an incremental authorization where you perform an authorization, followed by an incremental authorization then a capture. The second authorization (incremental) and the capture are the subsequent requests where you would not include `card.present`.
    Enum: "Y", "N"

  - `device` (object)

  - `device.terminalId` (string)
    This field is optional and is for backwards compatibility with existing vendors that are used to processing via UTG controlled devices.
Since Commerce Engine is running directly on the payment device it does not require a `device.terminalId` to be specified.
    Example: 1742

  - `transaction` (object, required)

  - `transaction.invoice` (string, required)
    10-digit invoice number assigned by the interface to identify a transaction. An invoice number serves as a unique key that identifies a transaction within a batch in Shift4's Gateway.
**Note: For US and Canadian processing: Although the invoice number is sent as a JSON string it is a numeric value. No alpha characters are allowed.**
**For processing outside of the US and Canada alpha characters are allowed.**
    Example: 0510093358

  - `apiOptions` (array)
    API Options modify the request being made.
| Value | Description |
|  --- | --- |
| RETURNHIST | Return the gift card usage history in the `history` array. |
    Example: ["RETURNHIST"]

  - `ui` (object)

  - `ui.language` (string)
    ISO 639-1 2-letter language code specifying the UI display language for the transaction (e.g. "en", "fr", "de"). When provided, overrides the device's configured default language for the duration of the session. Value persists across transactions until a new value is passed. Send default to reset the device back to its default language.
    Example: en

  - `ui.mode` (string)
    Set the UI to light mode by sending `light` or dark mode by sending `dark`
    Enum: "light", "dark"

  - `ui.suppressFinalResult` (boolean)
    When `true`, the terminal suppresses the final transaction result screen.
    Example: true

  - `p2pe` (object, required)

  - `p2pe.data` (string, required)
    The full output of a P2PE keypad/magnetic swipe reader (MSR).
    Example: 027101801F2D1E00939B%*432100******1119^VS/DUAL TRACK^2212******?*;432100******1119=2212******?*CECE3FCE7781142BEC8D0E267AE89F5D3C7E235BF1A70E637951E8D93003E5A2586C336CA4A3B31F6639B04005BB12A716D8BC4D3…

  - `p2pe.format` (string, required)
    Classifies the type of payment device being used for P2PE.
| Value | Description |
|  --- | --- |
| 01 | IDTech Enhanced Encryption format (Keyboard Mode) |
| 02 | IDTech Enhanced Encryption format (USB HID Mode) |
    Enum: "01", "02"

  - `p2pe` (object, required)
    See [P2PE Format 05 TDES DUKPT](/guides/core-concepts/p2pe-format#tdes-dukpt---format-05) for more information.

  - `p2pe.format` (string, required)
    Classifies the type of payment device being used for P2PE.
| Value | Description |
|  --- | --- |
| 05 | [Shift4 TDES DUKPT format](/guides/core-concepts/p2pe-format#tdes-dukpt---format-05) |
    Enum: "05"

  - `p2pe.ksn` (string, required)
    The key serial number which was used to encrypt the P2PE data.
    Example: 6299495001100E200041

  - `p2pe` (object, required)
    See [P2PE Format 03 Ingenico On-Guard SDE](/guides/core-concepts/p2pe-format#ingenico-on-guard-sde---format-03) for more information.

  - `p2pe.data` (string, required)
    Track information encrypted with AES 256 DUKPT. Contains the following information, separated by colons:
| Value | Description |
|  --- | --- |
| ksn | The key serial number (24 byte hex) |
| track indicator | `1` = track 1 only`2` = track 2 only`3` = manual entry`4` = dual track |
| length | The length of the encrypted data |
| encrypted data | Encrypted track/manual entry data |

Dual Track Example: `FFFF495A0000000200000005:4:0128:F48C880DE0DAF549E642C5CC25E65ADF9947E7EB0636DB80C4A490B4C0930AEF64B7201505343CED533A2AE9AFABFE6453875F705519A8109362197CA3BD8DA0FE90DB3F954B9CDA0DB58BDA3330862ADD28CB31EFDA7C641575E33D395D8BFF72EBF0B1FF9630DB0EAB080FE8C9B2FAC28127CDC48CA9F7D532D5BDE4CCE270`
Manual entry Example: `FFFF495A0000000200000006:3:0032:E394820DB97AF927B9B5E05F356750BBF5DFCCB3BC18B87E8FC3C9BC596229E7`
    Example: FFFF495A0000000200000005:4:0128:F48C880DE0DAF549E642C5CC25E65ADF9947E7EB0636DB80C4A490B4C0930AEF64B7201505343CED533A2AE9AFABFE6453875F705519A8109362197CA3BD8DA0FE90DB3F954B9CDA0DB58BDA3330862ADD28CB31…

  - `p2pe.format` (string, required)
    Classifies the type of payment device being used for P2PE.
| Value | Description |
|  --- | --- |
| 03 | Ingenico Onguard SDE Format |
    Enum: "03"

## Response 200 fields (application/json):

  - `result` (array)

  - `result.dateTime` (string)
    The date and time in ISO 8601 format including the timezone offset (yyyy-mm-ddThh:mm:ss.nnn+hh:mm).
Must be sent as the local date/time of the merchant. For example, a request processed at a merchant in the Pacific time zone at 9:18am on April 15th 2021 would be sent as 2021-04-15T09:18:23.283-07:00
    Example: 2024-05-21T09:18:23.283-07:00

  - `result.card` (object)

  - `result.card.deactivationReason` (string)
    In a Gift Card [Deactivate](/apis/payments-platform-rest/openapi/gift-cards/deactivate) or [Cashout](/apis/payments-platform-rest/openapi/gift-cards/cashout) request, specifies the reason for deactivation. In a Gift Card redemption or inquiry response, specifies the reason for denial sent by the processor.
    Example: Lost or Stolen

  - `result.card.entryMode` (string)
    **Conditional: The Card Entry Mode should be sent in an initial request; in subsequent requests, it should be left blank or not sent. When using a Universal Transaction Gateway® (UTG®)-controlled PIN pad, this field should be left blank or not sent in a request; the UTG will capture the card entry mode and return it in the response. When P2PE data is being sent from a non-UTG controlled device, this field is not needed**
The method used to capture a payment card in an authorization/sale request.
| Value | Description |
|  --- | --- |
| 1 | Track 1 Only or Dual Track (Track 1 & 2) |
| 2 | Track 2 Only |
| C | EMV Contactless via card or mobile wallet |
| E | EMV Chip |
| M | Manual Entry |
| Q | QR Code |
| R | Contactless MSD |
    Enum: "1", "2", "C", "E", "M", "Q", "R"

  - `result.card.expirationDate` (integer)
    **Conditional: Requires API Option "RETURNEXPDATE".**
Card expiration date in MMYY format. This value will only be populated if "RETURNEXPDATE" is included in the `apiOptions` array.
    Example: 1230

  - `result.card.number` (string)
    The card number field will always be masked when returned in a response.
    Example: XXXXXXXXXXXX8774

  - `result.card.present` (string)
    **Conditional: Send in the initial authorization/sale request**
Indicates whether a card was present (‘Y’) or not (‘N’) at the time a transaction took place. This should be set appropriately in the initial authorization/sale request.  In subsequent requests, this field should be left blank or should not be sent.
**Note:** Subsequent request here does not apply to the secondary request for card on file type transactions or reuse of the same card. An example of a subsequent request would be a capture after an authorization. You would not include `card.present` in the capture, which is the subsequent request. Another example is when performing an incremental authorization where you perform an authorization, followed by an incremental authorization then a capture. The second authorization (incremental) and the capture are the subsequent requests where you would not include `card.present`.
    Enum: "Y", "N"

  - `result.card.type` (string)
    An abbreviation used to specify the type of card that was used when processing a transaction.
| Value | Description |
|  --- | --- |
| GC | Gift Card |
| YC | IT’S YOUR CARD |
    Enum: "GC", "YC"

  - `result.card.balance` (object)

  - `result.card.balance.amount` (number)
    The balance remaining on the card.  Depending on which processor is being used, the balance may be returned for a gift card, debit card, EBT card, or other stored value card.
    Example: 24.33

  - `result.card.token` (object)

  - `result.card.token.value` (string)
    This field is used to specify a card token. Whenever CHD is sent in a request, a card token will be returned in this field. Your interface should be designed to store this card token for future use. The latest card token received should be used in any subsequent request that references the same card data.
    Example: 87743q5p3ffhv67y

  - `result.device` (object)

  - `result.device.terminalId` (string)
    To prompt a specific UTG-controlled PIN pad in a request, the API Terminal ID configured in UTG TuneUp must be specified in this field.
    Example: 1742

  - `result.merchant` (object)

  - `result.merchant.mid` (number)
    The merchant ID associated with the merchant account.
    Example: 15877

  - `result.merchant.name` (string)
    The merchant’s business name as configured with Shift4.
    Example: Merchant XYZ

  - `result.server` (object)

  - `result.server.name` (string)
    The name of the server that processed the request.
    Example: TM01CE

  - `result.transaction` (object)

  - `result.transaction.authSource` (string)
    In a response, a code returned by the processor to indicate which host issued the response.
| Value | Description |
|  --- | --- |
| E | Engine (Online) |
| O | Offline |
| A | APM (Online) |
| F | Payment Platform (Online) |
    Enum: "E", "O", "A", "F"

  - `result.transaction.invoice` (string)
    10-digit invoice number assigned by the interface to identify a transaction. An invoice number serves as a unique key that identifies a transaction within a batch in Shift4's Gateway.
**Note: For US and Canadian processing: Although the invoice number is sent as a JSON string it is a numeric value. No alpha characters are allowed.**
**For processing outside of the US and Canada alpha characters are allowed.**
    Example: 0510093358

  - `result.transaction.responseCode` (string)
    Code indicating the Shift4 host response.
| Value | Description | Details |
|  --- | --- | --- |
| A | Approved | The transaction is approved. |
| C | Approved | The transaction is approved without requiring additional authorization because it is less than or equal to a ceiling amount. (The ceiling amount is the original authorization amount multiplied by the tolerance per the merchant’s settings with Shift4.) |
| D | Declined | The transaction is declined. Note: Shift4 automatically declines AVS/CSC failures if the [POSHANDLEAVSFAIL Api Option](/guides/appendices/api-options#poshandleavsfail) was not sent in the request. |
| e | [Error](/guides/appendices/error-codes) | There is an error condition. |
| f | [AVS or CSC failure](/guides/response-handling/understanding-avs-and-csc-verification) | An AVS or CSC failure has occurred (credit card only). Note: This value will only be returned if the [POSHANDLEAVSFAIL Api Option](/guides/appendices/api-options#poshandleavsfail) was sent in the request. |
| P | [Partial approval](/guides/advanced-concepts/partial-approval) | A partial approval has occurred.  Check `amount.total` for the approved amount. Note: If both the [ALLOWPARTIALAUTH](/guides/appendices/api-options#allowpartialauth) and [POSHANDLEAVSFAIL](/guides/appendices/api-options#poshandleavsfail) Api Options were sent in the request and the transaction is partially approved with an AVS or CSC failure, `P` is returned instead of `f`. The interface must check `avs.valid` and `card.securityCode.valid` to determine whether AVS or CSC verification failed and handle the failure itself. |
| R | Voice referral | The transaction requires a voice referral. |
| [blank] | Status is unknown | The approval status is unknown. |
| X | Expired card | There is an error condition due to the card being expired. |
| S | SCA Online PIN required | The contactless EMV transaction requires strong customer authentication to continue. The terminal must gather the online PIN if supported by the device form factor and CVM list then resubmit the transaction request. |
| I | SCA Interface switch required | The contactless EMV transaction requires strong customer authentication to continue. The terminal must look at the form factor indicator to determine if the transaction should be declined, switched to EMV contact or tapped again using CDCVM. |
| J | Soft decline after exemption request | Transaction was soft declined. Returned when requesting an exemption by sending `transaction.exemptionAction = 02` and the card issuer rejects the exemption. |
    Enum: "A", "C", "D", "e", "f", "P", "R", "X", "S", "I"

  - `result.universalToken` (object)

  - `result.universalToken.value` (string)
    An identifier for a card or payment account across all Shift4 merchants.
    Example: 97032276-5944-00000001-16985FD179D

  - `result.history` (array)
    Returned if `RETURNHIST` is sent in `apiOptions`.

  - `result.history.amount` (object)
    Object containing information regarding the amount being requested. The `total` field within the object is required and specifies the amount being requested.
Note: For merchants that are configured to allow multiple currencies, the amount fields can specify up to three decimal places. However, the number of decimal places can not exceed the number allowed for the specified currency. See the [Currency Codes](/guides/appendices/currency-codes) section for details.

  - `result.history.amount.total` (number, required)
    The amount being charged for a particular transaction. If other amount fields are sent, they must be included in the total amount. Amount cannot be zero.
    Example: 160

  - `result.history.transactionType` (string)
    The gift card transaction type
    Enum: "Sale", "Activate", "Allocate", "Deactivate", "Cashback", "Reactivate", "Reload", "Balance", "Cancel"

## Response 400 fields (application/json):

  - `result` (array)

  - `result.error` (object)

  - `result.error.code` (integer)
    Code indicating the type of error that occurred. Refer to the [Error Codes](/guides/appendices/error-codes) section of this document for more details.
**Note: This is currently only supported for European merchant processing.**
    Example: 64100

  - `result.error.severity` (string)
    Severity level of the error.
| Severity | Description |
|  --- | --- |
| Info | Action not required - Data input/formatting is incorrect |
| Error | Action may be required - Communication, timeout or network issue |
| Alert | Action required - System issue |
    Enum: "Info", "Error", "Alert"

  - `result.error.shortText` (string)
    Abbreviated error message that is always returned if an error condition exists
    Example: NOT IN CARDRANGE

  - `result.error.longText` (string)
    Extended error message that is returned if an error condition exists.
    Example: Card type not recognized

  - `result.error.primaryCode` (integer)
    Code indicating the type of error that occurred. Refer to the [Error Codes](/guides/appendices/error-codes) section of this document for more details.
    Example: 9842

  - `result.error.secondaryCode` (integer)
    This code supplements the code specified in the `error.primaryCode` field to provide additional information about the error that occurred.
    Example: 0

  - `result.server` (object)

  - `result.server.name` (string)
    The name of the server that processed the request.
    Example: TM01CE

## Response 504 fields (application/json):

  - `result` (array)

  - `result.error` (object)

  - `result.error.code` (integer)
    Code indicating the type of error that occurred. Refer to the [Error Codes](/guides/appendices/error-codes) section of this document for more details.
**Note: This is currently only supported for European merchant processing.**
    Example: 64100

  - `result.error.severity` (string)
    Severity level of the error.
| Severity | Description |
|  --- | --- |
| Info | Action not required - Data input/formatting is incorrect |
| Error | Action may be required - Communication, timeout or network issue |
| Alert | Action required - System issue |
    Enum: "Info", "Error", "Alert"

  - `result.error.shortText` (string)
    Abbreviated error message that is always returned if an error condition exists
    Example: NOT IN CARDRANGE

  - `result.error.longText` (string)
    Extended error message that is returned if an error condition exists.
    Example: Card type not recognized

  - `result.error.primaryCode` (integer)
    Code indicating the type of error that occurred. Refer to the [Error Codes](/guides/appendices/error-codes) section of this document for more details.
    Example: 9842

  - `result.error.secondaryCode` (integer)
    This code supplements the code specified in the `error.primaryCode` field to provide additional information about the error that occurred.
    Example: 0

  - `result.lighthouse` (object)

  - `result.lighthouse.data` (string)
    Base64 encoded JSON formatted data that will be returned from Lighthouse to be passed back to SkyTab. This data will contain variable information.
    Example: eyJwYXltZW50SWQiOiI4NWM0MWNhNy01NzVjLTQzNGUtODIyZi0xYzZlOTE0ZDAzODYiLCJyZW1haW5pbmdBbW91bnQiOjB9

  - `result.server` (object)

  - `result.server.name` (string)
    The name of the server that processed the request.
    Example: TM01CE

