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

# Create plan

> Only for products created with `type: recurring`.



## OpenAPI

````yaml /openapi.yaml post /v1/plan
openapi: 3.1.0
info:
  title: Lojou API
  version: 1.0.0
  description: |
    Official reference for the Lojou `/v1` API — everything a developer needs
    to create products, process orders, manage plans, and receive webhooks
    from a Lojou store.
servers:
  - url: https://api.lojou.app
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Health
  - name: OAuth
  - name: User
  - name: Products
  - name: Plans
  - name: Orders
  - name: Customers
  - name: Files
  - name: Webhooks
  - name: Discounts
  - name: Affiliates
paths:
  /v1/plan:
    post:
      tags:
        - Plans
      summary: Create plan
      description: 'Only for products created with `type: recurring`.'
      operationId: postV1Plan
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreatePlanRequest'
      responses:
        '201':
          description: Plan created
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
              example:
                status: success
                message: Plan created successfully.
                data:
                  plan_id: 8k2mZ
                  product_pid: J5bgs
                  name: Mensal
                  description: Acesso a todo o conteúdo, renovado todo mês.
                  price: 1500
                  currency: MZN
                  billing_interval: monthly
                  billing_interval_count: 1
                  trial_days: 0
                  is_active: true
                  created_at: '2026-08-31T16:15:00.000000Z'
                  updated_at: '2026-08-31T16:15:00.000000Z'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '422':
          description: 'Validation failed, or the product is not `type: recurring`'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationErrorResponse'
              example:
                status: error
                message: This product does not support plans.
components:
  schemas:
    CreatePlanRequest:
      type: object
      required:
        - product_pid
        - price
      properties:
        product_pid:
          type: string
          example: J5bgs
        price:
          type: number
          minimum: 0
          example: 1500
        name:
          type: string
          nullable: true
          example: Mensal
        description:
          type: string
          nullable: true
        plan_id:
          type: string
          nullable: true
        billing_interval:
          type: string
          enum:
            - daily
            - weekly
            - monthly
            - yearly
          nullable: true
        billing_interval_count:
          type: integer
          minimum: 1
          nullable: true
        trial_days:
          type: integer
          minimum: 0
          nullable: true
        is_active:
          type: boolean
    ValidationErrorResponse:
      allOf:
        - $ref: '#/components/schemas/ErrorResponse'
        - type: object
          properties:
            errors:
              type: object
              additionalProperties:
                type: array
                items:
                  type: string
    ErrorResponse:
      type: object
      properties:
        status:
          type: string
          example: error
        message:
          type: string
      additionalProperties: true
  responses:
    UnauthorizedError:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            status: error
            message: Unauthorized user.
    ForbiddenError:
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            status: error
            message: Permission denied for this endpoint.
            error_code: insufficient_scope
            required_scopes:
              - orders.read
            missing_scopes:
              - orders.read
            granted_scopes:
              - products.read
              - products.write
    NotFoundError:
      description: Not Found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            status: error
            message: Resource not found.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: |
        Send an API key or an OAuth access token in the `Authorization` header
        as a Bearer token. See [Authentication](/authentication) for details.

````