{"openapi":"3.1.0","info":{"title":"POST /api/v1/bills","version":"1.0.0","description":"Create bill"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/bills":{"post":{"tags":["bills"],"summary":"Create bill","description":"Create a new bill in draft status. Optionally include 'recurring' config to also create a recurring template.","operationId":"create_bill_api_v1_bills_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/BillCreateRequest"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessEnvelope_BillResponse_"}}}},"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"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"BillCreateRequest":{"properties":{"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description","description":"Description of what the bill is for."},"currency":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Currency","description":"Currency for the bill (USD, CAD, AUD, EUR, or GBP). Defaults to business default.","default":"USD"},"vendor_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Vendor Id","description":"UUID of the vendor this bill is from."},"bill_number":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Bill Number","description":"Bill/invoice number from the vendor. Auto-generated if not provided."},"type":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Type","description":"Bill type: 'recurring' (monthly rent, subscriptions) or 'one_time'."},"expected_amount":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Expected Amount","description":"Expected bill amount in cents."},"expected_paid_on_date":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string"},{"type":"null"}],"title":"Expected Paid On Date","description":"Expected payment date (ISO 8601 format)."},"s3_key":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"S3 Key","description":"S3 key of uploaded bill document (PDF/image)."},"recurring":{"anyOf":[{"$ref":"#/components/schemas/RecurringConfig"},{"type":"null"}],"description":"If provided, creates a recurring template for this bill."},"submitted_for_review":{"type":"boolean","title":"Submitted For Review","description":"When true, marks this draft as a client-submitted expense and notifies the assigned advisor to confirm or deny it.","default":false}},"type":"object","title":"BillCreateRequest","description":"Schema for creating a new bill (expense from a vendor).\n\nBills track money owed to vendors for goods or services received.\nThey progress through statuses: draft → forecasted → received → paid.","example":{"description":"Monthly office rent - January 2024","expected_amount":250000,"expected_paid_on_date":"2024-01-31T00:00:00Z","type":"recurring","vendor_id":"019ab37c-vend-7000-8000-000000000001"}},"BillResponse":{"properties":{"id":{"type":"string","title":"Id","description":"Bill UUID."},"business_id":{"type":"string","title":"Business Id","description":"Business UUID."},"currency":{"type":"string","title":"Currency","description":"Currency for the bill (USD, CAD, AUD, EUR, or GBP).","default":"USD"},"status":{"anyOf":[{"type":"integer"},{"type":"string"}],"title":"Status","description":"Bill status (see schema description)."},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description","description":"Bill description."},"bill_number":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Bill Number","description":"Bill/invoice number from vendor."},"vendor_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Vendor Id","description":"Vendor UUID."},"vendor_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Vendor Name","description":"Vendor name (resolved)."},"vendor_email":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Vendor Email","description":"Vendor email (resolved)."},"type":{"anyOf":[{"type":"integer"},{"type":"string"}],"title":"Type","description":"Type: 'recurring' or 'one_time'."},"expected_amount":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Expected Amount","description":"Expected amount in cents."},"expected_paid_on_date":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Expected Paid On Date","description":"Expected payment date."},"total_paid":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Total Paid","description":"Total amount paid so far in cents."},"amount":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Amount","description":"Actual bill amount in cents."},"s3_key":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"S3 Key","description":"S3 key of attached document."},"received_on":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Received On","description":"Date bill/goods received."},"due_on":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Due On","description":"Payment due date."},"paid_on":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Paid On","description":"Date fully paid."},"payment_method":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Payment Method","description":"Payment method (Wire Transfer, ACH, Check, Credit Card). Prefers the user-set override; otherwise inferred from a linked payment."},"created_at":{"type":"string","format":"date-time","title":"Created At","description":"Creation timestamp."},"updated_at":{"type":"string","format":"date-time","title":"Updated At","description":"Last update timestamp."},"signed_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Signed Url","description":"Signed URL to view attached document."},"payments":{"items":{"additionalProperties":true,"type":"object"},"type":"array","title":"Payments","description":"List of payments made.","default":[]},"vendor_credit_applications":{"items":{"$ref":"#/components/schemas/BillVendorCreditApplicationResponse"},"type":"array","title":"Vendor Credit Applications","description":"Vendor credits applied to this bill (reduces balance due)."},"total_credits_applied":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Total Credits Applied","description":"Sum of applied vendor credits in cents."},"balance_due":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Balance Due","description":"Remaining balance in cents (amount - total_paid - total_credits_applied). Zero for paid/canceled bills."},"journal_entries":{"items":{"additionalProperties":true,"type":"object"},"type":"array","title":"Journal Entries","description":"Associated accounting entries.","default":[]},"recurring_template_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Recurring Template Id","description":"ID of recurring template if this bill was generated from one, or if one was created."},"source_inventory_order_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source Inventory Order Id","description":"Source PO that produced this bill via the PO lifecycle. Non-null means this bill is visible on the Inventory -> Accounts Payable tab."},"match_status":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Match Status","description":"Three-way match outcome: matched, qty_variance, price_variance, qty_and_price_variance, unmatched, no_po. None until the matcher has run on the bill."},"match_variance_qty":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Match Variance Qty","description":"Signed unit variance across all lines (received - ordered). Positive = over-received; negative = short."},"match_variance_amount_cents":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Match Variance Amount Cents","description":"Signed amount variance in cents (bill amount - PO total). Positive = vendor billed more than ordered; negative = less."},"contract_match":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Contract Match","description":"Vendor contract comparison: matched, over_contract, needs_review, no_contract, or unknown."},"vendor_contract_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Vendor Contract Id","description":"Vendor contract UUID used for the last contract comparison."},"thread":{"anyOf":[{"$ref":"#/components/schemas/BillThreadResponse"},{"type":"null"}],"description":"Discussion thread and comment summary for this bill"}},"type":"object","required":["id","business_id","status","type","created_at","updated_at"],"title":"BillResponse","description":"Response schema for a bill.\n\nContains all bill details including vendor info, payment status,\nand associated journal entries for accounting.\n\n**Status values:**\n- `draft`: Bill created but not yet approved\n- `forecasted`: Approved, expected to be paid\n- `received`: Bill/goods received, liability recorded\n- `partially_paid`: Some payments and/or vendor credits applied\n- `paid`: Fully paid (cash and/or vendor credits)\n- `canceled`: Cancelled, will not be paid","example":{"amount":250000,"business_id":"019ab37c-bus1-7000-8000-000000000001","created_at":"2024-01-10T10:30:00Z","description":"Monthly office rent - January 2024","due_on":"2024-01-31T00:00:00Z","expected_amount":250000,"id":"019ab37c-bill-7000-8000-000000000001","journal_entries":[],"payments":[],"received_on":"2024-01-15T00:00:00Z","status":"received","type":"recurring","updated_at":"2024-01-15T14:00:00Z","vendor_email":"billing@abcproperty.com","vendor_id":"019ab37c-vend-7000-8000-000000000001","vendor_name":"ABC Property Management"}},"BillThreadResponse":{"properties":{"thread_id":{"type":"string","title":"Thread Id","description":"Thread UUID"},"comment_count":{"type":"integer","title":"Comment Count","description":"Number of comments on the thread"},"comments":{"items":{"additionalProperties":true,"type":"object"},"type":"array","title":"Comments","description":"Thread comments (detail view)"}},"additionalProperties":true,"type":"object","required":["thread_id","comment_count"],"title":"BillThreadResponse","description":"Thread summary embedded on bill detail responses."},"BillVendorCreditApplicationResponse":{"properties":{"id":{"type":"string","title":"Id","description":"Application record ID"},"vendor_credit_id":{"type":"string","title":"Vendor Credit Id","description":"Source vendor credit ID"},"bill_id":{"type":"string","title":"Bill Id","description":"Bill the credit was applied to"},"amount_applied":{"type":"integer","title":"Amount Applied","description":"Amount applied in cents"},"amount_applied_dollars":{"anyOf":[{"type":"string","pattern":"^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$"},{"type":"null"}],"title":"Amount Applied Dollars","description":"Amount applied in dollars"},"applied_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Applied At","description":"When the credit was applied"},"applied_by_user_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Applied By User Id","description":"User who applied the credit"},"vendor_credit_number":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Vendor Credit Number","description":"Vendor credit number (e.g. VC-0001)"},"journal_entry_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Journal Entry Id","description":"Journal entry posted when the credit was applied to this bill"}},"type":"object","required":["id","vendor_credit_id","bill_id","amount_applied"],"title":"BillVendorCreditApplicationResponse","description":"Vendor credit applied against a bill (embedded on bill detail/list)."},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"RecurringConfig":{"properties":{"frequency":{"type":"string","enum":["daily","weekly","biweekly","monthly","quarterly","annually"],"title":"Frequency","description":"How often to generate bills."},"start_date":{"type":"string","format":"date","title":"Start Date","description":"When to start generating bills (first occurrence)."},"name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Name","description":"Name for the recurring template. Defaults to bill description."},"end_date":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"End Date","description":"Stop generating after this date (null = indefinite). If both end_date and max_occurrences are set, whichever is reached first stops generation."},"day_of_month":{"anyOf":[{"type":"integer","maximum":31.0,"minimum":1.0},{"type":"null"}],"title":"Day Of Month","description":"Day of month (1-31). Only applies to monthly/quarterly/annually frequencies; ignored for daily/weekly/biweekly. If the day doesn't exist in a month (e.g., 31 in February), generates on the last day instead. If omitted, uses the day from start_date."},"day_of_week":{"anyOf":[{"type":"integer","maximum":6.0,"minimum":0.0},{"type":"null"}],"title":"Day Of Week","description":"Day of week (0=Monday, 6=Sunday). Only applies to weekly/biweekly frequencies; ignored for other frequencies. If omitted, uses the weekday from start_date."},"days_until_due":{"type":"integer","maximum":365.0,"minimum":0.0,"title":"Days Until Due","description":"Days from generation until due date.","default":30},"max_occurrences":{"anyOf":[{"type":"integer","minimum":1.0},{"type":"null"}],"title":"Max Occurrences","description":"Stop after generating this many bills (null = unlimited). If both end_date and max_occurrences are set, whichever is reached first stops generation."}},"type":"object","required":["frequency","start_date"],"title":"RecurringConfig","description":"Recurring configuration that can be embedded in bill create/update requests.","example":{"day_of_month":1,"days_until_due":15,"frequency":"monthly","start_date":"2026-02-01"}},"SuccessEnvelope_BillResponse_":{"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/BillResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[BillResponse]"},"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":[]}]}