Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/RoyGeova07/Credith/llms.txt

Use this file to discover all available pages before exploring further.

Credith exposes four analytical report endpoints that cover different scopes of the business: product-level performance across a company, a day-by-day store gain series over a custom date range, a monthly revenue and staffing summary for a single store, and aggregated financials rolled up to the company level. All four operate against the cd schema using raw PostgreSQL queries with CTEs, and all return pre-computed grossGain and netGain figures calculated from sell_price - buy_price margins.
All four report endpoints are restricted by role. GET /api/reports/products and GET /api/reports/companies require the OWNER role. GET /api/reports/stores and GET /api/reports/stores/range accept either OWNER or ADMIN. The API-level roleMiddleware enforces this — requests from EMPLOYEE-role users are rejected with 403. Ensure the JWT in the Authorization header belongs to a user with the appropriate role.

GET /api/reports/products

Returns product performance data for a company, broken down by product and store. For each product the response includes total quantity sold, current in-stock units, gross gain (sell price margin × qty), and net gain (line total margin × qty) — both for the company as a whole and per individual store. When no month/year is provided the report covers all historical sales. When a period is specified, only bills created within that calendar month are included. Query parameters
companyId
string (UUID)
required
Limits the report to products sold by or stocked in stores belonging to this company.
storeId
string (UUID)
Optional. Narrows both the sales and inventory queries to a single store within the company.
month
string | integer
Optional. Accepts either a numeric month (112) alongside year, or a combined YYYY-MM string (e.g. "2026-05"). When omitted together with year, the report covers all historical data.
year
integer
The four-digit calendar year. Required when month is sent as a plain integer.
limit
integer
default:"10"
Maximum number of products to return per page. Capped at 100.
offset
integer
default:"0"
Number of products to skip (for pagination).
Example
curl -X GET "https://your-domain.com/api/reports/products?companyId=cc001122-9ae8-4597-b95e-9889028f0001&month=2026-05&limit=10&offset=0" \
  -H "Authorization: Bearer <token>"
Response fields
period
object
Describes the date range applied to the query.
products
array
Paginated list of product performance objects.
Error responses
StatusCause
400companyId missing, invalid month/year combination

GET /api/reports/stores

Returns the monthly revenue summary and employee roster for a single store. If no month/year is specified, the current calendar month is used by default. Requires ADMIN or OWNER role. Query parameters
storeId
string (UUID)
required
UUID of the store to report on.
month
string | integer
Optional. Numeric month (112) with year, or YYYY-MM string. Defaults to the current month.
year
integer
Required when month is a plain integer.
Example
curl -X GET "https://your-domain.com/api/reports/stores?storeId=d55555e5-9ae8-4597-b95e-9889028f3333" \
  -H "Authorization: Bearer <token>"
Response fields
store
object
Monthly performance snapshot for the requested store.
Error responses
StatusCause
400storeId missing or invalid date parameters
404No store found for the given storeId

GET /api/reports/stores/range

Returns a day-by-day series of gross and net gain for a store between two calendar dates. Each entry in data corresponds to a single calendar day; days with no sales return grossGain: 0, netGain: 0. Requires ADMIN or OWNER role. Query parameters
storeId
string (UUID)
required
UUID of the store.
startDate
string (date)
required
Inclusive start date in YYYY-MM-DD format.
endDate
string (date)
required
Inclusive end date in YYYY-MM-DD format.
Response
{
  "data": [
    { "date": "2026-05-01", "grossGain": 1200.00, "netGain": 1140.00 },
    { "date": "2026-05-02", "grossGain": 0, "netGain": 0 },
    { "date": "2026-05-03", "grossGain": 3450.00, "netGain": 3277.50 }
  ]
}
Error responses
StatusCause
400storeId, startDate, or endDate missing; dates not in YYYY-MM-DD format

GET /api/reports/companies

Returns aggregated monthly revenue for every active store within a company. Defaults to the current calendar month if no period is specified. Requires OWNER role. Query parameters
companyId
string (UUID)
required
UUID of the company to report on.
month
string | integer
Optional. Numeric month (112) with year, or YYYY-MM string. Defaults to the current month.
year
integer
Required when month is a plain integer.
Example
curl -X GET "https://your-domain.com/api/reports/companies?companyId=cc001122-9ae8-4597-b95e-9889028f0001" \
  -H "Authorization: Bearer <token>"
Response fields
company
object
Aggregated company report.
Error responses
StatusCause
400companyId missing or invalid date parameters
404No company found for the given companyId

Build docs developers (and LLMs) love