{"openapi":"3.1.0","info":{"title":"POST /api/v1/bills/{bill_id}/submit-for-approval","version":"1.0.0","description":"Send bill for approval"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/bills/{bill_id}/submit-for-approval":{"post":{"tags":["bills"],"summary":"Send bill for approval","description":"Submit a cleaned-up draft bill into the AP approval workflow. The bill moves to 'pending_approval' and is NOT posted to the general ledger until an approver signs off, at which point it posts to 'received'. Requires the business to have the approval workflow enabled.","operationId":"submit_bill_for_approval_api_v1_bills__bill_id__submit_for_approval_post","parameters":[{"name":"bill_id","in":"path","required":true,"schema":{"type":"string","title":"Bill 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"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BillReceivedRequest"}}}},"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"}}}},"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":{"BillReceivedRequest":{"properties":{"bill_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Bill Id","description":"UUID of the bill (set automatically from URL path)."},"amount":{"type":"integer","exclusiveMinimum":0.0,"title":"Amount","description":"Actual bill amount in cents. Must be greater than 0."},"ledger_id":{"type":"string","title":"Ledger Id","description":"UUID of the expense ledger account to categorize this bill. Required for creating the journal entry."},"s3_key":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"S3 Key","description":"S3 key of the bill document."},"journal_entry_date":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date"},{"type":"string"},{"type":"null"}],"title":"Journal Entry Date","description":"Date for the accounting journal entry (ISO 8601 or YYYY-MM-DD)."},"received_on":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date"},{"type":"string"},{"type":"null"}],"title":"Received On","description":"Date the bill/goods were received (ISO 8601 or YYYY-MM-DD)."},"due_on":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date"},{"type":"string"},{"type":"null"}],"title":"Due On","description":"Payment due date (ISO 8601 or YYYY-MM-DD)."}},"type":"object","required":["amount","ledger_id"],"title":"BillReceivedRequest","description":"Schema for marking a bill as received and creating journal entries.\n\nWhen a bill is marked as received, accounting journal entries are created\nto record the liability (Accounts Payable).","example":{"amount":250000,"due_on":"2024-01-31T00:00:00Z","journal_entry_date":"2024-01-15T00:00:00Z","ledger_id":"019ab37c-led1-7000-8000-000000000001","received_on":"2024-01-15T00:00:00Z"}},"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"},"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":[]}]}