openapi: 3.1.0 x-brrtrouter-stack-size: 128KiB info: title: Accounts Payable version: 1.0.0 description: 'Accounts payable management service handling vendor invoices, payments, approvals, and cash flow forecasting. Supports the full AP lifecycle: invoice receipt, approval workflow, payment scheduling, and vendor reconciliation. Integrates with the general ledger for account posting.' contact: name: RERP Accounting API Support email: accounting-api@rerp.ai servers: - url: http://localhost:8004/api/v1/accounting/accounts-payable description: Local development (direct to service, port from port-registry) - url: /api/v1/accounting/accounts-payable description: Accounts Payable API tags: - name: vendor-invoices description: Vendor invoices and approval workflow - name: payments description: Vendor payments and payment scheduling - name: approvals description: Invoice approval workflow and hierarchy - name: vendors description: Vendor payment terms and reconciliation - name: cash-flow description: AP cash flow forecasting and commitments paths: /vendor-invoices: get: operationId: list_vendor_invoices summary: List vendor invoices description: Paginated list of all vendor invoices with AP-specific fields including approval status and payment status. parameters: - name: page in: query schema: type: integer format: int32 minimum: 1 default: 1 - name: limit in: query schema: type: integer format: int32 minimum: 1 maximum: 100 default: 20 - name: search in: query schema: type: string description: Search by vendor name, invoice number, or status - name: status in: query schema: type: string enum: - DRAFT - PENDING_APPROVAL - APPROVED - REJECTED - POSTED - name: approval_status in: query schema: type: string enum: - PENDING - APPROVED - REJECTED - CANCELLED - name: payment_status in: query schema: type: string enum: - UNPAID - SCHEDULED - PARTIAL - PAID - DISPUTED - name: vendor_id in: query schema: type: string format: uuid - name: company_id in: query schema: type: string format: uuid - name: currency_code in: query schema: type: string minLength: 3 maxLength: 3 - name: date_from in: query schema: type: string format: date description: Invoice date from - name: date_to in: query schema: type: string format: date description: Invoice date to responses: '200': description: Paginated list of vendor invoices content: application/json: schema: $ref: '#/components/schemas/PaginatedVendorInvoices' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' '403': description: Forbidden content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' post: operationId: create_vendor_invoice summary: Create vendor invoice description: Create a new AP record for a vendor invoice. Links the invoice to the vendor and initializes the approval workflow. x-brrtrouter-impl: true requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/CreateVendorInvoiceRequest' example: invoice_id: 1000.0 vendor_id: 550e8400-e29b-41d4-a716-446655440000 invoice_number: INV-2026-0001 invoice_date: 1000.0 amount: '10000.00' currency_code: USD tax_amount: '1000.00' due_date: '2026-01-15' terms: sample value description: Primary operating company company_id: 550e8400-e29b-41d4-a716-446655440000 line_items: [] auto_approve: true responses: '201': description: VendorInvoice created content: application/json: schema: $ref: '#/components/schemas/VendorInvoice' '400': description: Validation error content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' '401': description: Unauthorized — invalid or expired token content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' '403': description: Forbidden — insufficient permissions content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' '409': description: Conflict — resource already exists or violates business rules content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' /vendor-invoices/{id}: get: operationId: get_vendor_invoice summary: Get vendor invoice by id description: Retrieve a single vendor invoice with its full AP details including approval history and payment status. x-brrtrouter-impl: true parameters: - name: id in: path required: true schema: type: string format: uuid responses: '200': description: VendorInvoice details with AP context content: application/json: schema: $ref: '#/components/schemas/VendorInvoiceWithDetails' '404': description: Not found content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' /payments: get: operationId: list_vendor_payments summary: List payments description: Paginated list of all vendor payments with filtering by status, date range, and vendor. parameters: - name: page in: query schema: type: integer format: int32 minimum: 1 default: 1 - name: limit in: query schema: type: integer format: int32 minimum: 1 maximum: 100 default: 20 - name: search in: query schema: type: string description: Search by reference number or vendor - name: status in: query schema: type: string enum: - SCHEDULED - PENDING - SENT - COMPLETED - FAILED - CANCELLED - name: payment_method in: query schema: type: string enum: - WIRE - CHECK - ACH - BANK_TRANSFER - PAYMENT_GATEWAY - COUNTER_SERVICE - name: vendor_id in: query schema: type: string format: uuid - name: company_id in: query schema: type: string format: uuid - name: date_from in: query schema: type: string format: date description: Payment date from - name: date_to in: query schema: type: string format: date description: Payment date to responses: '200': description: Paginated list of payments content: application/json: schema: $ref: '#/components/schemas/PaginatedVendorPayments' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' '403': description: Forbidden content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' post: operationId: create_vendor_payment summary: Create payment description: Schedule a new vendor payment. Optionally auto-disburse if auto_disburse is true. x-brrtrouter-impl: true requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/CreateVendorPaymentRequest' example: reference_number: REF-2026-0001 amount: '10000.00' currency_code: USD payment_method: 1000.0 payment_date: 1000.0 vendor_id: 550e8400-e29b-41d4-a716-446655440000 company_id: 550e8400-e29b-41d4-a716-446655440000 notes: Approved by CFO on 2026-01-15 auto_disburse: true responses: '201': description: Payment created content: application/json: schema: $ref: '#/components/schemas/VendorPayment' '400': description: Validation error content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' '401': description: Unauthorized — invalid or expired token content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' '403': description: Forbidden — insufficient permissions content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' '409': description: Conflict — resource already exists or violates business rules content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' /payments/{id}: get: operationId: get_vendor_payment summary: Get payment by id description: Retrieve payment details. x-brrtrouter-impl: true parameters: - name: id in: path required: true schema: type: string format: uuid responses: '200': description: Payment details content: application/json: schema: $ref: '#/components/schemas/VendorPayment' '404': description: Not found content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' /vendor-invoices/{id}/register-payment: post: operationId: register_vendor_invoice_payment summary: Register vendor invoice payment x-brrtrouter-impl: true parameters: - name: id in: path required: true schema: type: string format: uuid requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/RegisterVendorInvoicePaymentRequest' example: amount: '10000.00' currency_code: USD payment_method: 1000.0 payment_date: 1000.0 reference_number: REF-2026-0001 responses: '201': description: Vendor payment registered content: application/json: schema: $ref: '#/components/schemas/VendorPayment' '400': description: Validation error content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' '401': description: Unauthorized — invalid or expired token content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' '403': description: Forbidden — insufficient permissions content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' '409': description: Conflict — resource already exists or violates business rules content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' components: parameters: Id: name: id in: path required: true schema: type: string format: uuid description: Resource UUID Page: name: page in: query required: false schema: type: integer format: int32 minimum: 1 default: 1 description: Page number (1-indexed) Limit: name: limit in: query required: false schema: type: integer format: int32 minimum: 1 maximum: 100 default: 20 description: Page size (1-100) Search: name: search in: query required: false schema: type: string description: Full-text search across name and description fields CompanyId: name: company_id in: query required: false schema: type: string format: uuid description: Filter by company UUID securitySchemes: bearerAuth: type: http scheme: bearer bearerFormat: JWT description: JWT bearer token for authentication. Include in Authorization header as 'Bearer '. schemas: VendorInvoice: type: object required: - amount - approval_status - approved_at - approved_by - company_id - created_at - currency_code - description - due_date - id - invoice_date - invoice_id - invoice_number - net_amount - payment_status - status - tax_amount - terms - vendor_id properties: id: type: string format: uuid description: Unique identifier for this AP record example: 550e8400-e29b-41d4-a716-446655440000 invoice_id: type: string format: uuid description: Reference to the base Invoice entity in the Invoice service example: 1000.0 vendor_id: type: string format: uuid description: Vendor this invoice is for example: 550e8400-e29b-41d4-a716-446655440000 invoice_number: type: string maxLength: 100 description: Vendor's invoice number for reference example: INV-2026-0001 invoice_date: type: string format: date description: Date on the vendor invoice example: 1000.0 amount: type: string pattern: ^-?[0-9]+(?:\.[0-9]{1,6})?$ currency_code: type: string minLength: 3 maxLength: 3 pattern: ^[A-Z]{3}$ example: USD tax_amount: type: string pattern: ^-?[0-9]+(?:\.[0-9]{1,6})?$ net_amount: type: string pattern: ^-?[0-9]+(?:\.[0-9]{1,6})?$ status: type: string enum: - DRAFT - PENDING_APPROVAL - APPROVED - REJECTED - POSTED description: AP status of this invoice example: active approval_status: type: string enum: - PENDING - APPROVED - REJECTED - CANCELLED description: Approval workflow status example: pending payment_status: type: string enum: - UNPAID - SCHEDULED - PARTIAL - PAID - DISPUTED description: Payment lifecycle state example: pending due_date: type: string format: date description: Payment due date example: '2026-01-15' terms: type: string enum: - DUE_ON_RECEIPT - NET_15 - NET_30 - NET_45 - NET_60 - CUSTOM description: Payment terms with this vendor example: sample value company_id: type: string format: uuid description: Company this invoice belongs to example: 550e8400-e29b-41d4-a716-446655440000 approved_by: type: - string - 'null' format: uuid description: User who approved this invoice example: 950e8400-e29b-41d4-a716-446655440004 approved_at: type: - string - 'null' format: date-time description: When the invoice was approved example: '2026-01-15T10:30:00Z' description: type: - string - 'null' maxLength: 2000 description: Invoice description/memo example: Primary operating company created_at: type: string format: date-time example: '2026-01-15T10:30:00Z' updated_at: type: string format: date-time example: '2026-01-15T10:30:00Z' VendorInvoiceWithDetails: allOf: - $ref: '#/components/schemas/VendorInvoice' - type: object properties: approval_history: type: array items: $ref: '#/components/schemas/ApprovalRecord' description: Approval workflow history payment_history: type: array items: $ref: '#/components/schemas/VendorPayment' description: Payment history for this invoice line_items: type: array items: $ref: '#/components/schemas/VendorInvoiceLineItem' description: Invoice line items CreateVendorInvoiceRequest: type: object required: - invoice_id - vendor_id - currency_code - amount properties: invoice_id: type: string format: uuid description: Base Invoice entity reference example: 1000.0 vendor_id: type: string format: uuid description: Vendor example: 550e8400-e29b-41d4-a716-446655440000 invoice_number: type: string maxLength: 100 description: Vendor's invoice number example: INV-2026-0001 invoice_date: type: string format: date description: Date on the vendor invoice example: 1000.0 amount: type: string pattern: ^-?[0-9]+(?:\.[0-9]{1,6})?$ currency_code: type: string minLength: 3 maxLength: 3 example: USD tax_amount: type: string pattern: ^-?[0-9]+(?:\.[0-9]{1,6})?$ due_date: type: - string - 'null' format: date description: Payment due date. Defaults to invoice_date + terms. example: '2026-01-15' terms: type: string enum: - DUE_ON_RECEIPT - NET_15 - NET_30 - NET_45 - NET_60 - CUSTOM example: sample value description: type: - string - 'null' maxLength: 2000 example: Primary operating company company_id: type: string format: uuid example: 550e8400-e29b-41d4-a716-446655440000 line_items: type: array items: $ref: '#/components/schemas/CreateInvoiceLineItemRequest' description: Invoice line items for GL posting example: [] auto_approve: type: boolean default: false description: Bypass approval workflow for invoices below threshold example: true VendorPayment: type: object required: - actual_payment_date - amount - company_id - currency_code - gl_entry_id - id - notes - payment_date - payment_method - posted_to_gl - reference_number - status - vendor_id properties: id: type: string format: uuid description: Unique identifier for the payment example: 550e8400-e29b-41d4-a716-446655440000 reference_number: type: - string - 'null' maxLength: 100 description: Payment reference (check number, wire reference) example: REF-2026-0001 amount: type: string pattern: ^-?[0-9]+(?:\.[0-9]{1,6})?$ currency_code: type: string minLength: 3 maxLength: 3 example: USD payment_method: type: string enum: - WIRE - CHECK - ACH - BANK_TRANSFER - PAYMENT_GATEWAY - COUNTER_SERVICE example: 1000.0 payment_date: type: string format: date description: Scheduled or actual payment date example: 1000.0 actual_payment_date: type: - string - 'null' format: date description: When payment was actually sent example: 1000.0 status: type: string enum: - SCHEDULED - PENDING - SENT - COMPLETED - FAILED - CANCELLED example: active vendor_id: type: string format: uuid description: Vendor this payment is for example: 550e8400-e29b-41d4-a716-446655440000 company_id: type: string format: uuid description: Company this payment belongs to example: 550e8400-e29b-41d4-a716-446655440000 posted_to_gl: type: boolean default: false description: Whether payment has been posted to general ledger example: true gl_entry_id: type: - string - 'null' format: uuid description: GL journal entry created for this payment example: 650e8400-e29b-41d4-a716-446655440001 notes: type: - string - 'null' maxLength: 1000 description: Payment notes example: Approved by CFO on 2026-01-15 created_at: type: string format: date-time example: '2026-01-15T10:30:00Z' updated_at: type: string format: date-time example: '2026-01-15T10:30:00Z' CreateVendorPaymentRequest: type: object required: - vendor_id - amount - currency_code - payment_method - payment_date properties: reference_number: type: - string - 'null' maxLength: 100 example: REF-2026-0001 amount: type: string pattern: ^-?[0-9]+(?:\.[0-9]{1,6})?$ currency_code: type: string minLength: 3 maxLength: 3 example: USD payment_method: type: string enum: - WIRE - CHECK - ACH - BANK_TRANSFER - PAYMENT_GATEWAY - COUNTER_SERVICE example: 1000.0 payment_date: type: string format: date description: Scheduled payment date example: 1000.0 vendor_id: type: string format: uuid example: 550e8400-e29b-41d4-a716-446655440000 company_id: type: string format: uuid example: 550e8400-e29b-41d4-a716-446655440000 notes: type: - string - 'null' maxLength: 1000 example: Approved by CFO on 2026-01-15 auto_disburse: type: boolean default: false description: Immediately disburse the payment example: true VendorInvoiceLineItem: type: object required: - amount - description - gl_account - id - invoice_id - product_id - quantity - tax_code - unit_price properties: id: type: string format: uuid description: Unique identifier for this line item example: 550e8400-e29b-41d4-a716-446655440000 invoice_id: type: string format: uuid description: Parent vendor invoice example: 1000.0 product_id: type: - string - 'null' format: uuid description: Product this line item relates to example: 850e8400-e29b-41d4-a716-446655440028 quantity: type: string pattern: ^-?[0-9]+(?:\.[0-9]{1,6})?$ unit_price: type: string pattern: ^-?[0-9]+(?:\.[0-9]{1,6})?$ amount: type: string pattern: ^-?[0-9]+(?:\.[0-9]{1,6})?$ tax_code: type: - string - 'null' maxLength: 50 description: Tax code for this line example: VAT-2026 description: type: string maxLength: 1000 description: Line item description example: Primary operating company gl_account: type: - string - 'null' format: uuid description: GL account for posting example: GL-2026-001 CreateInvoiceLineItemRequest: type: object required: - description - amount properties: product_id: type: - string - 'null' format: uuid example: 850e8400-e29b-41d4-a716-446655440028 quantity: type: string pattern: ^-?[0-9]+(?:\.[0-9]{1,6})?$ unit_price: type: string pattern: ^-?[0-9]+(?:\.[0-9]{1,6})?$ amount: type: string pattern: ^-?[0-9]+(?:\.[0-9]{1,6})?$ tax_code: type: - string - 'null' maxLength: 50 example: VAT-2026 description: type: string maxLength: 1000 example: Primary operating company gl_account: type: - string - 'null' format: uuid example: GL-2026-001 ApprovalRecord: type: object required: - action - approver_id - date - id - invoice_id properties: id: type: string format: uuid example: 550e8400-e29b-41d4-a716-446655440000 invoice_id: type: string format: uuid description: Invoice being approved example: 1000.0 approver_id: type: string format: uuid description: User who approved/rejected example: 550e8400-e29b-41d4-a716-446655440000 action: type: string enum: - APPROVE - REJECT - REQUEST_INFO - DELEGATE example: sample value date: type: string format: date-time description: When the action was taken example: '2026-01-15' notes: type: - string - 'null' maxLength: 2000 description: Approval/rejection notes example: Approved by CFO on 2026-01-15 threshold_met: type: boolean RegisterVendorInvoicePaymentRequest: type: object required: - amount - currency_code - payment_method - payment_date properties: amount: type: string pattern: ^-?[0-9]+(?:\.[0-9]{1,6})?$ currency_code: type: string minLength: 3 maxLength: 3 example: USD payment_method: type: string enum: - WIRE - CHECK - ACH - BANK_TRANSFER - PAYMENT_GATEWAY - COUNTER_SERVICE example: 1000.0 payment_date: type: string format: date example: 1000.0 reference_number: type: - string - 'null' example: REF-2026-0001 PaginatedVendorInvoices: type: object required: - items - total - page - limit properties: items: type: array items: $ref: '#/components/schemas/VendorInvoice' example: [] total: type: integer format: int64 example: 1 page: type: integer format: int32 example: 1 limit: type: integer format: int32 example: 1 has_more: type: boolean example: true PaginatedVendorPayments: type: object required: - items - total - page - limit properties: items: type: array items: $ref: '#/components/schemas/VendorPayment' example: [] total: type: integer format: int64 example: 1 page: type: integer format: int32 example: 1 limit: type: integer format: int32 example: 1 has_more: type: boolean example: true ErrorResponse: type: object required: - code - message properties: code: type: string enum: - NOT_FOUND - UNAUTHORIZED - FORBIDDEN - CONFLICT - SERVER_ERROR - UNKNOWN example: NOT_FOUND message: type: string example: Vendor invoice not found details: type: - object - 'null' example: sample value security: - bearerAuth: []