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

# Archive account (soft delete)

> 
        Archive an account (soft delete).

        **Validations:**
        - Cannot archive account with non-zero balance
        - Cannot archive account with active child accounts

        Returns the archived account with is_active set to false.

        **Flexible lookup:** The account_id parameter accepts UUID, account code, or external_id.
        



## OpenAPI

````yaml DELETE /v1/platform/businesses/{business_id}/general-ledger/chart-of-accounts/{account_id}/
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/{account_id}/:
    delete:
      tags:
        - General Ledger
      summary: Archive account (soft delete)
      description: |2-

                Archive an account (soft delete).

                **Validations:**
                - Cannot archive account with non-zero balance
                - Cannot archive account with active child accounts

                Returns the archived account with is_active set to false.

                **Flexible lookup:** The account_id parameter accepts UUID, account code, or external_id.
                
      operationId: archive_account
      parameters:
        - in: path
          name: account_id
          schema:
            type: string
            format: uuid
          description: A UUID string identifying this account.
          required: true
        - in: path
          name: business_id
          schema:
            type: string
            pattern: ^[0-9a-f-]+$
          required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChartOfAccountDetail'
              examples:
                ArchivedAccountResponse:
                  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: 0
                    current_balance_formatted: £0.00
                    debit_balance: 0
                    credit_balance: 0
                    has_children: false
                    hierarchy_level: 0
                    is_active: false
                    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: Archived 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:
    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.

````