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

# Get subscription by ID

> Returns complete details of a subscription, including charge history.



## OpenAPI

````yaml /api-reference/openapi.yaml get /v1/subscriptions/{id}
openapi: 3.0.0
info:
  title: FastPay API
  version: 1.0.0
  description: >-
    API for creating and managing payment charges.


    ## Authentication


    This API uses **Basic Authentication** for direct API access, such as
    creating charges.

    Use your API key as the username and an empty string as password.

    The header should be formatted as:


    `Authorization: Basic {base64(apiKey:)}`.


    For example:


    ```

    Authorization: Basic YWxleG91dG9uOiIi

    ```


    ## Webhooks


    FastPay sends webhooks to notify your application about charge status
    changes in real-time.

    Webhooks are sent via HTTP POST requests to your configured webhook
    endpoints.


    ### Webhook Events


    The following webhook events are available for charges:


    - `charge.created` - Sent when a new charge is created

    - `charge.pending` - Sent when a charge is pending payment

    - `charge.paid` - Sent when a charge is successfully paid

    - `charge.updated` - Sent when a charge is updated


    ### Webhook Payload Structure


    All webhook payloads follow this structure:


    ```json

    {
      "id": "webhook_event_id",
      "event": "charge.paid",
      "data": {
        // Complete charge object
      }
    }

    ```


    ### Webhook Delivery


    - Webhooks are sent via HTTP POST requests

    - Content-Type: `application/json`

    - Retry logic is implemented for failed deliveries

    - Webhook events are stored in the database for audit purposes

    - Delivery logs are maintained for debugging and monitoring


    ### Webhook Security


    - Webhooks are sent to pre-configured endpoints

    - Endpoints can be enabled/disabled per merchant

    - Event filtering is supported (only receive specific events)

    - Failed deliveries are retried with exponential backoff
servers:
  - url: https://api-global.fastpaybrasil.com
    description: Produção e Sandbox (diferenciados pela API key)
security: []
paths:
  /v1/subscriptions/{id}:
    get:
      tags:
        - Subscriptions
      summary: Get subscription by ID
      description: Returns complete details of a subscription, including charge history.
      parameters:
        - name: id
          in: path
          required: true
          description: Unique subscription identifier
          schema:
            type: string
          example: 2RhQg9M7ZCg3X3nMb9W1kX8Q
      responses:
        '200':
          description: Successfully retrieved subscription
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubscriptionDetail'
        '401':
          description: Unauthorized - invalid credentials
          content:
            application/json:
              schema:
                type: object
                properties:
                  statusCode:
                    type: integer
                    example: 401
                  message:
                    type: string
                    example: Unauthorized
        '404':
          description: Subscription not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  statusCode:
                    type: integer
                    example: 404
                  message:
                    type: string
                    example: Subscription not found
      security:
        - basic: []
components:
  schemas:
    SubscriptionDetail:
      type: object
      properties:
        id:
          type: string
          description: Unique subscription identifier
          example: 2RhQg9M7ZCg3X3nMb9W1kX8Q
        status:
          type: string
          enum:
            - pending_activation
            - pending_card_activation
            - active
            - cancelled
            - paused
            - expired
          description: Subscription status
          example: active
        currentPeriodStart:
          type: string
          format: date-time
          nullable: true
          description: Current billing period start
          example: '2024-01-15T10:30:00.000Z'
        currentPeriodEnd:
          type: string
          format: date-time
          nullable: true
          description: Current billing period end
          example: '2024-02-15T10:30:00.000Z'
        billingDay:
          type: integer
          description: Billing day of the month
          example: 15
        cancelledAt:
          type: string
          format: date-time
          nullable: true
          description: Cancellation timestamp
          example: null
        cancellationType:
          type: string
          enum:
            - regret
            - regular
          nullable: true
          description: Type of cancellation
          example: null
        refunded:
          type: boolean
          description: Whether the subscription was refunded
          example: false
        createdAt:
          type: string
          format: date-time
          description: Creation timestamp
          example: '2024-01-15T10:30:00.000Z'
        updatedAt:
          type: string
          format: date-time
          description: Last update timestamp
          example: '2024-01-15T10:30:00.000Z'
        plan:
          type: object
          properties:
            id:
              type: string
              description: Plan ID
              example: 2RhQg9M7ZCg3X3nMb9W1kX8Q
            name:
              type: string
              description: Plan name
              example: Plano Premium Mensal
            price:
              type: number
              description: Plan price
              example: 99.9
            currency:
              type: string
              description: Currency code
              example: BRL
            recurrenceType:
              type: string
              description: Recurrence type
              example: monthly
        customer:
          type: object
          properties:
            id:
              type: string
              description: Customer ID
              example: 2RhQg9M7ZCg3X3nMb9W1kX8Q
            name:
              type: string
              description: Customer name
              example: John Doe
            email:
              type: string
              description: Customer email
              example: john@example.com
        merchant:
          type: object
          properties:
            id:
              type: string
              description: Merchant ID
              example: 2RhQg9M7ZCg3X3nMb9W1kX8Q
            tradeName:
              type: string
              description: Merchant trade name
              example: Loja Exemplo
        charges:
          type: array
          description: Charge history
          items:
            $ref: '#/components/schemas/SubscriptionChargeItem'
        metadata:
          type: object
          nullable: true
          description: Additional metadata
          example:
            referralCode: PROMO2024
    SubscriptionChargeItem:
      type: object
      properties:
        id:
          type: string
          description: Charge ID
          example: 2RhQg9M7ZCg3X3nMb9W1kX8Q
        billingCycle:
          type: integer
          description: Billing cycle number
          example: 1
        billingPeriodStart:
          type: string
          format: date-time
          description: Billing period start
          example: '2024-01-15T10:30:00.000Z'
        billingPeriodEnd:
          type: string
          format: date-time
          description: Billing period end
          example: '2024-02-15T10:30:00.000Z'
        amount:
          type: number
          description: Charge amount
          example: 99.9
        currency:
          type: string
          description: Currency code
          example: BRL
        status:
          type: string
          enum:
            - pending
            - paid
            - failed
            - refunded
            - skipped
          description: Charge status
          example: paid
        pspTransactionId:
          type: string
          nullable: true
          description: PSP transaction ID
          example: '12345'
        failureReason:
          type: string
          nullable: true
          description: Failure reason if applicable
          example: null
        createdAt:
          type: string
          format: date-time
          description: Charge creation timestamp
          example: '2024-01-15T10:30:00.000Z'
  securitySchemes:
    basic:
      type: http
      scheme: basic
      description: |-
        HTTP Basic authentication. Use your secret key as the
        username and an empty string as password. The API key
        should be base64 encoded in the format 'username:' when
        sending the Authorization header.

````