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

# Create draft invoice or add to next bill

> Requires `write:billing`. Creates a one-off invoice **as a draft** for a customer, from one-time products (default or chosen price, or a custom amount) and/or custom lines (`description` + `amountCents`), with an optional car per line, due date and memo. Nothing is sent or charged; sending is a separate action, and staff can also finish it at `dashboardUrl`. Tax and processing fees follow the facility's settings. With `billingOption: "next_bill"` no invoice is created: the lines are added to the customer's next monthly plan bill and charged with it (409 `no_eligible_plan` when there is no active monthly plan).



## OpenAPI

````yaml /api-reference/openapi.json post /api/v1/billing/invoices
openapi: 3.0.0
info:
  title: Car Storage Software API
  version: 1.2.0
  description: >-
    Team-scoped REST API for Car Storage Software. Authenticate with a team API
    key (`Authorization: Bearer <key>` or `x-api-key: <key>`) created under
    Settings → Integrations → API. Keys carry granular `read:*` / `write:*`
    scopes; read never implies write.
servers:
  - url: https://www.carstoragesoftware.com
security: []
paths:
  /api/v1/billing/invoices:
    post:
      tags:
        - Billing
      summary: Create draft invoice or add to next bill
      description: >-
        Requires `write:billing`. Creates a one-off invoice **as a draft** for a
        customer, from one-time products (default or chosen price, or a custom
        amount) and/or custom lines (`description` + `amountCents`), with an
        optional car per line, due date and memo. Nothing is sent or charged;
        sending is a separate action, and staff can also finish it at
        `dashboardUrl`. Tax and processing fees follow the facility's settings.
        With `billingOption: "next_bill"` no invoice is created: the lines are
        added to the customer's next monthly plan bill and charged with it (409
        `no_eligible_plan` when there is no active monthly plan).
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                customerId:
                  type: string
                  format: uuid
                  description: Customer id from `list_customers`.
                items:
                  type: array
                  items:
                    type: object
                    properties:
                      productId:
                        type: string
                        format: uuid
                        description: >-
                          One-time product (from `list_billing_products`, type
                          `one_off`).
                      priceId:
                        type: string
                        format: uuid
                        description: >-
                          One of the product's prices; defaults to the product's
                          price.
                      description:
                        type: string
                        minLength: 1
                        maxLength: 500
                        description: >-
                          Line text. Required for a custom line (no productId),
                          e.g. `Battery tender install`.
                      amountCents:
                        type: integer
                        minimum: 1
                        maximum: 10000000
                        description: >-
                          Unit price in cents, before tax and processing fees.
                          Required for a custom line; with a productId it
                          overrides the product's price.
                      quantity:
                        type: integer
                        minimum: 1
                        maximum: 100
                      carId:
                        type: string
                        format: uuid
                        description: Car this line is for.
                  minItems: 1
                  maxItems: 25
                dueDate:
                  type: string
                  pattern: ^\d{4}-\d{2}-\d{2}$
                  description: >-
                    Due date (YYYY-MM-DD). Defaults to the facility's usual
                    terms.
                memo:
                  type: string
                  maxLength: 500
                  description: Note shown on the invoice.
                billingOption:
                  type: string
                  enum:
                    - draft
                    - next_bill
                  description: >-
                    `draft` (default) creates a draft invoice. `next_bill`
                    creates no invoice: each line is added to the customer's
                    next monthly plan bill and charged with it (one charge per
                    line). Answers 409 (`code: no_eligible_plan`) when the
                    customer has no active monthly plan to add to, 409 (`code:
                    out_of_stock`) when a capped product is sold out, 409
                    (`code: idempotency_conflict`) when `idempotencyKey` was
                    already used for different lines, 409 (`code: busy`) when
                    the plan's add-ons are being changed (retry shortly), or 409
                    (`code: needs_confirmation`) for a large amount sent without
                    `confirmedLargeAmount: true`. `dueDate` and `memo` are
                    ignored.
                subscriptionId:
                  type: string
                  format: uuid
                  description: >-
                    `next_bill` only: the plan to add to (from
                    `list_billing_subscriptions`). Defaults to the plan that
                    renews soonest.
                addOnsGetPlanDiscount:
                  type: boolean
                  description: >-
                    `next_bill` only: when the plan has a percent-off discount
                    on the whole plan, whether these lines get it too. Saved on
                    the plan and used for later add-ons. Without an answer,
                    add-ons pay full price.
                idempotencyKey:
                  type: string
                  minLength: 1
                  maxLength: 200
                  description: >-
                    `next_bill` only: send the same key when retrying so each
                    line is stored once.
                confirmedLargeAmount:
                  type: boolean
                  description: >-
                    `next_bill` only: set to `true` to add a large amount: any
                    line over the facility's line amount, or lines that take the
                    plan's waiting add-ons over its plan amount (set in Billing
                    settings; $10,000 and $25,000 unless changed, and either can
                    be turned off). Without it such a request stores nothing and
                    answers 409 (`code: needs_confirmation`,
                    `details.largeAmount` with the amount and the facility's
                    limit as `thresholdCents`). Confirm with the person asking,
                    then resend with the same `idempotencyKey`.
              required:
                - customerId
                - items
      responses:
        '201':
          description: >-
            Draft invoice created, or (`next_bill`) the lines added to the next
            bill.
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/V1BillingInvoiceCreated'
                  - $ref: '#/components/schemas/V1BillingNextBillChargesCreated'
        '401':
          description: Missing, invalid, revoked, or expired API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '403':
          description: API key missing required scope, or API disabled for team.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '404':
          description: Resource not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '409':
          description: >-
            Payments aren't set up for this facility (no connected Stripe
            account).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '422':
          description: Request validation failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    V1BillingInvoiceCreated:
      type: object
      properties:
        data:
          allOf:
            - $ref: '#/components/schemas/V1BillingInvoice'
            - type: object
              properties:
                dashboardUrl:
                  type: string
                  description: The draft in Payments, where staff can review and send it.
              required:
                - dashboardUrl
      required:
        - data
    V1BillingNextBillChargesCreated:
      type: object
      properties:
        data:
          type: object
          properties:
            billingOption:
              type: string
              enum:
                - next_bill
            charges:
              type: array
              items:
                type: object
                properties:
                  id:
                    type: string
                    description: Next-bill charge id.
                  onOpenBill:
                    type: boolean
                    description: >-
                      True when the plan's bill was already being prepared and
                      the line went straight onto it.
                required:
                  - id
                  - onOpenBill
            plan:
              type: object
              properties:
                subscriptionId:
                  type: string
                  nullable: true
                  description: Plan id from `list_billing_subscriptions`.
                name:
                  type: string
                nextBillAt:
                  type: string
                  description: When the plan's next bill is created (ISO 8601).
                currency:
                  type: string
              required:
                - subscriptionId
                - name
                - nextBillAt
                - currency
          required:
            - billingOption
            - charges
            - plan
      required:
        - data
    ApiError:
      type: object
      properties:
        error:
          type: string
        code:
          type: string
        details:
          nullable: true
      required:
        - error
    V1BillingInvoice:
      type: object
      properties:
        id:
          type: string
          description: Stripe invoice id (`in_…`).
        number:
          type: string
          nullable: true
        customerId:
          type: string
          nullable: true
          format: uuid
          description: Car Storage Software customer id, when linked.
        status:
          type: string
          nullable: true
          description: '`draft`, `open`, `paid`, `void`, or `uncollectible`.'
        currency:
          type: string
        totalCents:
          type: integer
        amountDueCents:
          type: integer
        amountPaidCents:
          type: integer
        amountRemainingCents:
          type: integer
        dueDate:
          type: string
          nullable: true
          format: date-time
        createdAt:
          type: string
          nullable: true
          format: date-time
        paidAt:
          type: string
          nullable: true
          format: date-time
        hostedInvoiceUrl:
          type: string
          nullable: true
        subscriptionId:
          type: string
          nullable: true
          description: Stripe subscription id, when recurring.
        lines:
          type: array
          items:
            type: object
            properties:
              description:
                type: string
                nullable: true
              amountCents:
                type: integer
              quantity:
                type: integer
                nullable: true
            required:
              - description
              - amountCents
              - quantity
      required:
        - id
        - number
        - customerId
        - status
        - currency
        - totalCents
        - amountDueCents
        - amountPaidCents
        - amountRemainingCents
        - dueDate
        - createdAt
        - paidAt
        - hostedInvoiceUrl
        - subscriptionId
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: >-
        Team API key from Settings → Integrations. Use `Authorization: Bearer
        <key>` or `x-api-key`.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.