{"openapi":"3.1.0","info":{"title":"GET /api/v1/invoices/collections","version":"1.0.0","description":"AR collections dashboard"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/invoices/collections":{"get":{"tags":["invoices"],"summary":"AR collections dashboard","description":"Returns overdue invoices plus AR collection workflow run history and recorded collection reminder emails when present in the database.","operationId":"get_invoice_collections_api_v1_invoices_collections_get","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/SuccessEnvelope_InvoiceCollectionsResponse_"}}}},"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"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"CollectionOverdueInvoice":{"properties":{"id":{"type":"string","title":"Id"},"invoice_number":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Invoice Number"},"customer_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Customer Id"},"customer_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Customer Name"},"customer_email":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Customer Email"},"status":{"type":"string","title":"Status"},"total":{"type":"integer","title":"Total","description":"Invoice total in cents."},"total_paid":{"type":"integer","title":"Total Paid","description":"Total paid in cents.","default":0},"balance_due":{"type":"integer","title":"Balance Due","description":"Remaining balance in cents."},"due_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Due Date"},"days_past_due":{"type":"integer","title":"Days Past Due","description":"Days past the due date."},"suggested_reminder_type":{"type":"string","title":"Suggested Reminder Type","description":"Recommended tone: 'friendly', 'firm', or 'final'."},"reminder_count":{"type":"integer","title":"Reminder Count","description":"Collection reminders already recorded for this invoice.","default":0},"last_reminder_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Last Reminder At","description":"ISO timestamp of the most recent collection reminder."}},"type":"object","required":["id","status","total","balance_due","days_past_due","suggested_reminder_type"],"title":"CollectionOverdueInvoice","description":"An overdue invoice surfaced on the Collections tab."},"CollectionReminderHistoryItem":{"properties":{"id":{"type":"string","title":"Id"},"invoice_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Invoice Id"},"reminder_type":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Reminder Type"},"days_overdue":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Days Overdue"},"subject":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Subject"},"recipient_email":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Recipient Email"},"recipient_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Recipient Name"},"processing_status":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Processing Status"},"created_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created At"}},"type":"object","required":["id"],"title":"CollectionReminderHistoryItem","description":"A collection reminder email stored in the emails table."},"CollectionWorkflowRun":{"properties":{"id":{"type":"string","title":"Id"},"workflow_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Workflow Id"},"status":{"type":"string","title":"Status"},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description"},"started_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Started At"},"created_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created At"},"completed_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Completed At"},"total_overdue_invoices":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Total Overdue Invoices"},"total_amount_cents":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Total Amount Cents"},"friendly_count":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Friendly Count"},"firm_count":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Firm Count"},"final_count":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Final Count"},"emails_sent":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Emails Sent"},"error_message":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Error Message"}},"type":"object","required":["id","status"],"title":"CollectionWorkflowRun","description":"A recorded AR collection workflow run from the tasks table."},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"InvoiceCollectionsResponse":{"properties":{"as_of_date":{"type":"string","title":"As Of Date","description":"Report date in YYYY-MM-DD format."},"workflow_id":{"type":"string","title":"Workflow Id","description":"Deterministic Temporal workflow ID for AR collection runs."},"total_overdue_count":{"type":"integer","title":"Total Overdue Count"},"total_overdue_amount_cents":{"type":"integer","title":"Total Overdue Amount Cents"},"overdue_invoices":{"items":{"$ref":"#/components/schemas/CollectionOverdueInvoice"},"type":"array","title":"Overdue Invoices","description":"Open or partially-paid invoices past their due date."},"latest_workflow":{"anyOf":[{"$ref":"#/components/schemas/CollectionWorkflowRun"},{"type":"null"}],"description":"Most recent AR collection workflow run, if any."},"workflow_history":{"items":{"$ref":"#/components/schemas/CollectionWorkflowRun"},"type":"array","title":"Workflow History","description":"Recent AR collection workflow runs newest first."},"reminder_history":{"items":{"$ref":"#/components/schemas/CollectionReminderHistoryItem"},"type":"array","title":"Reminder History","description":"Collection reminder emails recorded in the system."}},"type":"object","required":["as_of_date","workflow_id","total_overdue_count","total_overdue_amount_cents"],"title":"InvoiceCollectionsResponse","description":"Collections dashboard: overdue invoices plus workflow and reminder history."},"SuccessEnvelope_InvoiceCollectionsResponse_":{"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/InvoiceCollectionsResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[InvoiceCollectionsResponse]"},"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":[]}]}