---
title: "Analyze accounts and suggest a Chart of Accounts"
method: GET
path: "/v3/{ledgerName}/analyze-accounts"
tags: ["Accounts"]
---

# Analyze accounts and suggest a Chart of Accounts

`GET /v3/{ledgerName}/analyze-accounts`

## Request

- Base URL: `http://localhost:9000`
- URL: `http://localhost:9000/v3/{ledgerName}/analyze-accounts`
- Auth: one of:
  - HTTP bearer
  - none

Scans all accounts in a ledger, discovers address patterns, and returns a
suggested Chart of Accounts. Useful after a mirror import to understand
account structure. Requires `ledger:read` scope.

## Path parameters

- `ledgerName` string, required

## Query parameters

- `variableThreshold` integer

## Headers

- `X-Consistency` 'linearizable' | 'stale'

## Response `200`

Analysis completed successfully

- AnalyzeAccountsResponse
  - `data` object, required
    - `patterns` AccountPattern[]
      - `pattern` string
      - `accountCount` integer
      - `assets` string[]
      - `metadataKeys` string[]
      - `segments` PatternSegment[]
        - `position` integer
        - `type` 'fixed' | 'variable'
        - `fixedValue` string
        - `variableName` string
        - `inferredPattern` string
        - `uniqueValues` integer: Number of distinct values observed at this segment position.
        - `examples` string[]
    - `totalAccounts` integer

## Other responses

- `400`: Bad request
- `401`: Authentication required (missing or invalid JWT token)
- `403`: Insufficient permissions (missing required scope)
- `404`: Not found
- `405`: Method not allowed
- `500`: Internal server error
- `503`: Service unavailable — the server cannot serve the request right now but an immediate retry can succeed. The `errorCode` field discriminates the cause: `NO_LEADER` (no elected Raft leader), `CACHE_HORIZON_EXCEEDED` (admission snapshot too old, retry against a fresh one), `UNAVAILABLE` (an internal forwarded stream was torn down mid-transfer), or the reason of any domain error of the unavailable kind (e.g. `INDEX_BUILDING`).

## Changes

- **2026-11-03** `f5e817eca038`: 1 info
  - api operation id `analyzeAccounts` removed and replaced with `v3AnalyzeAccounts`
- **2026-10-08** `3da23d327316`: 2 info
  - added the media type `text/plain` for the response with the status `401`
  - added the media type `text/plain` for the response with the status `403`
- **2026-10-08** `b3ee1959d86a`: 1 info
  - added the new optional `header` request parameter `X-Consistency`
- **2026-09-30** `b747efd5cd77`: 1 info
  - endpoint added
- **2026-09-29** `6ff73ac9a6bd`: 1 breaking
  - api path removed without deprecation

[Operation history](https://skmtc.dev/formancehq/apis/ledger-api/changes/v3/:ledgerName/analyze-accounts/get.md)

---

[API](https://skmtc.dev/formancehq/apis/ledger-api.md) - [All operations](https://skmtc.dev/formancehq/apis/ledger-api/llms.txt) - [OpenAPI document](https://skmtc.dev/formancehq/apis/ledger-api/revisions/f5e817eca038?raw)
