Overview
The Clients API manages customer information for sales operations. Clients are identified by their document number (primary key) and can be natural persons or legal entities.Model Structure
Cliente Model
Table:clientesPrimary Key:
documento (string, non-incrementing)
Attributes
Unique document identifier (CC, NIT, CE, etc.). Max 40 characters.
Full name or company name. Max 150 characters.
Foreign key to
tipos_cliente. Indicates if client is natural person or company.Foreign key to
tipos_documento. Document type (CC, NIT, CE, Passport, etc.).Physical address. Max 200 characters.
Contact phone number. Max 30 characters.
Email address. Max 150 characters. Must be valid email format.
Record creation timestamp.
Last update timestamp.
Relationships
Related
TipoCliente model. Contains client type classification.Related
TipoDocumento model. Contains document type information.Collection of
Venta records. All sales/separations for this client.Collection of
Apartamento records owned by this client.List All Clients
Response
Get Client by Document
Path Parameters
Client document identifier (e.g., “1234567890”)
Response
Error Responses
Client not found with provided document.
Create Client
Request Body
Client full name or company name. Max 150 characters.
Client type ID. Must exist in
tipos_cliente table.Document type ID. Must exist in
tipos_documento table.Unique document number. Max 40 characters. Must be unique.
Physical address. Max 200 characters.
Contact phone. Max 30 characters.
Email address. Max 150 characters. Must be valid email format.
Optional redirect URL after creation (used in web interface).
Validation Rules
- nombre: Required, string, max 150 characters
- id_tipo_cliente: Required, must exist in tipos_cliente table
- id_tipo_documento: Required, must exist in tipos_documento table
- documento: Required, string, max 40 chars, must be unique
- direccion: Optional, string, max 200 characters
- telefono: Optional, string, max 30 characters
- correo: Optional, valid email format, max 150 characters
Response
Error Responses
Validation failed. Common errors:
- Document already exists
- Invalid email format
- Missing required fields
- Invalid tipo_cliente or tipo_documento ID
Update Client
Path Parameters
Client document identifier
Request Body
Updated client name
Updated client type ID
Updated document type ID
Updated address
Updated phone
Updated email
The
documento field cannot be updated as it’s the primary key.Response
Delete Client
Path Parameters
Client document identifier to delete
Response
Error Responses
Client not found
Cannot delete client with existing sales records
Business Logic
Client Types
Clients are classified by type (id_tipo_cliente):
- Persona Natural: Individual buyers
- Persona Jurídica: Companies or legal entities
Document Types
Supported document types (id_tipo_documento):
- CC: Cédula de Ciudadanía (National ID)
- NIT: Número de Identificación Tributaria (Tax ID)
- CE: Cédula de Extranjería (Foreign ID)
- Pasaporte: Passport
- Otro: Other
Usage in Sales
- Each
Venta(sale) orSeparacion(separation) must reference a valid client - Client document serves as the foreign key in sales records
- Eager load client data when querying sales for performance
Data Integrity
- Document numbers must be unique across all clients
- Email validation ensures proper format
- Phone and address fields are optional but recommended
- Client type and document type are required for legal compliance
Related Endpoints
- Sales API - Create sales for clients
- Payments API - Track client payments
- Amortization API - Payment schedules for client purchases