Retrieve Square Gift Cards and Track Activity

Developers can use the Gift Cards API and Gift Card Activities API to get details about a gift card, view all gift cards for a seller account, track activity history, and get details about a particular activity.

Square provides the following endpoints to retrieve gift cards and activities:

  • RetrieveGiftCard - Retrieves a gift card using the gift card ID.
  • RetrieveGiftCardFromGAN - Retrieves a gift card using the gift card number (GAN).
  • RetrieveGiftCardFromNonce - Retrieves a gift cards using a payment token generated for the gift card by the Web Payments SDK or In-App Payments SDK.
  • ListGiftCards - Lists the gift cards in a seller account. You can use query parameters to filter the results. For example, use customer_id to list the gift cards on file for a customer.
  • ListGiftCardActivities - Lists activities for the gift cards in a seller account. You can use query parameters to filter the results. For example, use the gift_card_id query parameter to list the gift cards on file for a customer. Activities are actions that change the gift card balance or state.

You can also send Square GraphQL queries to get gift card data and use webhook events to keep track of changes.

Link to section

Retrieve a gift card

To get details about a particular gift card, such as the balance, ID, GAN, state, or GAN source, you can retrieve a gift card using:

Link to section

Retrieve a gift card by ID

To retrieve a gift card using its ID, call RetrieveGiftCard and provide the ID as a path parameter.

Retrieve gift card

Link to section

Retrieve a gift card by GAN

To retrieve a gift card using its GAN, call RetrieveGiftCardFromGAN and provide the GAN in the request body.

Retrieve gift card from GAN

Link to section

Retrieve a gift card by payment token

To retrieve a gift card using a payment token, call RetrieveGiftCardFromNonce and provide the payment token in the request body.

Retrieve gift card from nonce

When using the Web Payments SDK to take online payments or the In-App Payments SDK to take in-app payments, the SDK generates a secure payment token from the GAN entered by the buyer. Payment tokens are used to represent a payment source in a CreatePayment request.

Link to section

Response example

The RetrieveGiftCard, RetrieveGiftCardFromGAN, and RetrieveGiftCardFromNonce endpoints return a gift card in the response, as shown in the following example:

If the gift card is linked to at least one customer, the customer_ids field is present and lists the IDs of all linked customers. For more information, see Manage Square Gift Cards on File.

Link to section

List gift cards

To list the gift cards in a seller account, call ListGiftCards. You can optionally filter the request using the following query parameters:

  • type - Returns only the gift cards of the specified type, either DIGITAL or PHYSICAL.
  • state - Returns only the gift cards with the specified status, such as ACTIVE or PENDING.
  • customer_id - Returns only the gift cards that are linked with the specified customer. If you need to get the customer ID, you can search customer profiles by phone number, email address, or other supported attribute.

The following request uses the type query parameter to filter for DIGITAL gift cards and the limit query parameter to specify a maximum page size of three results. The default page size is 30 and the maximum is 200.

List gift cards

Link to section

ListGiftCards response

Results are sorted by created_at in ascending order (oldest to newest). The following is an example response for the previous request:

If the response is paged, the response includes a cursor field. To retrieve the next page of results, include the cursor query parameter in the next ListGiftCards call, as shown in the following example:

List gift cards

If no matching gift cards are found, the response contains an empty object:

{}
Link to section

List gift card activities

Activities represent actions that change the balance or state of a gift card. A gift card activity can be initiated by:

  • Sellers and buyers using a Square product. Sellers can use Square Point of Sale or the Square Dashboard to create and view gift card activities. Buyers can view and manage their gift cards from their Square profile.
  • Third-party applications calling CreateGiftCardActivity directly, creating a gift card payment using the Payments API or refunding a gift card payment using the Refunds API.
  • Square, which manages some activity types such as BLOCK and IMPORT.

To see the activity history for gift cards in a seller account, call ListGiftCardActivities. You can optionally filter the request using the following query parameters:

  • gift_card_id - Returns only the activities for the specified gift card. Square supports several methods to get the gift card ID if needed.
  • type - Returns only the activities of the specified type, such as ACTIVATE or REDEEM.
  • location_id - Returns only the activities that occurred at the specified location. If needed, call ListLocations to get a location ID.
  • begin_time and end_time - Returns only the activities that occurred in the specified range (inclusive). The begin_time timestamp defaults to one year prior to the current time and the end_time timestamp defaults to the current time.

The following request uses the gift_card_id query parameter to return activities for a particular gift card and the limit query parameter to specify a maximum page size of three results. The default page size is 50 and the maximum is 100.

List gift card activities

Link to section

ListGiftCardActivities response

By default, results are sorted by created_at in descending order (newest to oldest), but you can change to ascending order using the sort_order query parameter. The following is an example response for the previous request:

If the response is paged, the response includes a cursor field. To retrieve the next page of results, include the cursor query parameter in the next ListGiftCardActivities call, as shown in the following example:

List gift cards

If no matching activities are found, the response contains an empty object:

{}
Link to section

Checking a gift card balance

To find the balance of a gift card, retrieve the gift card and check the balance_money field. You can retrieve a gift card using:

A gift card's balance is represented by the balance_money field. The amount field is the monetary amount in the lowest denomination of the currency. The following gift card has a balance of $22.21 USD:

{ "gift_card": { "id": "gftc:01696eaf3d5141bfb4c786949EXAMPLE", "type": "DIGITAL", "gan_source": "SQUARE", "state": "ACTIVE", "balance_money": { "amount": 2221, "currency": "USD" }, "gan": "7783320005000000", "created_at": "2023-04-01T18:49:34Z" } }

A gift card balance can be zero or higher, up to the maximum allowed amount. A gift card balance cannot be negative.

Note

A gift card activity returned for a CreateGiftCardActivity or ListGiftCardActivities response contains a gift_card_balance_money field with a balance amount. Keep in mind that this is the balance at the time of the activity and might not represent the current balance.

Link to section

Getting a gift card ID

Some operations require a gift card ID, such as linking and unlinking customers with gift cards, listing activities for a specified gift card, and providing a gift card ID as a payment source. Depending on your use case and the information you have, there are several ways to get a gift card ID:

  • If you collect the GAN from the buyer, call RetrieveGiftCardFromGAN. Note that CreateGiftCardActivity requests accept either a gift card ID or GAN.
  • If you use the Web Payments SDK to take online payments or the In-App Payments SDK to take in-app payments, call RetrieveGiftCardFromNonce and provide the payment token generated by the SDK for the gift card payment.
  • If you just created or registered the gift card, check the ID from the corresponding CreateGiftCard or CreateGiftCardActivity response.
  • If the gift card is linked to a customer, call ListGiftCards with the customer_id query parameter to get the customer's gift cards on file. Otherwise, you can try filtering the request or parsing the response to find the target gift card.
  • If you have a payment (or an order tender) made using the gift card, call ListGiftCardActivities and filter by the timestamp of the payment. This method might return better results than calling ListGiftCards, as described in the following section.
Link to section

Getting a gift card ID using ListGiftCardActivities

When you need to retrieve a gift card but don't have the gift card ID, GAN, or payment token, you can call ListGiftCardActivities to find the ID. Depending on the information you have, this method might provide more conclusive results than calling ListGiftCards.

For example, suppose you have an order and you want to retrieve the gift card that was used for the payment. You can call ListGiftCardActivities and filter using information from the order, such as the created_at timestamp of the corresponding tender.

The following is an excerpt of an order that has one tender, which corresponds to the payment for the order. Note that tenders and payments don't include the gift card ID or full GAN.

When you call ListGiftCardActivities, you can use information from the order as query parameters. The following example request includes:

  • type set to REDEEM because paying with a gift card creates a REDEEM activity.
  • location_id set to the location of the corresponding tender.
  • begin_time and end_time set based on the created_at timestamp of the corresponding tender.

List gift card activities

The following example response contains two activities. To confirm that you find the specific activity, compare the payment_id and the last four characters of gift_card_gan in the activity to id and last_4 of the corresponding tender.

If you need additional gift card details, you can call RetrieveGiftCard using the gift_card_id.

Note

gift_card_balance_money represents the gift card balance at the time of the activity. It doesn't represent the current gift card balance.

Link to section

Viewing gift card reports in the Square Dashboard

The Reports section in the Square Dashboard includes the following gift card related reports:

  • Sales Summary report - Shows a summary of all activities that occurred using the Point of Sale application, Square Dashboard, and transactions made using the Orders API and Payments API. This report includes a section for gift card sales, but doesn't include redemptions.
  • Gift Cards report - Shows gift card specific activities.

When your application uses the Orders API and Payments API, these reports are Square-backed and accurately reflect the activities. For example:

  • When you redeem a gift card using the Payments API, Square automatically creates the corresponding REDEEM gift card activity.
  • When you activate a gift card and provide the ID of a Square order, Square reads the order and determines the amount to add to the card as the initial balance.

When an application uses a custom solution to create an order and process a payment, the activity doesn't appear in the Sales Summary report. Only the Gift Cards report tracks this activity.

The Gift Cards section in the Square Dashboard can be used for the following tasks:

  • View information about all gift cards, such as recent activation and redemption totals and the Last Used location and date for each card.
  • View the status and activity history for an individual gift card and clear the gift card balance. Orders that are processed with the Orders API provide a Receipt link that opens the transaction details. You can search for a gift card by entering the full GAN in the Search by Gift Card Number box.
  • Manage your gift card settings on the Settings page.

The Customers section in the Square Dashboard can be used for the following tasks:

  • View the gift cards that are linked to a customer. When you select a customer profile, the Cards on File tile in the details pane shows credit cards and gift cards on file.
  • View the activity history of a linked gift card.
Link to section

See also