{"openapi":"3.1.0","info":{"title":"GET /api/v1/close/verification","version":"1.0.0","description":"Close verification report"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/close/verification":{"get":{"tags":["close-verification"],"summary":"Close verification report","description":"Run the month-end verification checks for a period and return the exceptions: uncategorized transactions, miscategorized candidates, transfer pairing, counterparty vs description, cash inflows and manual journal entries.","operationId":"get_close_verification_report","parameters":[{"name":"start_date","in":"query","required":true,"schema":{"type":"string","description":"Period start (YYYY-MM-DD)","title":"Start Date"},"description":"Period start (YYYY-MM-DD)"},{"name":"end_date","in":"query","required":true,"schema":{"type":"string","description":"Period end (YYYY-MM-DD)","title":"End Date"},"description":"Period end (YYYY-MM-DD)"},{"name":"checks","in":"query","required":false,"schema":{"type":"array","items":{"type":"string"},"description":"Checks to run (comma-separated; default all): uncategorized_transactions, miscategorized_candidates, transfer_pairing, counterparty_mismatch, cash_inflows, manual_journal_entries, shopify_tie_out","default":[],"title":"Checks"},"description":"Checks to run (comma-separated; default all): uncategorized_transactions, miscategorized_candidates, transfer_pairing, counterparty_mismatch, cash_inflows, manual_journal_entries, shopify_tie_out"},{"name":"max_rows_per_check","in":"query","required":false,"schema":{"type":"integer","maximum":5000,"minimum":0,"description":"Exception rows returned per check; counts always cover all rows","default":100,"title":"Max Rows Per Check"},"description":"Exception rows returned per check; counts always cover all rows"},{"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/SuccessEnvelope_CloseVerificationResponse_"}}}},"400":{"description":"Bad Request - Invalid input","content":{"application/json":{"example":{"error":"validation_error","message":"Validation failed: due_date: Input should be a valid date","errors":{"due_date":"Input should be a valid date"},"code":"GEN_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized - Missing or expired token, an MCP OAuth token used against the REST API, or no access to this business","content":{"application/json":{"example":{"error":"unauthorized","message":"Authentication required","code":"AUTH_001","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden - Insufficient permissions","content":{"application/json":{"example":{"error":"forbidden","message":"You don't have permission to access this resource","code":"AUTH_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"error":"validation_error","message":"Validation failed: amount: Input should be a valid integer","errors":{"amount":"Input should be a valid integer"},"code":"GEN_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"}}}}},"x-fastapi-operation-id":"get_close_verification_report_api_v1_close_verification_get"}}},"components":{"schemas":{"CloseVerificationCheck":{"properties":{"check":{"type":"string","title":"Check"},"title":{"type":"string","title":"Title"},"description":{"type":"string","title":"Description"},"status":{"type":"string","enum":["ok","review","blocking"],"title":"Status"},"count":{"type":"integer","title":"Count","description":"Exceptions found (blocking + review); info rows are separate"},"blocking_count":{"type":"integer","title":"Blocking Count","default":0},"review_count":{"type":"integer","title":"Review Count","default":0},"info_count":{"type":"integer","title":"Info Count","default":0},"total_amount_cents":{"type":"integer","title":"Total Amount Cents","description":"Sum of absolute amounts across the exception rows","default":0},"counts_by_issue":{"additionalProperties":{"type":"integer"},"type":"object","title":"Counts By Issue"},"suggested_fix":{"type":"string","title":"Suggested Fix"},"rows":{"items":{"$ref":"#/components/schemas/CloseVerificationRow"},"type":"array","title":"Rows"},"rows_truncated":{"type":"boolean","title":"Rows Truncated","description":"True when rows was capped by max_rows_per_check","default":false},"details":{"additionalProperties":true,"type":"object","title":"Details"}},"type":"object","required":["check","title","description","status","count","suggested_fix"],"title":"CloseVerificationCheck","description":"Result of one check."},"CloseVerificationCheckSummary":{"properties":{"count":{"type":"integer","title":"Count"},"blocking_count":{"type":"integer","title":"Blocking Count"},"review_count":{"type":"integer","title":"Review Count"},"status":{"type":"string","enum":["ok","review","blocking"],"title":"Status"}},"type":"object","required":["count","blocking_count","review_count","status"],"title":"CloseVerificationCheckSummary"},"CloseVerificationResponse":{"properties":{"business_id":{"type":"string","title":"Business Id"},"period_start":{"type":"string","title":"Period Start"},"period_end":{"type":"string","title":"Period End"},"checks_run":{"items":{"type":"string"},"type":"array","title":"Checks Run"},"summary":{"$ref":"#/components/schemas/CloseVerificationSummary"},"checks":{"items":{"$ref":"#/components/schemas/CloseVerificationCheck"},"type":"array","title":"Checks"}},"type":"object","required":["business_id","period_start","period_end","checks_run","summary","checks"],"title":"CloseVerificationResponse"},"CloseVerificationRow":{"properties":{"check":{"type":"string","title":"Check","description":"Check that produced the row"},"issue":{"type":"string","title":"Issue","description":"Machine-readable issue kind within the check"},"severity":{"type":"string","enum":["blocking","review","info"],"title":"Severity","description":"blocking = fix before closing, review = needs a human look, info = listed for completeness"},"transaction_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Transaction Id"},"journal_entry_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Journal Entry Id"},"date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Date","description":"YYYY-MM-DD"},"amount_cents":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Amount Cents","description":"Cash-flow signed cents for a transaction (positive = money in); total debits for a journal entry"},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description"},"counterparty":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Counterparty"},"account":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Account","description":"Bank/card account name"},"current_ledger_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Current Ledger Id"},"current_ledger":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Current Ledger"},"expected_ledger_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Expected Ledger Id"},"expected_ledger":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Expected Ledger"},"why":{"type":"string","title":"Why","description":"Why this row is an exception"},"suggested_fix":{"type":"string","title":"Suggested Fix","description":"What to do about it"},"related_ids":{"items":{"type":"string"},"type":"array","title":"Related Ids","description":"Ids of related rows (transfer partner, bank rule, default)"},"details":{"additionalProperties":true,"type":"object","title":"Details"}},"type":"object","required":["check","issue","severity","why","suggested_fix"],"title":"CloseVerificationRow","description":"One exception found by a check."},"CloseVerificationSummary":{"properties":{"status":{"type":"string","enum":["ok","review","blocking"],"title":"Status"},"total_exceptions":{"type":"integer","title":"Total Exceptions"},"blocking_count":{"type":"integer","title":"Blocking Count"},"review_count":{"type":"integer","title":"Review Count"},"total_amount_cents":{"type":"integer","title":"Total Amount Cents"},"checks":{"additionalProperties":{"$ref":"#/components/schemas/CloseVerificationCheckSummary"},"type":"object","title":"Checks"}},"type":"object","required":["status","total_exceptions","blocking_count","review_count","total_amount_cents","checks"],"title":"CloseVerificationSummary"},"SuccessEnvelope_CloseVerificationResponse_":{"properties":{"success":{"type":"boolean","title":"Success","default":true},"message":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Message"},"code":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Code"},"data":{"anyOf":[{"$ref":"#/components/schemas/CloseVerificationResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[CloseVerificationResponse]"},"ErrorResponse":{"title":"ErrorResponse","type":"object","description":"Envelope returned by every non-2xx response. Branch on `code` (stable) rather than `message` (human-readable, may change).","required":["error","message","code"],"properties":{"error":{"type":"string","description":"Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`."},"message":{"type":"string","description":"Human-readable explanation, safe to show to end users."},"code":{"type":"string","description":"Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`)."},"request_id":{"type":"string","description":"Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied."},"errors":{"type":"object","additionalProperties":{"type":"string"},"description":"Field-level validation messages keyed by field name. Present on 400/422 validation failures only."}}}},"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Token","description":"API token authentication. Format: `Bearer dz_...`"}}},"security":[{"BearerAuth":[]}]}