Skip to main content

Overview

Gift cards are digital payment instruments that enable merchants to:
  • Create branded gift cards with custom cover designs
  • Issue cards with specified amounts and currencies
  • Track card status and redemption via the query API
  • Query merchant account currency balances (separate from any single card) when needed
For request headers, signature rules, and callback verification, refer to Authentication & Security.

API Reference

Create Gift Card

Endpoint: POST /v1/pay/gift/create Creates a new gift card with specified parameters. Responses use the standard status / code / label / errorMessage / data wrapper. On success, card fields such as card_num, card_key, and numeric status are inside data.

Request Parameters

Response Fields

Responses use the common wrapper: status, code, label, errorMessage, and data. On success, the gift card payload is in data:

Example Request

Example Response

If title is not a string, the request is rejected before a gift card is created and no business data is written:

Query Gift Card Cover Templates

Endpoint: GET /v1/pay/gift/temp/list Retrieves available cover templates for gift card customization.

Response Fields

Successful responses use the common wrapper; templates are returned in data as an array. Each item has:

Example Response

Query merchant account balances

Endpoint: GET /v1/pay/balance Returns balances for all currencies available on the current merchant account (account-level balances), not a single gift card. There are no query parameters; authentication headers apply as for other Pay APIs.

Response Fields

Example Response

Query Gift Card Details

Endpoint: POST /v1/pay/gift/query Retrieves gift card details by card number or redemption code. Send a JSON body (not query string). Provide card_number and/or key; if both are sent, key takes priority.

Request body

Response Fields (data)

Example Request

Example Response

Batch query gift cards

Endpoint: POST /v1/pay/gift/batch/query Returns a paginated list of gift cards created by the current merchant, filtered by batch ID or creation time range. When you provide both batch_id and a time range, the API returns records that match both filters.

Request body

Example request

Response fields (data)

Example response

Gift card status codes

The create and single-card query endpoints return status as an integer. The batch query endpoint returns list[].status as the string form of public status codes 0–8. It does not expose internal extension statuses 9–11; those values are returned as 0:

Callback Behavior

Gift cards do not provide asynchronous callbacks. Retrieve a single card’s status and details with POST /v1/pay/gift/query, or use POST /v1/pay/gift/batch/query to page through cards by batch or creation time. Use GET /v1/pay/balance when you need the merchant account’s multi-currency balances, not a per-card balance. For information on callback handling for other products, see Notification & Callbacks.

Error Handling

Common platform error codes and how to resolve them are listed below. When querying a gift card, an incorrect key or card number may return 5003000. For more error codes and best practices, see Error Codes & Best Practices.

Integration Guide

Minimum runnable path

For a first integration, validate the lifecycle of a single gift card first, then expand to batch issuance, campaign fulfillment, or membership-related use cases.

Basic Flow

  1. Retrieve available templates using GET /v1/pay/gift/temp/list
  2. Create a gift card using POST /v1/pay/gift/create with your chosen template
  3. Store the card details (card_num and card_key from the create response) securely
  4. Distribute the gift card to your customer
  5. Query one card’s details with POST /v1/pay/gift/query (body: card_number and/or key), or page through gift cards with POST /v1/pay/gift/batch/query. Use GET /v1/pay/balance only for merchant account currency balances

Best Practices

  • Store both card_num and card_key for lookups; the query API accepts card_number or key in the JSON body (if both are sent, key wins)
  • For batch queries, provide start_time and end_time together. When has_more is true, increment page to continue
  • Use Gift card status codes when branching, and handle the integer or string field type documented for each endpoint
  • Use card_temp_id from the template list as templateId when creating a card
  • GET /v1/pay/balance reflects merchant account funds by currency, not an individual gift card’s remaining value