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.

The Companies API is the top level of Credith’s organizational hierarchy. Every store location, staff member, and point-of-sale terminal is ultimately rooted in a company record. A company holds the legal identity of a business — its name, tax registration number (RTN), contact email, and physical address — and acts as the parent container for all stores created beneath it. All endpoints are protected: only users with the Owner role may read or modify company data.

Endpoints overview

All company endpoints require a valid token cookie and the Owner role.
MethodPathDescription
GET/api/companiesList companies (paginated, filterable)
GET/api/companies/:idGet a single company by UUID
POST/api/companiesCreate a new company
PUT/api/companies/:idUpdate company fields
DELETE/api/companies/:idPermanently delete a company

List companies

GET /api/companies
Authentication: ✅ Required — Owner role
limit
integer
default:"10"
Maximum number of records to return per page.
offset
integer
default:"0"
Number of records to skip before starting the page — use together with limit for pagination.
filter
string
Case-insensitive partial match on the company name field (ILIKE %filter%). Omit to return all companies.
GET /api/companies?limit=10&offset=0&filter=servi

Response 200

{
  "total": 1,
  "data": [
    {
      "companyId": "3f2e1a00-bc45-4d78-a9f2-000000000001",
      "name": "ServiCredit",
      "rtn": "08011999123456",
      "email": "contacto@servicredit.com",
      "address": "San Pedro Sula, Cortés",
      "createdAt": "2024-01-15T10:00:00.000Z",
      "updatedAt": "2024-01-15T10:00:00.000Z"
    }
  ]
}

Get company by ID

GET /api/companies/:id
Authentication: ✅ Required — Owner role
id
string
required
UUID of the company to retrieve.

Responses

StatusDescription
200Company object returned.
404No company found with the given ID.
{
  "companyId": "3f2e1a00-bc45-4d78-a9f2-000000000001",
  "name": "ServiCredit",
  "rtn": "08011999123456",
  "email": "contacto@servicredit.com",
  "address": "San Pedro Sula, Cortés",
  "createdAt": "2024-01-15T10:00:00.000Z",
  "updatedAt": "2024-01-15T10:00:00.000Z"
}

Create a company

POST /api/companies
Authentication: ✅ Required — Owner role
The rtn (Registro Tributario Nacional) must be unique across all companies. Submitting a duplicate RTN returns 400 Bad Request. The RTN is also validated to be non-empty before any database lookup is performed.

Request body

name
string
required
Legal trading name of the company. Cannot be blank or whitespace-only.
rtn
string
required
Tax registration number (Registro Tributario Nacional). Maximum 25 characters. Must be unique across all companies.
email
string
Contact email address for the company. Maximum 100 characters.
address
string
Physical address or location description for the company’s headquarters.

Example request

curl -X POST https://your-domain.com/api/companies \
  -H "Content-Type: application/json" \
  -b cookies.txt \
  -d '{
    "name": "ServiCredit",
    "rtn": "08011999123456",
    "email": "contacto@servicredit.com",
    "address": "San Pedro Sula, Cortés, Honduras"
  }'

Responses

StatusDescription
201Company created successfully. Returns the new company object.
400Validation failed — name or rtn missing/blank, or RTN already exists.
500Unexpected server error.
{
  "message": "Empresa creada correctamente",
  "company": {
    "companyId": "3f2e1a00-bc45-4d78-a9f2-000000000001",
    "name": "ServiCredit",
    "rtn": "08011999123456",
    "email": "contacto@servicredit.com",
    "address": "San Pedro Sula, Cortés, Honduras",
    "createdAt": "2024-06-01T14:22:00.000Z",
    "updatedAt": "2024-06-01T14:22:00.000Z"
  }
}

Update a company

PUT /api/companies/:id
Authentication: ✅ Required — Owner role
id
string
required
UUID of the company to update.
All body fields are optional — only the fields you include will be changed.
name
string
New company name. Cannot be set to an empty or whitespace-only string.
rtn
string
New RTN value. Must be unique if it differs from the company’s current RTN.
email
string
New contact email address.
address
string
New headquarters address.

Responses

StatusDescription
200Company updated successfully. Returns the updated company object.
400Validation failed — blank name/RTN supplied, or new RTN already belongs to another company.
404No company found with the given ID.
500Unexpected server error.
{
  "message": "Empresa actualizada correctamente",
  "company": {
    "companyId": "3f2e1a00-bc45-4d78-a9f2-000000000001",
    "name": "ServiCredit S.A.",
    "rtn": "08011999123456",
    "email": "nuevo@servicredit.com",
    "address": "Tegucigalpa, Honduras",
    "updatedAt": "2024-07-10T09:15:00.000Z"
  }
}

Delete a company

DELETE /api/companies/:id
Authentication: ✅ Required — Owner role
id
string
required
UUID of the company to delete.
This is a hard delete — the company record is permanently removed from the database. All associated stores and dependent records may be affected. Ensure there are no active stores under this company before deleting it.

Responses

StatusDescription
200Company deleted successfully.
404No company found with the given ID.
500Unexpected server error.
{
  "message": "Empresa eliminada correctamente"
}

Company object reference

companyId
string
UUID v4 primary key, auto-generated on creation.
name
string
Legal trading name of the company. Maximum 100 characters.
rtn
string
Registro Tributario Nacional — the company’s government-issued tax ID. Maximum 25 characters. Unique across all records.
email
string | null
Optional contact email address. Maximum 100 characters.
address
string | null
Optional free-text headquarters address.
createdAt
string
ISO 8601 timestamp of when the record was created.
updatedAt
string
ISO 8601 timestamp of the most recent update.
Company records use soft-delete internally via a deletedAt column. While the DELETE endpoint hard-destroys the row with Sequelize’s destroy(), the paranoid model means any record with a deletedAt timestamp is automatically excluded from all queries.

Build docs developers (and LLMs) love