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

# Create Subscription

> Create a new Subscription for a User.
    User must have a valid customer ID of Payment Provider set.
    Requires billing details with at least a country code and postal code if country is one of US, CA, UA, IN.
    
    Note: User must have a valid customer ID of Payment Provider set and this customer must have a valid default payment method set (Payment Provider dashboard).



## OpenAPI

````yaml /api-reference/api-docs.yaml post /v0/subscriptions/create
openapi: 3.1.0
info:
  title: Fungies API v0
  version: 0.3.5
servers:
  - url: https://api.fungies.io
security: []
tags:
  - name: discounts
    description: Discounts related endpoints
  - name: keys
    description: Offer product keys related endpoints
  - name: orders
    description: Orders related endpoints
  - name: payments
    description: Payments related endpoints
  - name: offers
    description: Offers related endpoints
  - name: products
    description: Products related endpoints
  - name: subscriptions
    description: Subscriptions related endpoints
  - name: users
    description: Users related endpoints
  - name: variants
    description: Product variants related endpoints
  - name: plans
    description: Product plans related endpoints
  - name: elements
    description: Elements related endpoints
paths:
  /v0/subscriptions/create:
    post:
      tags:
        - subscriptions
      summary: Create Subscription
      description: |-
        Create a new Subscription for a User.
            User must have a valid customer ID of Payment Provider set.
            Requires billing details with at least a country code and postal code if country is one of US, CA, UA, IN.
            
            Note: User must have a valid customer ID of Payment Provider set and this customer must have a valid default payment method set (Payment Provider dashboard).
      operationId: PostV0SubscriptionsCreate
      requestBody:
        description: POST /v0/subscriptions/create Request body
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PostV0SubscriptionsCreateRequestBody'
      responses:
        '200':
          description: POST /v0/subscriptions/create Positive response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostV0SubscriptionsCreatePositiveResponse'
        '400':
          description: POST /v0/subscriptions/create Negative response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostV0SubscriptionsCreateNegativeResponse'
              examples:
                example1:
                  value:
                    status: error
                    error:
                      message: Sample error message
      security:
        - APIKEY_1: []
          APIKEY_2: []
components:
  schemas:
    PostV0SubscriptionsCreateRequestBody:
      type: object
      properties:
        userId:
          type: string
          format: uuid
        userEmail:
          type: string
          format: email
        backdateStartDate:
          type:
            - integer
            - 'null'
          format: int64
          minimum: 0
          maximum: 9007199254740991
        billingCycleAnchor:
          type:
            - integer
            - 'null'
          format: int64
          minimum: 0
          maximum: 9007199254740991
        trialEnd:
          type:
            - integer
            - 'null'
          format: int64
          minimum: 0
          maximum: 9007199254740991
        skipTrial:
          type: boolean
          default: false
        skipNotifications:
          type: boolean
          default: false
        items:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
                description: >-
                  Name of the Item. Required if Offer ID is not provided. Can be
                  used to override the Offer name.
                examples:
                  - Premium Plan
              unitPrice:
                type: integer
                format: int64
                exclusiveMinimum: 100
                maximum: 9007199254740991
                description: >-
                  New unit price in cents (min: 100). Required if Offer ID is
                  not provided. Can be used to override the Offer price.
                examples:
                  - 10000
              currency:
                type: string
                enum:
                  - AFN
                  - ALL
                  - DZD
                  - AOA
                  - ARS
                  - AMD
                  - AWG
                  - AUD
                  - AZN
                  - BSD
                  - BDT
                  - BBD
                  - BZD
                  - BMD
                  - BOB
                  - BAM
                  - BWP
                  - BRL
                  - BHD
                  - GBP
                  - BND
                  - BGN
                  - BIF
                  - BYN
                  - KHR
                  - CAD
                  - CVE
                  - KYD
                  - KWD
                  - XAF
                  - XPF
                  - CLP
                  - CNY
                  - COP
                  - KMF
                  - CDF
                  - CRC
                  - HRK
                  - CZK
                  - DKK
                  - DJF
                  - DOP
                  - XCD
                  - EGP
                  - ETB
                  - EUR
                  - FKP
                  - FJD
                  - GMD
                  - GEL
                  - GIP
                  - GTQ
                  - GNF
                  - GYD
                  - HTG
                  - HNL
                  - HKD
                  - HUF
                  - ISK
                  - INR
                  - IDR
                  - ILS
                  - JMD
                  - JPY
                  - JOD
                  - KZT
                  - KES
                  - KGS
                  - LAK
                  - LBP
                  - LSL
                  - LRD
                  - MOP
                  - MKD
                  - MGA
                  - MWK
                  - MYR
                  - MVR
                  - MRO
                  - MUR
                  - MXN
                  - MDL
                  - MNT
                  - MAD
                  - MZN
                  - MMK
                  - NAD
                  - NPR
                  - ANG
                  - TWD
                  - NZD
                  - NIO
                  - NGN
                  - NOK
                  - OMR
                  - PKR
                  - PAB
                  - PGK
                  - PYG
                  - PEN
                  - PHP
                  - PLN
                  - QAR
                  - RON
                  - RUB
                  - RWF
                  - SHP
                  - SVC
                  - WST
                  - STD
                  - SAR
                  - RSD
                  - SCR
                  - SLL
                  - SGD
                  - SBD
                  - SOS
                  - ZAR
                  - KRW
                  - LKR
                  - SRD
                  - SZL
                  - SEK
                  - CHF
                  - TJS
                  - TZS
                  - THB
                  - TND
                  - TOP
                  - TTD
                  - TRY
                  - UGX
                  - UAH
                  - AED
                  - UYU
                  - USD
                  - UZS
                  - VUV
                  - VEF
                  - VND
                  - XOF
                  - YER
                  - ZMW
                  - SLE
                  - XCG
                  - SSP
                  - VES
                  - MRU
                  - STN
                  - VED
                description: >-
                  Valid currency code. Required if value is provided. Required
                  if Offer ID is not provided. Can be used to override the Offer
                  currency.
                          
                          Note: Currently needs to match Workspace currency.
                examples:
                  - USD
              quantity:
                type: number
                format: double
                minimum: 1
                maximum: 1.7976931348623157e+308
                default: 1
                description: 'Optional quantity (default: 1).'
                examples:
                  - 1
              offerId:
                type: string
                format: uuid
                description: |-
                  Optional valid Offer ID. Adds Offer reference to the Item. 
                        
                        Note: name, value and currency are derived from the Offer if not provided.
                        - name: Offer name with full specification
                        - value: Offer price
                        - currency: Offer currency
                examples:
                  - 123e4567-e89b-12d3-a456-426614174000
              price:
                type: number
                format: double
                minimum: 100
                maximum: 1.7976931348623157e+308
                description: Deprecated. Use value instead.
              value:
                type: number
                format: double
                minimum: 100
                maximum: 1.7976931348623157e+308
                description: Deprecated. Use unitPrice instead.
          minItems: 1
          maxItems: 1
      required:
        - items
    PostV0SubscriptionsCreatePositiveResponse:
      type: object
      properties:
        status:
          type: string
          const: success
        data:
          type: object
          properties:
            subscription:
              type: object
              properties:
                object:
                  type: string
                  enum:
                    - subscription
                  default: subscription
                  description: >-
                    Object type identifier. Always 'subscription' for
                    subscription objects.
                id:
                  type: string
                  pattern: ^#?([0-9A-Za-z]{12,32}|[0-9]+)(-[0-9]+)?$
                  description: Subscription identifier (based on initial order number).
                status:
                  type: string
                  enum:
                    - all
                    - active
                    - canceled
                    - incomplete
                    - incomplete_expired
                    - past_due
                    - trialing
                    - paused
                    - unpaid
                  description: |-
                    Subscription status from payment provider:
                        - active: Subscription is active and billing
                        - past_due: Payment failed, retry in progress
                        - canceled: Subscription has been cancelled
                        - unpaid: Payment failed after all retries
                        - incomplete: Initial payment pending
                        - incomplete_expired: Initial payment expired
                        - trialing: In trial period
                        - paused: Subscription is paused
                createdAt:
                  type:
                    - integer
                    - 'null'
                  format: int64
                  minimum: 0
                  maximum: 9007199254740991
                currentIntervalEnd:
                  type:
                    - integer
                    - 'null'
                  format: int64
                  minimum: 0
                  maximum: 9007199254740991
                currentIntervalStart:
                  type:
                    - integer
                    - 'null'
                  format: int64
                  minimum: 0
                  maximum: 9007199254740991
                cancelAtIntervalEnd:
                  type: boolean
                  default: false
                canceledAt:
                  type:
                    - integer
                    - 'null'
                  format: int64
                  minimum: 0
                  maximum: 9007199254740991
                  default: null
                userId:
                  type:
                    - string
                    - 'null'
                  format: uuid
                  default: null
                user:
                  type:
                    - object
                    - 'null'
                  properties:
                    object:
                      type: string
                      enum:
                        - user
                      default: user
                      description: Object type identifier. Always 'user' for user objects.
                    id:
                      type: string
                      format: uuid
                      description: Unique identifier (UUID) for this user.
                    username:
                      type:
                        - string
                        - 'null'
                      default: null
                      description: Username of the user, if set.
                  required:
                    - id
                  default: null
                orderId:
                  type: string
                  format: uuid
                orderNumber:
                  type: string
                  pattern: ^#?([0-9A-Za-z]{12,32}|[0-9]+)(-[0-9]+)?$
                order:
                  type: object
                  properties:
                    object:
                      type: string
                      enum:
                        - order
                      default: order
                      description: >-
                        Object type identifier. Always 'order' for order
                        objects.
                    id:
                      type: string
                      format: uuid
                      description: Unique identifier (UUID) for this order.
                    number:
                      type: string
                      pattern: ^#?([0-9A-Za-z]{12,32}|[0-9]+)(-[0-9]+)?$
                      description: Human-readable order number.
                    status:
                      type: string
                      enum:
                        - PENDING
                        - PAID
                        - FAILED
                        - UNPAID
                        - CANCELLED
                        - REFUNDED
                        - PARTIALLY_REFUNDED
                        - EXPIRED
                      description: Current order status.
                  required:
                    - id
                    - number
                    - status
                lastPaymentId:
                  type:
                    - string
                    - 'null'
                  format: uuid
                  default: null
                lastPaymentNumber:
                  type:
                    - string
                    - 'null'
                  pattern: ^#?([0-9A-Za-z]{12,32}|[0-9]+)(-[0-9]+)?$
                  default: null
                lastPayment:
                  type:
                    - object
                    - 'null'
                  properties:
                    object:
                      type: string
                      enum:
                        - payment
                      default: payment
                      description: >-
                        Object type identifier. Always 'payment' for payment
                        objects.
                    id:
                      type: string
                      format: uuid
                      description: Unique identifier (UUID) for this payment.
                    type:
                      type: string
                      enum:
                        - one_time
                        - subscription_initial
                        - subscription_update
                        - subscription_interval
                        - subscription_extra
                        - claim_free
                      description: |-
                        Type of payment:
                            - one_time: Single purchase
                            - subscription_initial: First subscription payment
                            - subscription_update: Subscription modification payment
                            - subscription_interval: Recurring subscription payment
                            - subscription_extra: Additional subscription charge
                            - claim_free: Free product claim
                    number:
                      type: string
                      pattern: ^#?([0-9A-Za-z]{12,32}|[0-9]+)(-[0-9]+)?$
                      description: >-
                        Human-readable payment number (e.g., #ABC123DEF456).
                        Used for reference in invoices and support.
                    status:
                      type: string
                      enum:
                        - PENDING
                        - PAID
                        - FAILED
                        - UNPAID
                        - CANCELLED
                        - REFUNDED
                        - PARTIALLY_REFUNDED
                        - EXPIRED
                      description: |-
                        Current payment status:
                            - PENDING: Being processed
                            - PAID: Completed successfully
                            - FAILED: Payment failed
                            - UNPAID: Not yet attempted
                            - CANCELLED: Was cancelled
                            - REFUNDED: Fully refunded
                            - PARTIALLY_REFUNDED: Partially refunded
                            - EXPIRED: Expired before completion
                  required:
                    - id
                    - type
                    - number
                    - status
                  default: null
              required:
                - id
                - status
                - createdAt
                - currentIntervalEnd
                - currentIntervalStart
                - orderId
                - orderNumber
                - order
          required:
            - subscription
      required:
        - status
        - data
    PostV0SubscriptionsCreateNegativeResponse:
      type: object
      properties:
        status:
          type: string
          const: error
        error:
          type: object
          properties:
            message:
              type: string
          required:
            - message
      required:
        - status
        - error
  securitySchemes:
    APIKEY_1:
      type: apiKey
      in: header
      name: x-fngs-public-key
    APIKEY_2:
      type: apiKey
      in: header
      name: x-fngs-secret-key

````