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

# Create a custom invoice for an account

> Create a custom invoice for an account.



## OpenAPI

````yaml post /invoices
openapi: 3.0.3
info:
  version: '1.0'
  title: Togai Apis
  contact:
    email: engg@togai.com
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html
  description: APIs for Togai App
servers:
  - description: Api endpoint
    url: https://api.togai.com/
  - description: Sandbox api endpoint
    url: https://sandbox-api.togai.com/
security:
  - bearerAuth: []
tags:
  - name: Customers
    description: Customer level calls
  - name: Accounts
    description: Account level calls
  - name: Event Schemas
    description: Event Schema level calls
  - name: Usage Meters
    description: Usage Meter level calls
  - name: Price Plans
    description: (DEPRECATED) Price Plan level calls
  - name: PricePlanV2
    description: Price Plan V2 level calls
  - name: Schedules
    description: Account Schedule level calls
  - name: Pricing Rules
    description: Pricing Rules level calls
  - name: Settings
    description: Settings
  - name: Price Experimentation
    description: Price Experimentation apis
  - name: InvoiceGroups
    description: Invoice Group level calls
  - name: Organization
    description: Organization level calls
  - name: FileStorage
    description: File Storage level calls
  - name: Aliases
    description: Alias level calls
  - name: Reports
    description: Report level calls
  - name: ReportTemplates
    description: Report Template level calls
  - name: Customer Portal
    description: Portal level calls
  - name: Alerts
    description: Alert level calls
  - name: Event Management
    description: APIs for getting events ingested in Togai
    externalDocs:
      description: docs
      url: https://togai.com/docs/billing/events
  - name: Metrics
    description: APIs for getting Togai metrics
    externalDocs:
      description: docs
      url: https://togai.com/docs/metrics
  - name: Licenses
    description: APIs for getting or updating license records in Togai
  - name: Entitlements
    description: APIs related to entitlements
  - name: Invoices
    description: Invoices API
  - name: Credits
    description: Credits API
  - name: Wallet
    description: Wallet API
  - name: InvoiceTemplates
    description: InvoiceTemplates API
  - name: InvoiceSequence
    description: InvoiceSequence API
  - name: Payments
    description: Payments API
  - name: Authentication
    description: Authentication API
externalDocs:
  description: Find out more about Togai
  url: https://docs.togai.com/docs
paths:
  /invoices:
    post:
      tags:
        - Invoices
      summary: Create a custom invoice for an account
      description: Create a custom invoice for an account.
      operationId: createCustomInvoice
      requestBody:
        $ref: '#/components/requestBodies/CreateCustomInvoiceRequest'
      responses:
        '201':
          $ref: '#/components/responses/InvoiceResponse'
        '400':
          $ref: '#/components/responses/ErrorResponse'
        '401':
          $ref: '#/components/responses/ErrorResponse'
        '403':
          $ref: '#/components/responses/ErrorResponse'
        '404':
          $ref: '#/components/responses/ErrorResponse'
        '429':
          $ref: '#/components/responses/ErrorResponse'
        default:
          $ref: '#/components/responses/ErrorResponse'
components:
  requestBodies:
    CreateCustomInvoiceRequest:
      description: Payload to create invoice
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/CreateCustomInvoiceRequest'
          examples:
            CreateCustomInvoiceRequest:
              $ref: '#/components/examples/CreateCustomInvoiceRequest'
  responses:
    InvoiceResponse:
      description: Response for Get invoice requests
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Invoice'
          examples:
            Invoice:
              $ref: '#/components/examples/Invoice'
    ErrorResponse:
      description: Error response
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            ErrorResponse:
              summary: Error message
              value:
                message: <Reason message>
  schemas:
    CreateCustomInvoiceRequest:
      description: Payload to create invoice
      type: object
      additionalProperties: false
      required:
        - accountId
        - startDate
        - endDate
        - status
        - lineItems
      properties:
        accountId:
          type: string
          example: ACC001
        ownerType:
          type: string
          enum:
            - ACCOUNT
            - INVOICE_GROUP
        startDate:
          type: string
          format: date-time
          example: '2020-06-04T12:00:00.000Z'
        endDate:
          type: string
          format: date-time
          example: '2020-07-04T12:00:00.000Z'
        idempotencyKey:
          type: string
          example: '1234567890'
        status:
          title: CreateInvoiceStatus
          description: Status to create an invoice in.
          type: string
          enum:
            - DRAFT
            - DUE
            - PAID
          example: DUE
        lineItems:
          type: array
          minItems: 1
          maxItems: 50
          items:
            $ref: '#/components/schemas/CustomInvoiceLineItem'
        autoAdvance:
          type: boolean
          description: >
            This property defines the behaviour of status transition of the
            invoice.

            If true, invoice auto transitions from `DRAFT` to `DUE` or `PAID` at
            the end of pricing cycle.

            If false, the invoice’s state doesn’t automatically advance without
            an explicit action.

            Default: false
        applyCredits:
          type: boolean
          description: >
            This property defines the behaviour of whether or not to use credits
            to net off with the invoice amount. Default: true
        applyWalletBalance:
          type: boolean
          description: >
            This property defines the behaviour of whether or not to use wallet
            amount to net off with the invoice amount. Default: true
    Invoice:
      description: Structure of invoice
      type: object
      additionalProperties: false
      required:
        - id
        - status
        - invoiceDate
        - updatedAt
        - invoiceClass
        - invoiceType
        - totalAmount
        - paidAmount
        - netTermDays
      properties:
        id:
          description: Identifier of invoice
          type: string
          maxLength: 50
        customerId:
          type: string
        ownerId:
          type: string
        pricePlanId:
          type: string
        usageInfo:
          type: array
          items:
            $ref: '#/components/schemas/InvoiceLineItem'
        revenueInfo:
          $ref: '#/components/schemas/InvoiceLineItem'
        invoiceDetails:
          $ref: '#/components/schemas/InvoiceDetails'
        status:
          $ref: '#/components/schemas/InvoicesStatus'
          example: DUE
        finalizingStatus:
          type: string
          enum:
            - FINALIZING
            - FINALIZED
        invoiceClass:
          $ref: '#/components/schemas/InvoicesClass'
          example: INVOICE
        invoiceType:
          $ref: '#/components/schemas/InvoicesType'
        autoAdvance:
          type: boolean
          example: true
        startDate:
          description: Start date of the invoice
          type: string
          format: date-time
          example: '2020-07-04T12:00:00.000Z'
        endDate:
          description: End date of the invoice
          type: string
          format: date-time
          example: '2020-07-04T12:00:00.000Z'
        endDateInclusive:
          description: Inclusive end date of the invoice
          type: string
          format: date-time
          example: '2020-07-03T11:59:59.999Z'
        invoiceDate:
          description: Invoice date of the invoice
          type: string
          format: date-time
          example: '2020-07-04T12:00:00.000Z'
        dueDate:
          description: Due date of the invoice
          type: string
          format: date-time
          example: '2020-07-04T12:00:00.000Z'
        generatedAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
        metadata:
          type: object
          additionalProperties: true
        info:
          type: array
          items:
            type: object
            additionalProperties: false
            required:
              - type
              - value
            properties:
              type:
                type: string
                description: Type of the information
              value:
                type: string
                description: Value of the information
        sequenceId:
          type: string
          description: Sequence id of the invoice
        pdfUrl:
          description: Download URL of the pdf file corresponding to the invoice
          type: string
        totalAmount:
          type: number
        paidAmount:
          type: number
        netTermDays:
          type: integer
          description: >-
            Number of days from the invoice date after which an invoice is
            considered overdue.
    ErrorResponse:
      type: object
      additionalProperties: false
      required:
        - message
      properties:
        message:
          type: string
          description: error description
          maxLength: 500
    CustomInvoiceLineItem:
      type: object
      description: >
        Custom line item. Either `value` or `quantity` + `valuePerQuantity` is
        required.

        In case `quantity` and `valuePerQuantity` are provided, `value` is
        computed as (`quantity` X `valuePerQuantity`)
      additionalProperties: false
      properties:
        id:
          type: string
        description:
          type: string
        valuePerQuantity:
          type: number
        quantity:
          type: number
        value:
          type: number
        billableId:
          type: string
    InvoiceLineItem:
      type: object
      additionalProperties: false
      required:
        - description
        - type
        - value
      properties:
        id:
          type: string
        description:
          type: string
        type:
          type: string
          enum:
            - TOTAL_USAGE
            - USAGE_METER_USAGE
            - GRAND_TOTAL_AMOUNT
            - TOTAL_AMOUNT
            - NET_AMOUNT
            - GROSS_AMOUNT
            - SUB_TOTAL_AMOUNT
            - PRICE_PLAN_AMOUNT
            - FIXED_FEE_RATE_CARD_AMOUNT
            - CREDIT_GRANT_RATE_CARD_AMOUNT
            - BILLING_ENTITLEMENT_RATE_CARD_AMOUNT
            - ENTITLEMENT_OVERAGE_RATE_CARD_AMOUNT
            - ENTITLEMENT_OVERAGE_RATE_CARD_SLAB_AMOUNT
            - LICENSE_RATE_CARD_AMOUNT
            - USAGE_CYCLE_AMOUNT
            - LICENSE_RATE_CARD_SLAB_AMOUNT
            - USAGE_RATE_CARD_AMOUNT
            - USAGE_RATE_CARD_SLAB_AMOUNT
            - TOTAL_CREDITS
            - SUB_CREDITS
            - TOTAL_ADVANCED_FEES
            - ADVANCED_FIXED_FEE
            - ADVANCED_LICENSE_RATE_CARD_AMOUNT
            - ADVANCED_BILLING_ENTITLEMENT_RATE_CARD_AMOUNT
            - ADVANCED_CREDIT_GRANT_RATE_CARD_AMOUNT
            - TOTAL_MISCELLANEOUS_CHARGES
            - MISCELLANEOUS_CHARGE
            - TRUE_UP_AMOUNT
            - TOTAL_PURCHASE_AMOUNT
            - CUSTOM_AMOUNT
            - CUSTOM_TAG
            - TOTAL_PRICING_RULE_ADDITION_AMOUNT
            - PRICING_RULE_ADDITION_AMOUNT
            - PRICING_RULE_REVENUE_UPDATE_AMOUNT
            - PRICING_RULE_USAGE_UPDATE_AMOUNT
            - RATE_CONFIG_ADJUSTMENT_AMOUNT
            - TOTAL_TAX_AMOUNT
            - TAX_AMOUNT
            - PROXY_AMOUNT
          description: >
            Type of the line item

            - GRAND_TOTAL_AMOUNT: Sum of all total amount of individual invoices
            in a grouped(composite) invoice

            - TOTAL_AMOUNT: Total revenue of the invoice

            - NET_AMOUNT: Net revenue of the invoice ( Gross revenue - Discounts
            )

            - GROSS_AMOUNT: Gross revenue of the invoice 

            - PRICE_PLAN_AMOUNT: SUB_TOTAL_AMOUNT + true up amount

            - SUB_TOTAL_AMOUNT: Sum of all rate card revenues

            - TRUE_UP_AMOUNT: Minimum commitment - SUB_TOTAL_AMOUNT (Always
            positive)

            - TOTAL_USAGE: List of all the usage meter usages

            - USAGE_METER_USAGE: Usage of an usage meter

            - USAGE_RATE_CARD_AMOUNT: Revenue generated from usage rate card

            - USAGE_RATE_CARD_SLAB_AMOUNT: Revenue generated from usage rate
            card slab

            - FIXED_FEE_RATE_CARD_AMOUNT: Revenue generated from fixed fee rate
            card

            - CREDIT_GRANT_RATE_CARD_AMOUNT: : Revenue generated from credit
            grant rate card

            - BILLING_ENTITLEMENT_RATE_CARD_AMOUNT: Revenue generated from
            billing entitlement rate card

            - ENTITLEMENT_OVERAGE_RATE_CARD_AMOUNT: : Revenue generated from
            entitlement overage rate card

            - ENTITLEMENT_OVERAGE_RATE_CARD_SLAB_AMOUNT: Revenue generated from
            entitlement overage rate card slab

            - LICENSE_RATE_CARD_AMOUNT: Revenue generated from license rate card

            - TOTAL_CREDITS: Sum of all credit amounts

            - SUB_CREDITS: Granted credit value

            - TOTAL_ADVANCED_FEES: Sum of all advanced fee revenue

            - ADVANCED_FIXED_FEE: Revenue generated from advanced fixed fee rate
            card

            - ADVANCED_LICENSE_RATE_CARD_AMOUNT: Revenue generated from advanced
            license rate card

            - ADVANCED_BILLING_ENTITLEMENT_RATE_CARD_AMOUNT: Revenue generated
            from advanced billing entitlement rate card

            - ADVANCED_CREDIT_GRANT_RATE_CARD_AMOUNT: Revenue generated from
            advanced credit grant rate card

            - TOTAL_MISCELLANEOUS_CHARGES: Net revenue of all
            MISCELLANEOUS_CHARGE

            - MISCELLANEOUS_CHARGE: Custom amount added to a DRAFT invoice

            - TOTAL_PURCHASE_AMOUNT: Net revenue all rate cards in a purchase
            plan

            - CUSTOM_AMOUNT: Custom amount added a DRAFT invoice

            - CUSTOM_TAG: User defined tags given to each rate card

            - TOTAL_PRICING_RULE_ADDITION_AMOUNT: Sum of all line items added by
            applying pricing rules

            - PRICING_RULE_ADDITION_AMOUNT: Amount added to invoice as a result
            of applying a pricing rule

            - PRICING_RULE_REVENUE_UPDATE_AMOUNT: Difference in revenue(value)
            obtained as a result of applying a pricing rule

            - PRICING_RULE_USAGE_UPDATE_AMOUNT: Difference in usage(quantity)
            obtained as a result of applying a pricing rule

            - RATE_CONFIG_ADJUSTMENT_AMOUNT: Difference in revenue obtained as a
            result of applying rate config['minimumRate', 'maximumRate'] at rate
            card level
        valuePerQuantity:
          type: number
        quantity:
          type: number
        units:
          type: string
        value:
          type: number
        metadata:
          type: object
          additionalProperties: true
    InvoiceDetails:
      type: object
      additionalProperties: false
      properties:
        customer:
          type: object
          additionalProperties: false
          required:
            - name
            - primaryEmail
          properties:
            name:
              type: string
            primaryEmail:
              type: string
            billingAddress:
              type: string
            address:
              $ref: '#/components/schemas/Address'
        account:
          type: object
          additionalProperties: false
          required:
            - name
            - invoiceCurrency
            - address
            - primaryEmail
          properties:
            name:
              type: string
            invoiceCurrency:
              type: string
            address:
              $ref: '#/components/schemas/Address'
            primaryEmail:
              type: string
        pricePlanName:
          type: string
        invoiceGroup:
          type: object
          additionalProperties: false
          required:
            - id
            - name
            - dailyInvoiceConsolidation
            - invoiceCurrency
            - address
          properties:
            id:
              type: string
            name:
              type: string
            email:
              type: string
            dailyInvoiceConsolidation:
              type: boolean
            invoiceCurrency:
              type: string
            address:
              $ref: '#/components/schemas/Address'
        organization:
          type: object
          additionalProperties: false
          required:
            - businessName
            - address
            - primaryEmail
          properties:
            businessName:
              type: string
            address:
              $ref: '#/components/schemas/Address'
            primaryEmail:
              type: string
            metadata:
              type: object
              additionalProperties:
                type: string
        logoUrl:
          type: string
    InvoicesStatus:
      description: Status of the invoice
      type: string
      enum:
        - DRAFT
        - DUE
        - PAID
        - VOID
        - UN_COLLECTIBLE
        - REFUND_INITIATED
        - REFUND_COMPLETED
        - MERGED
        - PARTIALLY_PAID
    InvoicesClass:
      description: Represents the class of entity( INVOICE/ORDER/BILLABLE)
      type: string
      enum:
        - INVOICE
        - ORDER
        - BILLABLE
    InvoicesType:
      description: Represents the type of entity(STANDARD/AD_HOC/COMPOSITE)
      type: string
      enum:
        - STANDARD
        - AD_HOC
        - CUSTOM
        - COMPOSITE
        - STANDARD_ADVANCED
        - ADHOC_ADVANCED
    Address:
      description: billing address of the customer
      type: object
      additionalProperties: false
      properties:
        phoneNumber:
          description: Contact number
          type: string
        line1:
          description: Address line 1 (eg. Street, PO Box, Company Name)
          type: string
        line2:
          description: Address line 2 (eg. apartment, suite, unit or building)
          type: string
        postalCode:
          description: ZIP or postal code
          type: string
        city:
          description: City, district, suburb, town or village
          type: string
        state:
          description: State, county, province or region
          type: string
        country:
          description: >-
            Two letter country code [ISO-3166-1
            Alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
          type: string
  examples:
    CreateCustomInvoiceRequest:
      summary: A sample for CreateCustomInvoiceRequest
      value:
        accountId: ACC001
        startDate: '2020-06-04T12:00:00.000Z'
        endDate: '2020-07-04T12:00:00.000Z'
        idempotencyKey: '1234567890'
        status: DRAFT
        lineItems:
          - description: Payout IMPS
            valuePerQuantity: 0.001
            quantity: 32109
    Invoice:
      summary: A sample Invoice
      value:
        id: inv.hkgkgyh.ghg
        sequenceId: 2020-07-2958
        customerId: 7VcRw9xZDIqsC5E
        ownerId: ACC001
        usageInfo:
          - description: rides - local
            type: USAGE_METER_USAGE
            value: 15
            units: USAGE_UNITS
          - description: rides - pro
            type: USAGE_METER_USAGE
            value: 5
            units: USAGE_UNITS
        revenueInfo:
          description: Grand Total Amount
          type: GRAND_TOTAL_AMOUNT
          units: USD
          value: 881.94
          lineItems:
            - description: Total Amount
              type: TOTAL_AMOUNT
              units: USD
              value: 881.94
              lineItems:
                - description: Total amount due
                  type: NET_AMOUNT
                  units: USD
                  value: 881.94
                  lineItems:
                    - description: Sum Total
                      type: GROSS_AMOUNT
                      units: USD
                      value: 981.94
                      lineItems:
                        - description: Payout_NEFT
                          type: USAGE_RATE_CARD_AMOUNT
                          units: USD
                          value: 392.1
                          lineItems:
                            - description: Slab 1
                              type: USAGE_RATE_CARD_SLAB_AMOUNT
                              valuePerQuantity: 0.001
                              quantity: 10000
                              units: USD
                              value: 10
                            - description: Slab 2
                              type: USAGE_RATE_CARD_SLAB_AMOUNT
                              valuePerQuantity: 0.001
                              quantity: 10000
                              units: USD
                              value: 10
                        - description: Payout IMPS
                          type: USAGE_RATE_CARD_AMOUNT
                          valuePerQuantity: 0.001
                          quantity: 32109
                          units: USD
                          value: 589.94
                          lineItems:
                            - description: Slab 1
                              type: USAGE_RATE_CARD_SLAB_AMOUNT
                              valuePerQuantity: 0.001
                              quantity: 10000
                              units: USD
                              value: 10
                            - description: Slab 2
                              type: USAGE_RATE_CARD_SLAB_AMOUNT
                              valuePerQuantity: 0.001
                              quantity: 10000
                              units: USD
                              value: 10
        invoiceDetails:
          customer:
            name: John Doe
            primaryEmail: john@togai.com
            address:
              line1: 2281 Broadway Street
              line2: G-31
              postalCode: '29501'
              city: Florence
              state: South Carolina
              country: US
          account:
            name: Togai
            address:
              line1: 2281 Broadway Street
              line2: G-31
              postalCode: '29501'
              city: Florence
              state: South Carolina
              country: US
            primaryEmail: john@togai.com
            invoiceCurrency: USD
          pricePlanName: Togai Basic
        totalAmount: 881.94
        paidAmount: 0
        invoiceClass: INVOICE
        invoiceType: STANDARD
        status: DUE
        finalizingStatus: FINALIZED
        startDate: '2020-07-04T12:00:00.000Z'
        endDate: '2020-08-04T12:00:00.000Z'
        invoiceDate: '2020-08-04T12:00:00.000Z'
        generatedAt: '2020-08-04T12:00:00.000Z'
        updatedAt: '2020-08-04T12:00:00.000Z'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: Bearer <credential>

````