# Query subscription details

> Query subscription information by contract ID and retrieve its billing, status, and token details.

```yaml
openapi: 3.1.0
info:
  title: Query subscription details
  version: 1.0.0
  description: Query subscription information by contract ID and retrieve its
    billing, status, and token details.
paths:
  /v1/txn/sub/detail:
    post:
      summary: Query subscription details
      description: Query subscription information by contract ID and retrieve its
        billing, status, and token details.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                merchantNo:
                  type: string
                  description: Merchant number assigned by Onerway. See
                    [Setup](/payments/get-started/setup#retrieve-your-credentials)
                    for how to obtain it.
                contractId:
                  type: string
                  description: Subscription contract number used to query one subscription detail.
                    This endpoint supports querying details by `contractId`; it
                    does not return a subscription list or aggregate summary.
                sign:
                  type: string
                  description: Request signature string. See [Request
                    signing](/payments/get-started/request-signing) for how to
                    generate it.
              required:
                - merchantNo
                - contractId
                - sign
            examples:
              query-subscription-details:
                summary: Query subscription details
                value:
                  contractId: sub_contract_demo_202606210001
                  merchantNo: replace_with_merchant_no
                  sign: "{{SIGN}}"
      responses:
        "200":
          description: Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  respCode:
                    type: string
                    description: "`20000` means the query request was processed successfully. Other
                      values are error codes. See [Response
                      codes](/payments/api-reference/response-codes)."
                  respMsg:
                    type: string
                    description: Human-readable message for the response code.
                  data:
                    type: object
                    properties:
                      contractId:
                        type: string
                        description: Subscription contract number identifying one subscription contract.
                      merchantNo:
                        type: string
                        description: Merchant number assigned by Onerway.
                      merchantCustomerId:
                        type: string
                        description: Customer identifier in the merchant system, used to associate this
                          subscription with the merchant customer record.
                      products:
                        type: string
                        description: Subscription product information list. The wire value is a JSON
                          string that parses to an array of product objects.
                        contentMediaType: application/json
                        contentSchema:
                          type: array
                          items:
                            type: object
                            properties:
                              currency:
                                type: string
                                description: Product currency as a three-letter [ISO
                                  4217](https://en.wikipedia.org/wiki/ISO_4217)
                                  currency code.
                              name:
                                type: string
                                description: Product name.
                              num:
                                type: string
                                description: Product quantity, transmitted as a string.
                              price:
                                type: string
                                description: Product unit price, transmitted as a string.
                              type:
                                type: string
                                description: Product type.
                                x-onerway-value:
                                  empty: true
                                  when:
                                    en: Can be an empty string when no product type is configured.
                                    zh: 未配置商品类型时可为空字符串。
                        x-onerway-format: json_string
                      orderAmount:
                        type: string
                        description: Charge amount for one billing cycle.
                      orderCurrency:
                        type: string
                        description: Charge currency for one billing cycle, as a three-letter [ISO
                          4217](https://en.wikipedia.org/wiki/ISO_4217) currency
                          code.
                      expireDate:
                        type: string
                        description: Subscription contract expiration date in `yyyy-MM-dd` format.
                      frequencyType:
                        type: string
                        description: Subscription billing-cycle unit.
                        enum:
                          - D
                          - M
                          - Y
                        x-enum-descriptions:
                          D: Bill by day.
                          M: Bill by month.
                          Y: Bill by year.
                      frequencyPoint:
                        type: number
                        description: Billing cycle length, in the unit specified by `frequencyType`.
                          Merchant-managed subscriptions (`selfExecute=2`) count
                          the cycle in days, so the value returned is the number
                          of days submitted in the initial subscription request;
                          Onerway does not use it to collect payments.
                      cycleCount:
                        type:
                          - number
                          - "null"
                        description: Total number of billing cycles in the subscription plan.
                        x-onerway-constraints:
                          - kind: range
                            min: 1
                            max: 99
                            text: When present, the value must be between `1` and `99`.
                        x-onerway-value:
                          nullable: true
                          when:
                            en: Returns a concrete cycle count when the subscription ends after a fixed
                              number of billing cycles; returns `null` when the
                              subscription was created without `cycleCount` and
                              ends by `expireDate`.
                            zh: 订阅按固定计费周期数结束时返回具体周期数；创建订阅时未传 `cycleCount` 且按 `expireDate` 结束时返回 `null`。
                      notificationEmail:
                        type:
                          - string
                          - "null"
                        description: Email address for subscription-related notifications.
                        x-onerway-value:
                          nullable: true
                          when:
                            en: Has a value only when a subscription notification email is configured.
                            zh: 订阅配置了通知邮箱时才有值；未配置时可为 `null`。
                      billingCycleAnchor:
                        type:
                          - string
                          - "null"
                        description: Next billing anchor time in `yyyy-MM-dd HH:mm:ss` format.
                        x-onerway-value:
                          nullable: true
                          when:
                            en: Active subscriptions normally return the next charge time. It can be `null`
                              when the next charge time is not determined.
                            zh: "`active` 订阅正常返回下一期扣款时间；下一期扣款时间未确定时可为 `null`。"
                      dataStatus:
                        type: string
                        description: Enablement status of the subscription contract.
                        enum:
                          - "0"
                          - "1"
                          - "2"
                          - "3"
                        x-enum-descriptions:
                          "0": Pending activation.
                          "1": Active.
                          "2": Inactive.
                          "3": Canceled.
                      subscriptionStatus:
                        type: string
                        description: Current lifecycle status of the subscription.
                        enum:
                          - trialing
                          - paymentdue
                          - active
                          - pastdue
                          - paused
                          - canceled
                          - ended
                        x-enum-descriptions:
                          trialing: Trial period before the paid subscription starts. Charging depends on
                            `trialFromPlan`.
                          paymentdue: Payment is due or processing; the subscription contract is not
                            active yet.
                          active: The subscription is active and all due payments have been paid.
                          pastdue: Payment is overdue; the current cycle has ended but the retry or
                            collection remains pending.
                          paused: The subscription is temporarily paused after all payment attempts for a
                            billing cycle failed; the contract stays enabled.
                          canceled: The subscription was canceled before the planned end.
                          ended: The subscription ended naturally by date or after all billing cycles
                            completed.
                      metaData:
                        type:
                          - string
                          - "null"
                        description: Merchant-defined custom metadata carried as a JSON string.
                        contentMediaType: application/json
                        contentSchema:
                          type: object
                          properties:
                            {}
                        x-onerway-value:
                          nullable: true
                          empty: true
                          when:
                            en: Has a value when custom metadata was provided during subscription creation
                              or update; it can be empty when no metadata is
                              configured.
                            zh: 订阅创建或更新时传入自定义数据时返回；未配置时可能为空。
                        x-onerway-format: json_string
                      createTime:
                        type: string
                        description: Initial subscription creation time in `yyyy-MM-dd HH:mm:ss` format.
                      tokenId:
                        type: string
                        description: Subscription token used for later charges.
                    description: Subscription query result object containing contract, customer,
                      product, billing-cycle, status, and token information.
```
