{"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","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"},"example":{"description":"Quarterly liability insurance premium","estimated_amount":180000,"expected_date":"2026-04-01","vendor_id":"0192a4f0-1b2c-7d3e-8f4a-5b6c7d8e9f02"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessEnvelope_UpcomingBillListResponse_"}}}},"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/invalid token 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"}}}},"404":{"description":"Not Found - Resource does not exist","content":{"application/json":{"example":{"error":"not_found","message":"Resource not found","code":"NOT_FOUND_001","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":"create_upcoming_bill_api_v1_bills_upcoming_post"}}},"components":{"schemas":{"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.","example":{"description":"Quarterly liability insurance premium","estimated_amount":180000,"expected_date":"2026-04-01","vendor_id":"0192a4f0-1b2c-7d3e-8f4a-5b6c7d8e9f02"},"examples":[{"description":"Quarterly liability insurance premium","estimated_amount":180000,"expected_date":"2026-04-01","vendor_id":"0192a4f0-1b2c-7d3e-8f4a-5b6c7d8e9f02"}]},"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."},"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":[]}]}