{"openapi":"3.1.0","info":{"title":"POST /api/v1/ledgers/suggest-cleanup","version":"1.0.0","description":"AI account cleanup suggestions"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/ledgers/suggest-cleanup":{"post":{"tags":["ledgers"],"summary":"AI account cleanup suggestions","description":"Get AI-powered suggestions for chart of accounts cleanup. Read-only; rate limited per user and gated on monthly AI quota.","operationId":"suggest_cleanup_api_v1_ledgers_suggest_cleanup_post","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Authorization"}},{"name":"x-business-id","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Business-Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuggestAccountCleanupResponse"}}}},"401":{"description":"Unauthorized - Authentication required","content":{"application/json":{"example":{"detail":"Not authenticated"}}}},"403":{"description":"Forbidden - Insufficient permissions","content":{"application/json":{"example":{"detail":"Not enough permissions"}}}},"429":{"description":"Too Many Requests - Rate limit exceeded","content":{"application/json":{"example":{"detail":"Rate limit exceeded"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"AccountCleanupSuggestionItem":{"properties":{"type":{"type":"string","enum":["merge","cleanup","reclassify","unused"],"title":"Type","description":"Kind of suggestion: merge, cleanup, reclassify, or unused."},"title":{"type":"string","title":"Title","description":"Short headline (<=80 chars)."},"description":{"type":"string","title":"Description","description":"Explanation of the suggestion (<=240 chars)."},"affected_accounts":{"items":{"type":"string"},"type":"array","title":"Affected Accounts","description":"Display names of the accounts affected."},"affected_ledger_ids":{"items":{"type":"string"},"type":"array","title":"Affected Ledger Ids","description":"Resolved ledger UUIDs for the affected accounts. Use these when taking action (e.g. calling /ledgers/merge)."},"suggested_target_ledger_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Suggested Target Ledger Id","description":"For 'merge' suggestions, the recommended target ledger UUID to merge the others into. Null for non-merge suggestions."}},"type":"object","required":["type","title","description"],"title":"AccountCleanupSuggestionItem","description":"A single chart-of-accounts cleanup suggestion from the AI.\n\n``affected_ledger_ids`` is the server-resolved list of real ledger\nUUIDs the suggestion refers to — clients should use these IDs (not\n``affected_accounts``, which is display text) when acting on a\nsuggestion (e.g. wiring a \"merge these\" button to\n:class:`LedgerMergeRequest`)."},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"SuggestAccountCleanupResponse":{"properties":{"suggestions":{"items":{"$ref":"#/components/schemas/AccountCleanupSuggestionItem"},"type":"array","title":"Suggestions"},"cached":{"type":"boolean","title":"Cached","description":"True if the response was served from short-TTL cache.","default":false}},"type":"object","title":"SuggestAccountCleanupResponse"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}},"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Token","description":"API token authentication. Format: `Bearer dz_...`"}}},"security":[{"BearerAuth":[]}]}