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

# Create Subscription

> Create a subscription linked to a plan and customer

Creates a subscription for an existing customer based on a plan. The initial subscription creation generates a payment transaction which the customer completes to activate the subscription.


## OpenAPI

````yaml POST /subscriptions
openapi: 3.0.3
info:
  title: OraFi Merchant API
  description: Seamless crypto payments API for merchants
  version: 1.0.0
  contact:
    name: OraFi Support
    email: support@orafi.app
servers:
  - url: https://api.orafi.app/v1
    description: Production server
  - url: http://localhost:3000/v1
    description: Local development server
security: []
tags:
  - name: Paylinks
    description: Paylink management endpoints
  - name: Payments
    description: Payment creation and verification endpoints
  - name: Customers
    description: Customer management endpoints
  - name: Transactions
    description: Transaction retrieval and payout endpoints
  - name: Refunds
    description: Refund management endpoints
  - name: Webhooks
    description: Webhook registration and management
  - name: Profile
    description: Business profile settings
  - name: Settlements
    description: Settlement account management
  - name: Fiat
    description: Fiat-related endpoints
  - name: Business
    description: Business mode and settings
  - name: Notifications
    description: Notification preferences
  - name: Subscriptions
    description: Subscription plans and customer subscriptions
paths:
  /subscriptions:
    post:
      tags:
        - Subscriptions
      summary: Create a subscription for a customer
      description: Create a subscription linked to a plan and customer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSubscriptionRequest'
      responses:
        '201':
          description: Subscription created
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  message:
                    type: string
                    example: Subscription created
                  data:
                    type: object
                    properties:
                      checkoutUrl:
                        type: string
                        nullable: true
                      subscription:
                        allOf:
                          - $ref: '#/components/schemas/Subscription'
                          - type: object
                            properties:
                              plan:
                                $ref: '#/components/schemas/SubscriptionPlan'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
      security:
        - apiKey: []
components:
  schemas:
    CreateSubscriptionRequest:
      type: object
      properties:
        customerId:
          type: string
        planId:
          type: string
        network:
          description: Network for subscription payments
          type: string
          enum:
            - SUI
      required:
        - customerId
        - planId
        - network
    Subscription:
      type: object
      properties:
        id:
          description: Subscription unique identifier
          type: string
          example: sub_abc123
        customerId:
          description: Customer associated with subscription
          type: string
        planId:
          description: Plan associated with subscription
          type: string
        network:
          description: Network used for subscription payments
          type: string
          enum:
            - SUI
        status:
          description: Current subscription status
          type: string
          enum:
            - PENDING
            - ABANDONED
            - ACTIVE
            - CANCELLED
            - PAST_DUE
        startsAt:
          description: When the subscription starts
          type: string
          format: date-time
        endsAt:
          description: When the subscription ends
          type: string
          format: date-time
        canceledAt:
          description: When the subscription was canceled
          type: string
          format: date-time
        createdAt:
          description: When the subscription was created
          type: string
          format: date-time
        updatedAt:
          description: When the subscription was last updated
          type: string
          format: date-time
    SubscriptionPlan:
      type: object
      properties:
        id:
          description: Subscription plan unique identifier
          type: string
          example: plan_abc123
        name:
          description: Plan name
          type: string
          example: Basic Monthly
        duration:
          description: Duration of the plan
          type: string
          enum:
            - WEEKLY
            - MONTHLY
            - SIX_MONTHS
            - YEARLY
        amount:
          description: Plan amount
          type: number
          example: 9.99
        currency:
          description: Currency code for the plan amount
          type: string
          example: USDC
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
  responses:
    BadRequest:
      description: Bad request - Invalid input or validation error
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                example: false
              message:
                type: string
                example: Validation error message
    Unauthorized:
      description: Unauthorized - Missing or invalid API key
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                example: false
              message:
                type: string
                example: Unauthorized access
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: API key for merchant authentication required for most endpoints

````