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

# Create account

> 
        Create a new account in the chart of accounts.

        **Idempotency:** If external_id is provided and matches an existing account,
        returns the existing account with 200 OK.

        **Parent account:** Can be specified by UUID, code, or external_id.

        **Accounting validations:**
        - is_non_cash_expense can only be set on expense accounts
        - balance_behavior must be 'debit_positive', 'credit_positive', or blank
        



## OpenAPI

````yaml POST /v1/platform/businesses/{business_id}/general-ledger/chart-of-accounts/
openapi: 3.0.3
info:
  title: Thredfi Accounting Platform API
  version: 1.0.0
  description: >-
    Comprehensive API for accounting, invoice management, open banking, and
    intelligence services.
servers: []
security: []
paths:
  /v1/platform/businesses/{business_id}/general-ledger/chart-of-accounts/:
    post:
      tags:
        - General Ledger
      summary: Create account
      description: |2-

                Create a new account in the chart of accounts.

                **Idempotency:** If external_id is provided and matches an existing account,
                returns the existing account with 200 OK.

                **Parent account:** Can be specified by UUID, code, or external_id.

                **Accounting validations:**
                - is_non_cash_expense can only be set on expense accounts
                - balance_behavior must be 'debit_positive', 'credit_positive', or blank
                
      operationId: create_account
      parameters:
        - in: path
          name: business_id
          schema:
            type: string
            pattern: ^[0-9a-f-]+$
          required: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AccountCreateAPIRequest'
            examples:
              CreateBankAccount:
                value:
                  code: '1100'
                  name: Business Bank Account
                  account_type: asset
                  account_subtype: current_assets
                  description: Primary operating bank account for daily transactions
                  external_id: qbo-1100
                  institution_name: Barclays Bank PLC
                  iban: GB29BUKB20201555555555
                  sort_code: 20-20-15
                  account_number_mask: '****5555'
                  is_cash_account: true
                  custom_fields:
                    branch: London City
                    relationship_manager: John Smith
                summary: Create bank account
              CreateWithParent:
                value:
                  code: 1100-01
                  name: Petty Cash
                  parent_id: '1100'
                  description: Office petty cash fund
                  external_id: qbo-1100-01
                  is_cash_account: true
                summary: Create with parent
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/AccountCreateAPIRequest'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/AccountCreateAPIRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChartOfAccountDetail'
              examples:
                AccountResponse:
                  value:
                    id: 234567ab-cdef-4567-8901-234567890123
                    code: '1100'
                    name: Business Bank Account
                    currency: GBP
                    account_type: asset
                    account_type_display: Asset
                    account_subtype: current_assets
                    account_subtype_display: Current Assets
                    parent_account_code: null
                    current_balance: 1250050
                    current_balance_formatted: £12,500.50
                    debit_balance: 1500000
                    credit_balance: 249950
                    has_children: true
                    hierarchy_level: 0
                    is_active: true
                    description: Primary operating bank account for daily transactions
                    institution_name: Barclays Bank PLC
                    iban: GB29BUKB20201555555555
                    sort_code: 20-20-15
                    account_number_mask: '****5555'
                    total_debits: 234
                    total_credits: 189
                    last_entry_date: '2024-03-28T14:30:00Z'
                    last_entry_reference: JE-2024-0042
                    sub_accounts: []
                  summary: Account response
          description: ''
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChartOfAccountDetail'
              examples:
                AccountResponse:
                  value:
                    id: 234567ab-cdef-4567-8901-234567890123
                    code: '1100'
                    name: Business Bank Account
                    currency: GBP
                    account_type: asset
                    account_type_display: Asset
                    account_subtype: current_assets
                    account_subtype_display: Current Assets
                    parent_account_code: null
                    current_balance: 1250050
                    current_balance_formatted: £12,500.50
                    debit_balance: 1500000
                    credit_balance: 249950
                    has_children: true
                    hierarchy_level: 0
                    is_active: true
                    description: Primary operating bank account for daily transactions
                    institution_name: Barclays Bank PLC
                    iban: GB29BUKB20201555555555
                    sort_code: 20-20-15
                    account_number_mask: '****5555'
                    total_debits: 234
                    total_credits: 189
                    last_entry_date: '2024-03-28T14:30:00Z'
                    last_entry_reference: JE-2024-0042
                    sub_accounts: []
                  summary: Account response
          description: ''
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationErrorResponse'
          description: Validation errors in request data
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Authentication required - missing or invalid API key
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Permission denied - insufficient privileges
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Resource not found
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Conflict - resource already exists or invalid state transition
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Unprocessable entity - business logic validation failed
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Internal server error
      security:
        - PartnerJWT: []
        - BusinessScopedJWT: []
        - BasicAuth: []
        - BearerUnscoped: []
        - BearerBusinessScoped: []
components:
  schemas:
    AccountCreateAPIRequest:
      type: object
      description: |-
        Serializer for creating accounts via the Chart of Accounts API.

        Supports flexible parent identification (UUID, code, or external_id).
        Implements idempotency via external_id field.
      properties:
        code:
          type: string
          minLength: 1
          description: Unique account code within business (e.g., '1000', 'REV-SALES')
          maxLength: 50
        name:
          type: string
          description: Account display name. Maps to custom_name field.
          maxLength: 255
        account_type:
          enum:
            - asset
            - liability
            - equity
            - revenue
            - expense
            - ''
          type: string
          x-spec-enum-id: bee27527493b2230
          description: |-
            Account type: asset, liability, equity, revenue, expense

            * `asset` - Asset
            * `liability` - Liability
            * `equity` - Equity
            * `revenue` - Revenue
            * `expense` - Expense
        account_subtype:
          enum:
            - current_assets
            - non_current_assets
            - current_liabilities
            - non_current_liabilities
            - share_capital
            - share_premium
            - reserves
            - retained_earnings
            - revenue
            - other_operating_income
            - finance_income
            - direct_costs
            - operating_expenses
            - finance_costs
            - income_tax
            - ''
          type: string
          x-spec-enum-id: f729e72199be4c29
          description: |-
            Account subtype for granular categorization

            * `current_assets` - Current Assets
            * `non_current_assets` - Non-current Assets
            * `current_liabilities` - Current Liabilities
            * `non_current_liabilities` - Non-current Liabilities
            * `share_capital` - Share Capital
            * `share_premium` - Share Premium
            * `reserves` - Reserves
            * `retained_earnings` - Retained Earnings
            * `revenue` - Revenue
            * `other_operating_income` - Other Operating Income
            * `finance_income` - Finance Income
            * `direct_costs` - Direct Costs
            * `operating_expenses` - Operating Expenses
            * `finance_costs` - Finance Costs
            * `income_tax` - Income Tax
        parent_id:
          type: string
          nullable: true
          description: Parent account identifier - accepts UUID, code, or external_id
        description:
          type: string
          description: Human-readable description of account purpose
        external_id:
          type: string
          description: External system identifier. Enables idempotent creation.
          maxLength: 100
        institution_name:
          type: string
          description: Financial institution name (e.g., 'Barclays Bank PLC')
          maxLength: 255
        iban:
          type: string
          description: International Bank Account Number (EU/UK format)
          maxLength: 34
        sort_code:
          type: string
          description: 'UK sort code (flexible format: XX-XX-XX or XXXXXX)'
          maxLength: 8
        account_number_mask:
          type: string
          description: Masked account number for display (e.g., '****4300')
          maxLength: 20
        balance_behavior:
          enum:
            - ''
            - debit_positive
            - credit_positive
          type: string
          x-spec-enum-id: 3fa8710cd3575d95
          description: >-
            Override balance calculation behavior. Leave blank for standard
            accounting rules.


            * `` - Auto-detect

            * `debit_positive` - Debit Positive

            * `credit_positive` - Credit Positive
        is_cash_account:
          type: boolean
          default: false
          description: Mark as cash or cash equivalent for cash flow purposes
        is_non_cash_expense:
          type: boolean
          default: false
          description: >-
            Mark as non-cash expense (depreciation, amortization). Only valid
            for expense accounts.
        custom_fields:
          description: Business-specific metadata as JSON object
      required:
        - code
    ChartOfAccountDetail:
      type: object
      description: Detailed serializer for account with additional information.
      properties:
        id:
          type: string
          format: uuid
          readOnly: true
          description: Unique account identifier
        code:
          type: string
          readOnly: true
          description: Account code from chart of accounts (e.g., '1000', '4000')
        name:
          type: string
          description: Account name from chart of accounts
          readOnly: true
        currency:
          type: string
          description: Account currency from business base currency (GBP, EUR, USD)
          readOnly: true
        account_type:
          enum:
            - asset
            - liability
            - equity
            - revenue
            - expense
          type: string
          x-spec-enum-id: bee27527493b2230
          readOnly: true
          description: |-
            Account type code (asset, liability, equity, revenue, expense)

            * `asset` - Asset
            * `liability` - Liability
            * `equity` - Equity
            * `revenue` - Revenue
            * `expense` - Expense
        account_type_display:
          type: string
          nullable: true
          description: Human-readable account type (e.g., 'Current Asset', 'Revenue')
          readOnly: true
        account_subtype:
          enum:
            - current_assets
            - non_current_assets
            - current_liabilities
            - non_current_liabilities
            - share_capital
            - share_premium
            - reserves
            - retained_earnings
            - revenue
            - other_operating_income
            - finance_income
            - direct_costs
            - operating_expenses
            - finance_costs
            - income_tax
          type: string
          x-spec-enum-id: f729e72199be4c29
          readOnly: true
          description: >-
            Account subtype code for more granular classification (bank, cash,
            etc.)


            * `current_assets` - Current Assets

            * `non_current_assets` - Non-current Assets

            * `current_liabilities` - Current Liabilities

            * `non_current_liabilities` - Non-current Liabilities

            * `share_capital` - Share Capital

            * `share_premium` - Share Premium

            * `reserves` - Reserves

            * `retained_earnings` - Retained Earnings

            * `revenue` - Revenue

            * `other_operating_income` - Other Operating Income

            * `finance_income` - Finance Income

            * `direct_costs` - Direct Costs

            * `operating_expenses` - Operating Expenses

            * `finance_costs` - Finance Costs

            * `income_tax` - Income Tax
        account_subtype_display:
          type: string
          nullable: true
          description: Account subtype for more granular classification
          readOnly: true
        parent_account_code:
          type: string
          nullable: true
          description: >-
            Parent account code if this is a sub-account (null for top-level
            accounts)
          readOnly: true
        current_balance:
          type: integer
          description: Current balance in cents
          readOnly: true
        current_balance_formatted:
          type: string
          description: Formatted balance with currency symbol (e.g., '£12,500.50')
          readOnly: true
        debit_balance:
          type: integer
          description: Debit balance in cents
          readOnly: true
        credit_balance:
          type: integer
          description: Credit balance in cents
          readOnly: true
        period_balance:
          type: integer
          description: Period balance in cents (null if no period filter applied)
          readOnly: true
        period_balance_formatted:
          type: string
          nullable: true
          description: >-
            Formatted period balance with currency symbol (null if no period
            filter)
          readOnly: true
        has_children:
          type: boolean
          description: Whether this account has sub-accounts (nested hierarchy)
          readOnly: true
        hierarchy_level:
          type: integer
          description: Depth in account hierarchy (0 for root accounts)
          readOnly: true
        is_active:
          type: boolean
          readOnly: true
          description: Whether this account is active and accepting transactions
        description:
          type: string
          readOnly: true
          description: Detailed account description
        institution_name:
          type: string
          readOnly: true
          nullable: true
          description: Bank institution name (for bank accounts only)
        iban:
          type: string
          readOnly: true
          nullable: true
          description: International Bank Account Number (for bank accounts)
        sort_code:
          type: string
          readOnly: true
          nullable: true
          description: 'UK bank sort code (for UK bank accounts, format: XX-XX-XX)'
        account_number_mask:
          type: string
          readOnly: true
          nullable: true
          description: Masked account number showing last 4 digits (e.g., '****5555')
        total_debits:
          type: integer
          description: Total number of debit transactions (count, not amount)
          readOnly: true
        total_credits:
          type: integer
          description: Total number of credit transactions (count, not amount)
          readOnly: true
        last_entry_date:
          type: string
          format: date-time
          nullable: true
          readOnly: true
          description: Date of most recent journal entry
        last_entry_reference:
          type: string
          readOnly: true
          description: Reference of most recent journal entry
        sub_accounts:
          type: array
          items:
            type: object
            additionalProperties: {}
          description: >-
            List of sub-accounts if this is a parent account (empty array if no
            children)
          readOnly: true
      required:
        - account_number_mask
        - account_subtype
        - account_subtype_display
        - account_type
        - account_type_display
        - code
        - credit_balance
        - currency
        - current_balance
        - current_balance_formatted
        - debit_balance
        - description
        - has_children
        - hierarchy_level
        - iban
        - id
        - institution_name
        - is_active
        - last_entry_date
        - last_entry_reference
        - name
        - parent_account_code
        - period_balance
        - period_balance_formatted
        - sort_code
        - sub_accounts
        - total_credits
        - total_debits
    ValidationErrorResponse:
      type: object
      description: Validation error response with field-specific errors
      properties:
        error_code:
          type: string
          description: Error code (e.g., 'validation_error')
        message:
          type: string
          nullable: true
          description: Human-readable error message
        detail:
          type: object
          additionalProperties: {}
          description: Contains field_errors and additional context
        request_id:
          type: string
          description: Request ID for tracing
      required:
        - detail
        - error_code
        - message
    ErrorResponse:
      type: object
      description: Standard error response format
      properties:
        error_code:
          type: string
          description: Error code for programmatic handling
        message:
          type: string
          nullable: true
          description: Human-readable error message
        detail:
          type: object
          additionalProperties: {}
          description: Additional error details including field_errors and debug info
        request_id:
          type: string
          description: Request ID for tracing
      required:
        - error_code
        - message
  securitySchemes:
    PartnerJWT:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Partner-level JWT token (unscoped). Token payload includes `partner_id`.
        Business access is validated via partner ownership. Format: `Bearer
        <your-jwt-token>`


        **Use this for**: Multi-business operations where the business_id is
        specified in the URL and partner has access to multiple businesses.
    BusinessScopedJWT:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Business-scoped JWT token. Token payload includes `business_id` to
        automatically scope requests. Format: `Bearer <your-jwt-token>`


        **Use this for**: Business-specific operations where the business
        context is embedded in the token.
    BasicAuth:
      type: http
      scheme: basic
      description: >-
        Basic authentication for OAuth2 token endpoint. Use partner_uuid:api_key
        as username:password. Example: Authorization: Basic
        base64(partner_uuid:api_key)
    BearerUnscoped:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Partner (unscoped) JWT Bearer token. Obtain via POST
        /v1/platform/oauth2/token with Basic auth (partner_uuid:api_key). Use
        header: Authorization: Bearer {access_token}
    BearerBusinessScoped:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Business-scoped JWT Bearer token. Obtain via POST
        /v1/platform/{business_id}/oauth2/token/ using a partner Bearer token.
        Only valid for endpoints whose URL contains that business_id.

````