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

> Creates a checkout session and returns a `checkout_url` to send your
customer to. Currently required fields: `amount`, `product_pid`,
`customer`. Pass `from_order` to reuse a `cancelled`/`pending` order
instead of creating a new one.




## OpenAPI

````yaml /openapi.yaml post /v1/orders
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/orders:
    post:
      tags:
        - Orders
      summary: Create order
      description: |
        Creates a checkout session and returns a `checkout_url` to send your
        customer to. Currently required fields: `amount`, `product_pid`,
        `customer`. Pass `from_order` to reuse a `cancelled`/`pending` order
        instead of creating a new one.
      operationId: postV1Orders
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateOrderRequest'
      responses:
        '201':
          description: Order created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateOrderResponse'
              example:
                status: success
                success: true
                checkout_url: https://pay.lojou.app/token/954_aB3xY9k2m
                message: Checkout initialized successfully.
                order_number: '95428522'
                pay_token: 954_aB3xY9k2m
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          description: Product, plan, or referenced order (`from_order`) not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                status: error
                message: Product not found.
        '422':
          $ref: '#/components/responses/ValidationError'
components:
  schemas:
    CreateOrderRequest:
      type: object
      required:
        - amount
        - product_pid
        - customer
      properties:
        amount:
          type: number
          minimum: 10
          example: 748.6
        product_pid:
          type: string
          example: QUyMp
        plan_id:
          type: string
          nullable: true
        from_order:
          type: string
          nullable: true
          description: >-
            Reference to a previous order, to reuse it instead of creating a new
            one.
        customer:
          $ref: '#/components/schemas/CustomerPayload'
        affiliate_id:
          type: integer
          nullable: true
        return_url:
          type: string
          format: uri
          nullable: true
        cancel_url:
          type: string
          format: uri
          nullable: true
        coupon_code:
          type: string
          nullable: true
    CreateOrderResponse:
      type: object
      properties:
        status:
          type: string
          example: success
        success:
          type: boolean
          example: true
        message:
          type: string
          example: Checkout initialized successfully.
        checkout_url:
          type: string
          format: uri
          nullable: true
        order_number:
          type: string
          nullable: true
        pay_token:
          type: string
          nullable: true
    ErrorResponse:
      type: object
      properties:
        status:
          type: string
          example: error
        message:
          type: string
      additionalProperties: true
    CustomerPayload:
      type: object
      required:
        - name
        - email
        - mobile_number
      properties:
        name:
          type: string
          example: Carla Jeambi
        email:
          type: string
          format: email
          example: carla@example.com
        mobile_number:
          type: string
          example: '+258876683588'
        payment_number:
          type: string
          nullable: true
    ValidationErrorResponse:
      allOf:
        - $ref: '#/components/schemas/ErrorResponse'
        - type: object
          properties:
            errors:
              type: object
              additionalProperties:
                type: array
                items:
                  type: string
  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
    ValidationError:
      description: Validation failed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ValidationErrorResponse'
          example:
            status: error
            message: Validation failed.
            errors:
              amount:
                - The amount field is required.
  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.

````