03‐ Backend API Routes - mina-y-khalil/redeembooks-accounting-app GitHub Wiki

🛠️ Backend API Routes

This document describes all the Flask API routes used in the RedeemBooks Accounting App.
These routes support full CRUD operations and power the React + Redux frontend to create a seamless single-page app experience.


🔗 Postman Collection

Click the Postman logo above or RedeemBooks API Collection to open the live collection.
Any updates in Postman will automatically sync to this link.


👤 Authentication & Users

Signup
POST: /api/users/
Creates a new user account and logs them in.

Login
POST: /api/session/
Authenticates a user and starts a session.

Logout
DELETE: /api/session/
Logs out the currently authenticated user.

Get Current User
GET: /api/session/
Retrieves the details of the logged-in user.


🏢 Companies & User Management

Get All Companies (for current user)
GET: /api/companies/
Fetches all companies associated with the logged-in user.

Get Company by ID
GET: /api/companies/:companyId
Retrieves details of a specific company.

Create Company
POST: /api/companies/
Creates a new company.

Update Company
PUT: /api/companies/:companyId
Edits company information.

Delete Company
DELETE: /api/companies/:companyId
Removes a company (and cascades related data).


👥 Approver Management

Get Approvers for Company
GET: /api/companies/:companyId/approvers/
Lists all approvers for a company.

Add Approver
POST: /api/companies/:companyId/approvers/
Assigns a new approver to a company.

Update Approver Role
PUT: /api/approvers/:approverId
Updates the permissions or role of an approver.

Remove Approver
DELETE: /api/approvers/:approverId
Removes an approver from the company.


🏬 Vendors

Get All Vendors
GET: /api/companies/:companyId/vendors/
Retrieves all vendors for a company.

Get Vendor by ID
GET: /api/vendors/:vendorId
Fetches details of a specific vendor.

Create Vendor
POST: /api/companies/:companyId/vendors/
Adds a new vendor for a company.

Update Vendor
PUT: /api/vendors/:vendorId
Edits vendor details.

Delete Vendor
DELETE: /api/vendors/:vendorId
Removes a vendor.


🗂️ Categories

Get All Categories
GET: /api/companies/:companyId/categories/
Retrieves all expense categories for a company.

Create Category
POST: /api/companies/:companyId/categories/
Adds a new expense category.

Update Category
PUT: /api/categories/:categoryId
Edits an existing category.

Delete Category
DELETE: /api/categories/:categoryId
Removes a category.


🧾 Invoices

Get All Invoices
GET: /api/companies/:companyId/invoices/
Fetches all invoices for a company with filters for status and due dates.

Get Invoice by ID
GET: /api/invoices/:invoiceId
Retrieves a specific invoice.

Create Invoice
POST: /api/companies/:companyId/invoices/
Creates a new invoice with optional file attachment.

Update Invoice
PUT: /api/invoices/:invoiceId
Updates invoice details or approval status.

Delete Invoice
DELETE: /api/invoices/:invoiceId
Deletes an invoice and related payments.


💵 Payments (Partial Payments)

Get Payments for an Invoice
GET: /api/invoices/:invoiceId/payments/
Lists all payments made toward a specific invoice.

Create Payment
POST: /api/invoices/:invoiceId/payments/
Records a new payment or partial payment.

Update Payment
PUT: /api/payments/:paymentId
Edits an existing payment (e.g., amount or method).

Delete Payment
DELETE: /api/payments/:paymentId
Removes a payment record.


📦 AP Run / Payment Batches

Get All Payment Batches
GET: /api/companies/:companyId/batches/
Lists all scheduled AP runs for a company.

Get Batch by ID
GET: /api/batches/:batchId
Retrieves details of a specific payment batch.

Create Batch
POST: /api/companies/:companyId/batches/
Creates a new AP run with selected invoices.

Update Batch
PUT: /api/batches/:batchId
Updates batch details (e.g., scheduled date, status).

Delete Batch
DELETE: /api/batches/:batchId
Cancels or deletes a batch.


💳 Bank Balances

Get All Balances
GET: /api/companies/:companyId/balances/
Retrieves all bank balance records for a company.

Create Balance Record
POST: /api/companies/:companyId/balances/
Adds a new balance entry.

Update Balance
PUT: /api/balances/:balanceId
Edits balance details.

Delete Balance
DELETE: /api/balances/:balanceId
Removes a bank balance entry.


🕵️ Audit Logs

Get Audit Logs
GET: /api/companies/:companyId/audit-logs/
Fetches historical logs of all actions within a company.


This API structure ensures RESTful conventions, full CRUD coverage.