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

# Create subscription

> Assign a free plan to a customer. The customer can be created via POST /v1/customers or through checkout. Only free plans can be assigned via this endpoint — use checkout for paid plans.



## OpenAPI

````yaml /openapi.json post /subscriptions
openapi: 3.0.0
info:
  title: Lava API
  description: >-
    Lava API enables businesses to implement usage-based billing for AI
    services. This API allows tracking, managing, and billing for third-party AI
    API usage through a forwarding system.
  version: 1.0.0
  contact:
    name: Lava support
    url: https://www.lava.so/contact
servers:
  - url: https://api.lava.so/v1/
    description: Lava API v1
security: []
tags:
  - name: Authentication
  - name: Core Endpoints
  - name: Models
  - name: Services
  - name: Requests
  - name: Wallet
  - name: Payment Methods
  - name: Spend Keys
  - name: Usage
  - name: Checkout Sessions
  - name: Customers
  - name: Plans
  - name: Subscriptions
  - name: Meters
  - name: Webhooks
  - name: Secret Keys
  - name: Credit Bundles
  - name: Gateway Settings
  - name: Skills
  - name: News Data
  - name: Search
  - name: Enrich
paths:
  /subscriptions:
    post:
      tags:
        - Subscriptions
      summary: Create subscription
      description: >-
        Assign a free plan to a customer. The customer can be created via POST
        /v1/customers or through checkout. Only free plans can be assigned via
        this endpoint — use checkout for paid plans.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                customer_id:
                  type: string
                  description: >-
                    Customer ID (con_xxx) or your reference_id. Both are
                    accepted interchangeably.
                  example: con_test_01EXAMPLE00000000000000001
                plan_id:
                  type: string
                  description: >-
                    ID of the plan to assign. Must be a free plan (period_amount
                    = 0).
                  example: subconf_abc123
              required:
                - customer_id
                - plan_id
      responses:
        '201':
          description: Subscription created
          content:
            application/json:
              schema:
                type: object
                properties:
                  subscription: 401033d9-b86b-4983-8a04-8cc28117f071
                required:
                  - subscription
        '400':
          description: Bad request — plan is not free
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                plan_not_free:
                  summary: Plan is not free
                  value:
                    error:
                      message: >-
                        Only free plans can be assigned via API. Use checkout
                        for paid plans.
                      code: plan_not_free
                      status: 400
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Customer or plan not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Active subscription already exists
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                subscription_already_exists:
                  summary: Duplicate active subscription
                  value:
                    error:
                      message: An active subscription already exists for this customer.
                      code: subscription_already_exists
                      status: 409
      security:
        - Auth: []
components:
  schemas:
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              description: Human-readable error message describing what went wrong
              example: Invalid authentication credentials
            code:
              type: string
              description: Machine-readable error code describing what went wrong
              example: forward_token_json_invalid
            status:
              type: integer
              description: HTTP status code of the error
              example: 400
            issues:
              type: array
              items:
                type: object
                properties:
                  path:
                    type: array
                    items:
                      type: string
                    description: Path to the field that caused the validation error
                  message:
                    type: string
                    description: Error message describing the validation issue
                required:
                  - path
                  - message
              description: >-
                Optional array of specific validation issues with their paths
                and messages
              example:
                - path:
                    - model
                  message: 'Missing required field: model'
                - path:
                    - messages
                    - '0'
                    - content
                  message: Invalid message content format
          required:
            - message
            - code
            - status
      required:
        - error
  securitySchemes:
    Auth:
      type: http
      scheme: bearer
      description: >-
        Bearer token authentication used for standard API calls. Format: 'Bearer
        YOUR_API_KEY'

````