> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gate.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 批量查询礼品卡

> 根据礼品卡批次号或创建时间范围分页查询当前商户创建的礼品卡。批次号与时间范围同时传入时取交集。

## 概述

本页说明 `POST /v1/pay/gift/batch/query` 接口。完整的请求参数、响应结构与示例由上方关联的 OpenAPI 定义渲染。

## 说明

* 认证方式使用 GatePay 标准签名请求头。
* 支持按批次号、创建时间范围或两者组合过滤；同时传入时取交集。
* 通用签名规则请参见 [/global/api-reference/version/100/cn/common/securityAndSignature](/global/api-reference/version/100/cn/common/securityAndSignature)。


## OpenAPI

````yaml global/api-reference/version/100/cn/openapi/gift-card-openapi.json POST /v1/pay/gift/batch/query
openapi: 3.1.0
info:
  title: GatePay 礼品卡 API
  description: Gate Pay 礼品卡 API 解决方案，用于礼品卡的即时创建和价值检查。
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://openplatform.gateapi.io
security: []
paths:
  /v1/pay/gift/batch/query:
    post:
      summary: 批量查询礼品卡
      description: 根据礼品卡批次号或创建时间范围分页查询当前商户创建的礼品卡。批次号与时间范围同时传入时取交集。
      parameters:
        - $ref: '#/components/parameters/X-GatePay-Certificate-ClientId'
        - $ref: '#/components/parameters/X-GatePay-Signature'
        - $ref: '#/components/parameters/X-GatePay-Timestamp'
        - $ref: '#/components/parameters/X-GatePay-Nonce'
      requestBody:
        description: 批量查询请求参数。batch_id 或完整的 start_time/end_time 时间范围至少传一个。
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GiftCardBatchQueryRequestCn'
            examples:
              batchAndTimeExample:
                summary: 按批次号和创建时间范围查询
                value:
                  batch_id: G545273793309741056
                  start_time: 1791916618083
                  end_time: 1791939618083
                  page: 1
                  page_size: 20
        required: true
      responses:
        '200':
          description: 查询成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GiftCardBatchQueryResponseCn'
              examples:
                successResponse:
                  summary: 成功响应
                  value:
                    status: SUCCESS
                    code: '000000'
                    errorMessage: ''
                    data:
                      total: 1
                      has_more: false
                      list:
                        - batch_id: G545273793309741056
                          card_num: '5607423016280059'
                          key: EXAMPLE-REDEEM-CODE
                          title: Festival Gift Card
                          creator_name: GateUser-8118f6f8
                          amount: '0.99'
                          status: '3'
                          currency: USDT
                          card_temp_id: '346749173549240320'
                          create_time: 1791920000000
                          exchange_uid: 39992131
                          exchange_time: 1791923600000
components:
  parameters:
    X-GatePay-Certificate-ClientId:
      name: X-GatePay-Certificate-ClientId
      in: header
      required: true
      description: 商户客户端ID
      schema:
        type: string
        example: mZ96D37oKk-HrWJc
    X-GatePay-Signature:
      name: X-GatePay-Signature
      in: header
      required: true
      description: 签名
      schema:
        type: string
        example: >-
          b8c4705ff4c1357f2a27925dd180c1e1f4a244148f312a2dee5afbcc6f4b150e9ffceee455c5a298f895d43a64ee829eebdfd262539d45c41f7aee4336fd8c8c
    X-GatePay-Timestamp:
      name: X-GatePay-Timestamp
      in: header
      required: true
      description: 毫秒级时间戳，与服务端时间偏差不得超过30秒
      schema:
        type: string
        example: '1738934053475'
    X-GatePay-Nonce:
      name: X-GatePay-Nonce
      in: header
      required: true
      description: 随机数
      schema:
        type: string
        example: '5417061546'
  schemas:
    GiftCardBatchQueryRequestCn:
      type: object
      description: batch_id 或完整的 start_time/end_time 时间范围至少传一个。
      dependentRequired:
        start_time:
          - end_time
        end_time:
          - start_time
      anyOf:
        - required:
            - batch_id
        - required:
            - start_time
            - end_time
      properties:
        batch_id:
          type: string
          minLength: 1
          maxLength: 64
          description: 礼品卡批次号。传入后按批次精确过滤；与时间范围同时传入时取交集。
          example: G545273793309741056
        start_time:
          type: integer
          format: int64
          minimum: 0
          description: 创建时间范围起点，毫秒级 Unix 时间戳，闭区间。必须与 end_time 成对传入。
          example: 1791916618083
        end_time:
          type: integer
          format: int64
          minimum: 0
          description: 创建时间范围终点，毫秒级 Unix 时间戳，闭区间。单次查询跨度不得超过 31 天。
          example: 1791939618083
        page:
          type: integer
          minimum: 1
          default: 1
          description: 页码，从 1 开始。
          example: 1
        page_size:
          type: integer
          minimum: 1
          maximum: 100
          default: 20
          description: 每页条数，默认 20，最大 100。
          example: 20
    GiftCardBatchQueryResponseCn:
      type: object
      properties:
        status:
          type: string
          description: 响应状态
          example: SUCCESS
        code:
          type: string
          description: 响应码，000000 表示成功
          example: '000000'
        errorMessage:
          type: string
          description: 错误信息，成功时为空
          example: ''
        data:
          $ref: '#/components/schemas/GiftCardBatchQueryDataCn'
    GiftCardBatchQueryDataCn:
      type: object
      properties:
        total:
          type: integer
          format: int64
          description: 满足条件的记录总数
          example: 1
        has_more:
          type: boolean
          description: 是否还有下一页。为 true 时可继续使用 page+1 查询。
          example: false
        list:
          type: array
          description: 当前页礼品卡列表
          items:
            $ref: '#/components/schemas/GiftCardBatchQueryItemCn'
    GiftCardBatchQueryItemCn:
      type: object
      properties:
        batch_id:
          type: string
          description: 礼品卡批次号
          example: G545273793309741056
        card_num:
          type: string
          description: 礼品卡卡号
          example: '5607423016280059'
        key:
          type: string
          description: 兑换码
          example: EXAMPLE-REDEEM-CODE
        title:
          type: string
          description: 主题
          example: Festival Gift Card
        creator_name:
          type: string
          description: 礼品卡创建人名字
          example: GateUser-8118f6f8
        amount:
          type: string
          description: 礼品卡金额
          example: '0.99'
        status:
          type: string
          description: 礼品卡状态：0=未知状态，1=待支付，2=未兑换，3=已兑换，4=冻结，5=支付失败，6=人工审核，7=审核驳回，8=审核支付失败
          enum:
            - '0'
            - '1'
            - '2'
            - '3'
            - '4'
            - '5'
            - '6'
            - '7'
            - '8'
          example: '3'
        currency:
          type: string
          description: 礼品卡币种
          example: USDT
        card_temp_id:
          type: string
          description: 礼品卡封面 ID
          example: '346749173549240320'
        create_time:
          type: integer
          format: int64
          description: 创建时间（毫秒时间戳）
          example: 1791920000000
        exchange_uid:
          type: integer
          format: int64
          description: 兑换人 ID
          example: 39992131
        exchange_time:
          type: integer
          format: int64
          nullable: true
          description: 兑换时间（毫秒时间戳）；未兑换时为空。
          example: 1791923600000

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.