{"openapi":"3.1.0","info":{"title":"POST /api/v1/bills/upcoming","version":"1.0.0","description":"Create an upcoming bill (optionally recurring)"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/bills/upcoming":{"post":{"tags":["bills"],"summary":"Create an upcoming bill (optionally recurring)","description":"Create one expected bill, or a recurring series. A recurring request materialises every projected occurrence up front (capped by `recurrence.occurrences`), so each one can be edited, deleted or matched independently. Returns every occurrence created.","operationId":"create_upcoming_bill_api_v1_bills_upcoming_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"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpcomingBillCreateRequest"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessEnvelope_UpcomingBillListResponse_"}}}},"400":{"description":"Bad Request - Invalid input","content":{"application/json":{"example":{"detail":"Invalid request parameters"}}}},"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_UpcomingBillListResponse_":{"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/UpcomingBillListResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[UpcomingBillListResponse]"},"UpcomingBillCreateRequest":{"properties":{"vendor_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Vendor Id","description":"Vendor this is expected from, when one exists."},"vendor_name":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Vendor Name","description":"Payee name when there is no vendor record yet."},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description","description":"What the bill is for."},"estimated_amount":{"type":"integer","minimum":0.0,"title":"Estimated Amount","description":"Estimated amount in cents. An estimate, not a payable."},"expected_date":{"type":"string","format":"date","title":"Expected Date","description":"When the bill is expected (first occurrence for a series)."},"notes":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Notes","description":"Free-form notes."},"recurrence":{"anyOf":[{"$ref":"#/components/schemas/UpcomingBillRecurrence"},{"type":"null"}],"description":"Omit for a single expected bill."}},"type":"object","required":["estimated_amount","expected_date"],"title":"UpcomingBillCreateRequest","description":"Create a one-off expected bill, or a recurring series of them."},"UpcomingBillListResponse":{"properties":{"items":{"items":{"$ref":"#/components/schemas/UpcomingBillResponse"},"type":"array","title":"Items"},"total":{"type":"integer","title":"Total","description":"Number of rows returned."},"total_estimated_amount":{"type":"integer","title":"Total Estimated Amount","description":"Sum of estimated_amount over the returned `expected` rows, in cents. A forecast figure — never an AP balance."}},"type":"object","required":["items","total","total_estimated_amount"],"title":"UpcomingBillListResponse","description":"Expected bills within a date horizon.\n\nNot cursor-paginated: the list is bounded by the requested date window and\na hard row cap, and the client sums it for a forecast total, so a partial\npage would be actively misleading."},"UpcomingBillRecurrence":{"properties":{"frequency":{"type":"string","enum":["daily","weekly","biweekly","monthly","quarterly","annually"],"title":"Frequency","description":"How often the bill is expected."},"day_of_week":{"anyOf":[{"type":"integer","maximum":6.0,"minimum":0.0},{"type":"null"}],"title":"Day Of Week","description":"0=Monday … 6=Sunday. Used by weekly/biweekly series to pin the occurrence to a weekday; ignored otherwise."},"day_of_month":{"anyOf":[{"type":"integer","maximum":31.0,"minimum":1.0},{"type":"null"}],"title":"Day Of Month","description":"Day of month for monthly/quarterly/annual series. Clamped to the last day of shorter months."},"end_date":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"End Date","description":"Stop projecting occurrences after this date."},"occurrences":{"type":"integer","maximum":24.0,"minimum":1.0,"title":"Occurrences","description":"How many occurrences to project (max 24). Projection stops earlier if end_date is reached.","default":12}},"type":"object","required":["frequency"],"title":"UpcomingBillRecurrence","description":"Recurrence for an expected bill, e.g. \"every second Friday\"."},"UpcomingBillResponse":{"properties":{"id":{"type":"string","title":"Id"},"business_id":{"type":"string","title":"Business Id"},"vendor_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Vendor Id"},"vendor_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Vendor Name"},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description"},"estimated_amount":{"type":"integer","title":"Estimated Amount","description":"Estimated amount in cents."},"expected_date":{"type":"string","format":"date","title":"Expected Date"},"status":{"type":"string","title":"Status"},"series_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Series Id","description":"Shared by every occurrence generated together."},"frequency":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Frequency"},"day_of_week":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Day Of Week"},"day_of_month":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Day Of Month"},"bill_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Bill Id","description":"The real bill this became, once converted or matched."},"notes":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Notes"},"is_estimate":{"type":"boolean","title":"Is Estimate","description":"Always true. Upcoming bills are forecast rows: they carry no journal entries and are excluded from AP totals, aged payables and the balance sheet.","default":true},"created_at":{"type":"string","format":"date-time","title":"Created At"},"updated_at":{"type":"string","format":"date-time","title":"Updated At"}},"type":"object","required":["id","business_id","estimated_amount","expected_date","status","created_at","updated_at"],"title":"UpcomingBillResponse","description":"A projected bill occurrence."},"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":[]}]}