A CAI (Código de Autorización de Impresión) is a government-issued authorization code required for printing tax-compliant invoices in Honduras. In Credith, every store must have exactly one active CAI and one active CAI Range at any given time. When a new CAI is created, all previously active CAIs for that store are automatically deactivated. Each CAI owns one or more CAI Ranges, which define the numeric window (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.
minRange–maxRange) from which sequential bill numbers are drawn. The system tracks currentNumber within the active range so that every invoice receives a unique, SAR-compliant bill number.
CAI Endpoints
Base path:/api/cais
GET /api/cais
Returns a paginated list of CAIs. By default, only the most recent CAI per store is returned. Pass ?history=true to retrieve the full historical list across all stores.
Query parameters
Maximum number of records to return. Defaults to
10.Number of records to skip for pagination.
When
true, returns all historical CAIs. When false (default), returns only the latest CAI per store via a DISTINCT ON (store_id) query.POST /api/cais
Creates a new CAI together with its initial bill number range. Inside a single database transaction the server:
- Deactivates all currently active CAIs for the same store.
- Creates the new CAI record.
- Creates the initial
CaiRangechild record withcurrentNumber = 0.
The official CAI code issued by SAR, e.g.
"A1B2C3-D4E5F6-G7H8I9-J0K1L2-M3N4O5-06". Must be unique across all CAIs.UUID of the store this CAI belongs to. The store must exist.
ISO 8601 date string for when the CAI authorization expires, e.g.
"2027-06-30". Must be a future date.The initial bill number range to create alongside this CAI.
SAR document-type code. Defaults to
"01" (standard invoice). This value is embedded in the formatted bill number.When
true, skips the check that blocks creating a new CAI while one is already active. Use this when renewing an expiring CAI without an operational gap.| Status | Cause |
|---|---|
400 | Missing/invalid fields, negative ranges, minRange > maxRange, duplicate governmentId, or minRange does not exceed the store’s highest recorded maxRange |
404 | Store not found |
409 | Store already has an active CAI and isRenewal was not sent as true |
DELETE /api/cais/:id
Hard-deletes a CAI and all of its associated CAI Ranges inside a single transaction. The operation is blocked if any range belonging to this CAI has at least one invoice already issued against it.
Path parameter
UUID of the CAI to delete.
| Status | Cause |
|---|---|
400 | One or more ranges have associated bills |
404 | CAI not found |
CAI Range Endpoints
Base path:/api/cai-ranges and /api/cais/:caiId/ranges
A CAI Range defines a contiguous block of bill numbers (minRange to maxRange). The active range’s currentNumber counter is incremented atomically on every invoice creation. When a new range is added to an active CAI, all previous ranges for that CAI are deactivated.
GET /api/cai-ranges
Returns a paginated, time-descending list of all CAI Ranges. Each record includes the parent CAI object.
Query parameters
Maximum records to return.
Records to skip.
GET /api/cais/:caiId/ranges
Returns all CAI Ranges belonging to a specific CAI, paginated.
Path parameter
UUID of the parent CAI.
Maximum records to return.
Records to skip.
GET /api/cai-ranges/:id
Returns a single CAI Range by its UUID, including the parent CAI object.
Path parameter
UUID of the CAI Range.
POST /api/cai-ranges
Creates a new bill-number range under an active, non-expired CAI. On success:
- All currently active ranges for the parent CAI are deactivated.
- The new range is created with
currentNumber = 0andisActive = true.
UUID of the parent CAI. Must be active and not expired.
Starting bill number for this range. Must exceed the store’s global highest
maxRange.Ending bill number for this range. Must be ≥
minRange.| Status | Cause |
|---|---|
400 | Invalid/negative ranges, CAI is inactive or expired, or overlap with existing store ranges |
404 | CAI not found |
PUT /api/cai-ranges/:id
Extends the maxRange of an existing CAI Range. This is the only field that can be updated. The new value must be greater than the current maxRange. The operation is blocked if any bills have already been issued against this range.
Path parameter
UUID of the CAI Range to update.
The new upper bound. Must be greater than both the current
maxRange and the current currentNumber.| Status | Cause |
|---|---|
400 | New maxRange is not greater than the current value, is less than currentNumber, or bills already exist for this range |
404 | Range not found |
DELETE /api/cai-ranges/:id
Hard-deletes a single CAI Range. Blocked if any bill has been issued against this range.
Path parameter
UUID of the CAI Range to delete.
| Status | Cause |
|---|---|
400 | Range has associated bills |
404 | Range not found |
Data Models
CAI
Primary key, auto-generated UUIDv4.
The official CAI authorization code from SAR. Maximum 75 characters. Unique index enforced.
Date after which the CAI is no longer valid for new invoices.
SAR document type. Defaults to
"01" (standard invoice). Embedded in the formatted billNumberFinal.Whether this CAI is currently the active one for its store. Only one CAI per store can be active at a time.
Foreign key to the
stores table.Record creation timestamp.
Soft-delete timestamp. Non-null means the record is archived.
CaiRange
Primary key, auto-generated UUIDv4.
Foreign key linking this range to its parent CAI.
Lowest bill number in this authorized range.
Highest bill number in this authorized range.
Offset from
minRange representing how many bills have been issued. The next bill number is minRange + currentNumber. Starts at 0.Whether this is the currently active range for its parent CAI. Only one range per CAI can be active at a time.
Record creation timestamp.
Soft-delete timestamp.