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

# Get Subscription

export const entityType_0 = "subscription"

<Warning>
  **Anti-Polling Warning**: Avoid polling this endpoint; use webhooks for real-time {entityType_0} updates. See [Anti-Polling Policy](/developer-resources/rate-limits#quotas).
</Warning>


## OpenAPI

````yaml GET /subscription/get-subscription/{subscriptionId}
openapi: 3.0.1
info:
  title: xPay API Store
  description: ''
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.xpaycheckout.com
security:
  - basicAuth: []
paths:
  /subscription/get-subscription/{subscriptionId}:
    get:
      parameters:
        - name: subscriptionId
          in: path
          required: true
          schema:
            type: string
            example: sub_fooBOwYsaK50AEfK
          description: Unique identifier of the subscription
      responses:
        '200':
          description: Successful response with subscription details
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/get-subscription-response'
        '400':
          description: Invalid request, xSubscriptionId not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    get-subscription-response:
      type: object
      properties:
        subscriptionId:
          type: string
          description: Unique identifier of the subscription
          example: sub_fooBOwYsaK50AEfK
        interval:
          type: string
          description: The interval group between subscriptions.
          enum:
            - DAY
            - WEEK
            - MONTH
            - YEAR
          example: MONTH
        intervalCount:
          type: integer
          description: >-
            The number of intervals between subscription billings. For example,
            `interval = MONTH` and `intervalCount = 3` bills every 3 months.
          format: int64
          example: 2
        cycleCount:
          type: integer
          description: >-
            The number of billing cycles for which the subscription will renew
            before ending. The first cycle is included in this count.
          format: int64
          example: 2
        remainingCycleCount:
          type: integer
          description: The number of billing cycles remaining for the subscription.
          format: int64
          example: 2
        currency:
          type: string
          description: Three-letter currency code
          example: USD
        amount:
          type: integer
          description: The amount in lowest count unit (e.g., cents for USD)
          format: int64
          example: 100
        presentmentCurrency:
          type: string
          description: The currency that the customer paid in
          example: USD
        createdAt:
          type: string
          format: date-time
          description: Timestamp of when the subscription was created
          example: '2024-09-26T10:41:50.472+00:00'
        status:
          type: string
          description: >-
            The status of the subscription. Refer [subscription
            statuses](/products/subscription/subscription-statuses)
          example: CREATED
        upfrontAmount:
          type: integer
          format: int64
          description: >-
            The amount charged to the customer at the time the subscription was
            activated. This replaces the first billing cycle charge; regular
            billing resumes from the next cycle.
          example: 200
        trialPeriodCount:
          type: integer
          format: int64
          description: The number of trial periods before the first billing cycle.
          example: 7
        trialPeriodInterval:
          type: string
          description: The interval for the trial period.
          enum:
            - DAY
            - WEEK
            - MONTH
            - YEAR
          example: DAY
        metadata:
          type: object
          description: >-
            A collection of key-value pairs that can be attached to an object
            for storing additional structured information. This is useful for
            capturing custom data or context-specific attributes.


            Constraints:

            - Maximum of 50 key-value pairs allowed.

            - Each key must be no longer than 40 characters.

            - Each value must be a string and cannot exceed 500 characters.
          additionalProperties:
            type: string
          example:
            orderId: '12345'
            customerNote: Deliver after 5 PM
        updatePaymentMethodLink:
          type: string
          description: >-
            The URL to redirect the customer to the xPay payment gateway for
            updating the payment method. Available only for subscriptions in
            `TRIALING`, `ACTIVE`, or `UNPAID`  status.
          example: >-
            https://pay.xpaycheckout.com/subscription/update?subscription_id=sub_123
        paymentMetadata:
          $ref: '#/components/schemas/PaymentMetadataDTO'
          description: >-
            Payment metadata for the subscription, including the payment method
            and card details if applicable
    Error:
      required:
        - errorCode
        - errorDescription
      type: object
      properties:
        errorCode:
          type: string
          example: bad_request
        errorDescription:
          type: string
          example: Failed to read request
    PaymentMetadataDTO:
      type: object
      description: >-
        Payment metadata containing additional information about the payment
        attempt
      properties:
        paymentMethod:
          type: string
          description: >-
            The payment method used for this attempt. Refer to [supported
            payment
            methods](/get-started/payment-methods-supported#payment-method-enums)
            for a complete list of available payment methods.
          example: CARD
        cardMetadata:
          $ref: '#/components/schemas/CardMetadataDTO'
          description: Card-specific metadata (only present for card payments)
    CardMetadataDTO:
      type: object
      description: >-
        Card metadata containing additional information about the card used for
        payment
      properties:
        brand:
          type: string
          description: >-
            The brand of the card (e.g., `amex`, `diners`, `discover`, `jcb`,
            `mastercard`, `unionpay`, `visa`, `rupay`), among others
          example: visa
        country:
          type: string
          description: Country code of the card issuer
          example: US
        lastFourDigit:
          type: string
          description: Last 4 digits of the card number
          example: '4242'
        expiryMonth:
          type: integer
          format: int64
          description: Card expiration month
          example: 12
        expiryYear:
          type: integer
          format: int64
          description: Card expiration year
          example: 2028
        cardType:
          type: string
          description: Type of card funding, such as Credit or Debit
          enum:
            - CREDIT
            - DEBIT
            - PREPAID
            - UNKNOWN
          example: CREDIT
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic

````