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

# Create a new plan

> Create a new plan with the provided details. Note: This endpoint is restricted for internal use only.



## OpenAPI

````yaml specs/billing_api_docs.json post /api/v1/plans
openapi: 3.0.1
info:
  title: Billing API
  description: Billing service for managing subscriptions, payments, and entitlements
  contact: {}
  version: '1.0'
servers:
  - url: https://dev-billing-api.iqraa.ai/api/v1
security: []
tags:
  - name: Customers
    description: Customers related endpoints
  - name: Subscriptions
    description: Subscription related endpoints
  - name: Plans
    description: Plans related endpoints
  - name: Entitlements
    description: Entitlements related endpoints
  - name: Payments
    description: Payments related endpoints
  - name: Emails
    description: Email related endpoints
paths:
  /api/v1/plans:
    post:
      tags:
        - Plans
      summary: Create a new plan
      description: >-
        Create a new plan with the provided details. Note: This endpoint is
        restricted for internal use only.
      operationId: PlansController_create
      parameters:
        - name: x-admin-api-key
          in: header
          description: The API key to access the admin API
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreatePlanDto'
      responses:
        '201':
          description: The plan has been successfully created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreatePlanDto'
        '400':
          description: >-
            Bad Request - Invalid plan data, unsupported currency, or duplicate
            plan code/amount
        '401':
          description: Unauthorized - Missing or invalid admin API key
components:
  schemas:
    CreatePlanDto:
      type: object
      properties:
        name:
          type: string
          example: Premium Plan
        code:
          type: string
          example: iqraa_starter_monthly
          description: Unique code for the plan
        interval:
          type: string
          enum:
            - yearly
            - monthly
          example: monthly
          description: Billing interval
        currency:
          type: string
          example: USD
          description: Currency code
        amount:
          type: number
          example: 99.99
          minimum: 0
          description: Plan amount
        trialPeriod:
          type: number
          example: 14
          minimum: 0
          description: Trial period in days
        gracePeriod:
          type: number
          example: 7
          minimum: 0
          description: Grace period in days after subscription expiry
        charges:
          example:
            - billable_metric_id: 1a901a90-1a90-1a90-1a90-1a901a901a94
              charge_model: volume
              invoiceable: true
              pay_in_advance: false
              properties:
                volume_ranges:
                  - from_value: 0
                    to_value: 100
                    flat_amount: '0'
                    per_unit_amount: '0'
                  - from_value: 101
                    to_value: null
                    flat_amount: '0'
                    per_unit_amount: '0.5'
          description: Add multiple billable metrics in plan
          type: array
          items:
            $ref: '#/components/schemas/ChargesDto'
      required:
        - name
        - code
        - interval
        - currency
        - amount
    ChargesDto:
      type: object
      properties:
        billable_metric_id:
          type: string
          example: storage
        charge_model:
          type: string
          enum:
            - standard
            - graduated_percentage
            - package
            - percentage
            - volume
            - graduated
          example: volume
        invoiceable:
          type: boolean
          example: true
        pay_in_advance:
          type: boolean
          example: false
        properties:
          type: object
          example:
            volume_ranges:
              - from_value: 0
                to_value: 100
                flat_amount: '0'
                per_unit_amount: '0'
              - from_value: 101
                to_value: null
                flat_amount: '0'
                per_unit_amount: '0.5'
      required:
        - billable_metric_id
        - charge_model
        - invoiceable
        - pay_in_advance
        - properties

````