{"openapi":"3.1.0","info":{"title":"GET /api/v1/contracts/{contract_id}/suggested-invoices","version":"1.0.0","description":"Suggested invoices to link"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/contracts/{contract_id}/suggested-invoices":{"get":{"tags":["contracts"],"summary":"Suggested invoices to link","description":"Rank the business's unlinked (non-void, non-draft) invoices as likely matches for this contract, using deterministic heuristics: same customer, issue date inside the contract term, exact amount matches (order line / per-period / remaining value), and description-token overlap. Returns the top matches with human-readable reasons for each score.","operationId":"suggested_contract_invoices_api_v1_contracts__contract_id__suggested_invoices_get","parameters":[{"name":"contract_id","in":"path","required":true,"schema":{"type":"string","title":"Contract Id"}},{"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_SuggestedInvoicesResponse_"}}}},"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"}}}},"404":{"description":"Not Found - Resource does not exist","content":{"application/json":{"example":{"detail":"Resource not found"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"SuccessEnvelope_SuggestedInvoicesResponse_":{"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/SuggestedInvoicesResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[SuggestedInvoicesResponse]"},"SuggestedInvoice":{"properties":{"id":{"type":"string","title":"Id"},"number":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Number"},"date":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Date","description":"Issue date (the invoice's created_at date)."},"amount_cents":{"type":"integer","title":"Amount Cents","default":0},"customer_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Customer Name"},"score":{"type":"integer","title":"Score","default":0},"reasons":{"items":{"type":"string"},"type":"array","title":"Reasons"}},"type":"object","required":["id"],"title":"SuggestedInvoice","description":"An unlinked invoice ranked as a likely match for a contract.\n\nProduced by the deterministic link-suggestion scorer (see\n``ContractService.suggested_invoices``). ``reasons`` are short\nhuman-readable explanations of the score components so the UI can show\n*why* the invoice was suggested."},"SuggestedInvoicesResponse":{"properties":{"items":{"items":{"$ref":"#/components/schemas/SuggestedInvoice"},"type":"array","title":"Items"}},"type":"object","title":"SuggestedInvoicesResponse","description":"Top link suggestions for a contract, best match first."},"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":[]}]}