Credith organises its data around a three-level hierarchy: a company (empresa) owns one or more stores (tiendas/sucursales), and each store has users (staff) and checkout machines (cajas de facturación) assigned to it. A user belongs to exactly one store and one checkout machine, while the company record holds the legal identity —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.
name and RTN (Registro Tributario Nacional) — that is stamped on every invoice at bill time. Getting this hierarchy right before processing sales is essential, as the bill controller validates each layer during invoice creation.
Setup Flow
Create a company
POST /api/companies creates the top-level legal entity. name and rtn are required; the RTN must be unique across the system.201 response returns the new company record including the generated companyId UUID. If the RTN already exists the server returns 400 Ya existe una empresa con ese RTN.The
companies endpoints require the OWNER role via roleMiddleware. Requests without a valid OWNER-role JWT cookie will be rejected.Create a store under the company
POST /api/stores creates a branch linked to the company. storeNumber must be a positive integer and companyId must reference an existing company.201 response returns the created store:The
address field on the cd.stores table is typed as INTEGER in the database schema — it represents a store number or location code rather than a free-text address string. Pass an integer value such as 101 or 2. Free-text branch addresses live on the cd.companies record.POST /api/stores is protected by authMiddleware + roleMiddleware(ROLE.ADMIN, ROLE.OWNER), so a valid auth cookie with at least an ADMIN role is required.Register users and assign them to a store
POST /api/users accepts a storeId field that links the new user to their branch. Every user must be assigned to a store at creation time — the storeId is validated server-side and the request is rejected if the store does not exist.Assign roles to users
Roles (This inserts a row into the
Employee, Admin, Owner) are seeded in cd.roles. You can associate a role to a user after creation via the dedicated endpoint:cd.users_roles junction table. A user can hold multiple roles; the login controller uses the first role returned (user.roles?.[0]?.name) to sign the JWT.Create a checkout machine and associate it to a cashier
Every user who will process sales needs a checkout machine. First create the machine:If the machine already exists but needs to be re-associated to a different cashier, use the associate endpoint:The
machineNumber is stamped on each generated invoice as part of the billNumberFinal string and also stored in checkoutMachineNumber on the cd.bills row.Activating and Deactivating Stores
Stores can be toggled active/inactive without deleting them. Deactivating a store prevents it from showing as a valid assignment target and excludes it from company-level revenue reports.| Status | Message |
|---|---|
400 | "La tienda ya esta desactivada" / "La tienda ya esta activa" |
404 | "Tienda no encontrada" |
Updating a Store
PUT /api/stores/:id allows any combination of storeNumber, address, and companyId to be updated. Only the fields you send are changed.
Updating a Company
PUT /api/companies/:id accepts name, rtn, email, and address. RTN changes are validated for uniqueness.