> ## 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.

# Create a subscription plan

> Creates a new recurring subscription plan.



## OpenAPI

````yaml /api-reference/openapi.yaml post /v1/subscription-plans
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/subscription-plans:
    post:
      tags:
        - Subscription Plans
      summary: Create a subscription plan
      description: Creates a new recurring subscription plan.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NewSubscriptionPlan'
      responses:
        '201':
          description: Subscription plan successfully created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubscriptionPlan'
        '401':
          description: Unauthorized - invalid credentials
          content:
            application/json:
              schema:
                type: object
                properties:
                  statusCode:
                    type: integer
                    example: 401
                  message:
                    type: string
                    example: Unauthorized
        '403':
          description: Forbidden - insufficient permissions
          content:
            application/json:
              schema:
                type: object
                properties:
                  statusCode:
                    type: integer
                    example: 403
                  message:
                    type: string
                    example: Forbidden
      security:
        - basic: []
components:
  schemas:
    NewSubscriptionPlan:
      type: object
      required:
        - merchantId
        - name
        - price
        - currency
        - recurrenceType
      properties:
        merchantId:
          type: string
          description: Merchant ID
          example: 2RhQg9M7ZCg3X3nMb9W1kX8Q
        name:
          type: string
          description: Plan name
          example: Plano Premium Mensal
        price:
          type: number
          description: Price in currency units (e.g., 99.90 for R$99.90)
          example: 99.9
        currency:
          type: string
          description: ISO 4217 currency code
          example: BRL
        recurrenceType:
          type: string
          description: Recurrence type
          enum:
            - weekly
            - biweekly
            - monthly
            - custom
          example: monthly
        recurrenceInterval:
          type: integer
          description: >-
            Custom recurrence interval in months (required if recurrenceType is
            'custom')
          example: 3
        endDate:
          type: string
          format: date
          description: Plan end date (ISO 8601)
          example: '2025-12-31'
        buyerMessage:
          type: string
          description: Message displayed to buyer
          example: Bem-vindo ao Plano Premium!
        paymentMethods:
          type: array
          items:
            type: string
          description: Accepted payment methods
          example:
            - credit_card
        trial:
          type: object
          description: |-
            Optional trial period configuration. If provided, new subscribers
            will go through a trial before the first full billing cycle.
          required:
            - durationDays
            - isFree
          properties:
            durationDays:
              type: integer
              minimum: 1
              maximum: 365
              description: Duration of the trial period in days
              example: 14
            isFree:
              type: boolean
              description: Whether the trial is free. If false, `price` is required.
              example: true
            price:
              type: number
              description: >-
                Price charged during the trial period. Required when `isFree` is
                false.
              example: 9.9
        status:
          type: string
          enum:
            - active
            - inactive
          default: active
          description: Initial plan status
          example: active
    SubscriptionPlan:
      type: object
      properties:
        id:
          type: string
          description: Unique plan identifier
          example: 2RhQg9M7ZCg3X3nMb9W1kX8Q
        merchantId:
          type: string
          description: Merchant 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
          enum:
            - weekly
            - biweekly
            - monthly
            - custom
          example: monthly
        recurrenceInterval:
          type: integer
          nullable: true
          description: Custom recurrence interval in months
          example: null
        endDate:
          type: string
          format: date-time
          nullable: true
          description: Plan end date
          example: null
        buyerMessage:
          type: string
          nullable: true
          description: Message displayed to buyer
          example: Bem-vindo ao Plano Premium!
        paymentMethods:
          type: array
          items:
            type: string
          description: Accepted payment methods
          example:
            - credit_card
        imageUrl:
          type: string
          nullable: true
          description: Plan image URL
          example: https://storage.example.com/plans/image.png
        status:
          type: string
          enum:
            - active
            - inactive
          description: Plan status
          example: active
        activeSubscriptionsCount:
          type: integer
          description: Number of active subscriptions
          example: 150
        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'
  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.

````