Skip to main content

Overview

The Clients (Clientes) API allows you to manage client information for the advertising platform. Clients can be associated with companies and campaigns, and may own vehicles that participate in advertising activities.

Base Endpoint

/Database/clientes/

Model Structure

Cliente Model

The Cliente model represents a client in the system with the following fields:
id_cliente
integer
required
Unique identifier for the client (auto-generated primary key)
id_usuario
integer
required
Foreign key reference to the Usuario (User) model. Links the client to their user account
cedula_cliente
string
required
Client’s identification number (cedula). Maximum 10 characters
nombre
string
required
Client’s first name. Maximum 20 characters
apellido
string
required
Client’s last name. Maximum 20 characters
fecha_nacimiento
date
required
Client’s date of birth in ISO 8601 format (YYYY-MM-DD)
email
string
required
Client’s email address. Maximum 40 characters
sexo
integer
required
Client’s gender represented as an integer:
  • 0: Female
  • 1: Male
telefono
string
required
Client’s phone number. Maximum 10 characters
id_ciudad
integer
required
Foreign key reference to the Ciudad (City) model. Defaults to 1
id_pais
integer
required
Foreign key reference to the Pais (Country) model. Defaults to 1
id_empresa
integer
Foreign key reference to the Empresa (Company) model. Can be null or blank if the client is not associated with a company
id_campana
integer
Foreign key reference to the CampanaPublicitaria (Advertising Campaign) model. Can be null or blank if not currently enrolled in a campaign
estado
integer
required
Current status of the client:
  • 0: Inactive
  • 1: Active
  • 3: Disabled

Endpoints

List All Clients

GET /Database/Database/clientes/

Retrieve a list of all clients in the system

Response

id_cliente
integer
Client’s unique identifier
id_usuario
integer
Associated user account ID
cedula_cliente
string
Client’s identification number
nombre
string
Client’s first name
apellido
string
Client’s last name
fecha_nacimiento
date
Client’s date of birth
email
string
Client’s email address
sexo
integer
Client’s gender (0: Female, 1: Male)
telefono
string
Client’s phone number
id_ciudad
integer
City ID where the client is located
id_pais
integer
Country ID where the client is located
id_empresa
integer
Associated company ID (nullable)
id_campana
integer
Associated campaign ID (nullable)
estado
integer
Client’s status (0: Inactive, 1: Active, 3: Disabled)

Example Response

[
  {
    "id_cliente": 1,
    "id_usuario": 45,
    "cedula_cliente": "1234567890",
    "nombre": "Ana",
    "apellido": "García",
    "fecha_nacimiento": "1995-08-20",
    "email": "[email protected]",
    "sexo": 0,
    "telefono": "0987654321",
    "id_ciudad": 1,
    "id_pais": 1,
    "id_empresa": 5,
    "id_campana": 12,
    "estado": 1
  },
  {
    "id_cliente": 2,
    "id_usuario": 52,
    "cedula_cliente": "0987654321",
    "nombre": "Pedro",
    "apellido": "Sánchez",
    "fecha_nacimiento": "1987-12-05",
    "email": "[email protected]",
    "sexo": 1,
    "telefono": "0912345678",
    "id_ciudad": 2,
    "id_pais": 1,
    "id_empresa": null,
    "id_campana": null,
    "estado": 1
  }
]

Get Single Client

GET /Database/Database/clientes/{id}/

Retrieve details of a specific client by ID

Path Parameters

id
integer
required
The unique identifier of the client

Example Response

{
  "id_cliente": 1,
  "id_usuario": 45,
  "cedula_cliente": "1234567890",
  "nombre": "Ana",
  "apellido": "García",
  "fecha_nacimiento": "1995-08-20",
  "email": "[email protected]",
  "sexo": 0,
  "telefono": "0987654321",
  "id_ciudad": 1,
  "id_pais": 1,
  "id_empresa": 5,
  "id_campana": 12,
  "estado": 1
}

Create New Client

POST /Database/Database/clientes/

Create a new client in the system

Request Body

id_usuario
integer
required
User account ID to associate with this client
cedula_cliente
string
required
Client’s identification number (max 10 characters)
nombre
string
required
Client’s first name (max 20 characters)
apellido
string
required
Client’s last name (max 20 characters)
fecha_nacimiento
date
required
Client’s date of birth (YYYY-MM-DD)
email
string
required
Client’s email address (max 40 characters)
sexo
integer
required
Client’s gender (0 or 1)
telefono
string
required
Client’s phone number (max 10 characters)
id_ciudad
integer
default:"1"
City ID (defaults to 1 if not provided)
id_pais
integer
default:"1"
Country ID (defaults to 1 if not provided)
id_empresa
integer
Company ID to associate with this client (optional)
id_campana
integer
Campaign ID to associate with this client (optional)
estado
integer
required
Client status (0, 1, or 3)

Example Request

{
  "id_usuario": 60,
  "cedula_cliente": "1122334455",
  "nombre": "Laura",
  "apellido": "Mendoza",
  "fecha_nacimiento": "1993-04-12",
  "email": "[email protected]",
  "sexo": 0,
  "telefono": "0998877665",
  "id_ciudad": 1,
  "id_pais": 1,
  "id_empresa": 3,
  "id_campana": 8,
  "estado": 1
}

Example Response

{
  "id_cliente": 3,
  "id_usuario": 60,
  "cedula_cliente": "1122334455",
  "nombre": "Laura",
  "apellido": "Mendoza",
  "fecha_nacimiento": "1993-04-12",
  "email": "[email protected]",
  "sexo": 0,
  "telefono": "0998877665",
  "id_ciudad": 1,
  "id_pais": 1,
  "id_empresa": 3,
  "id_campana": 8,
  "estado": 1
}

Update Client

PUT /Database/Database/clientes/{id}/

Update an existing client’s information (full update)

Path Parameters

id
integer
required
The unique identifier of the client to update

Request Body

All fields from the create request are required for a full update.

Example Request

{
  "id_usuario": 60,
  "cedula_cliente": "1122334455",
  "nombre": "Laura Patricia",
  "apellido": "Mendoza López",
  "fecha_nacimiento": "1993-04-12",
  "email": "[email protected]",
  "sexo": 0,
  "telefono": "0998877665",
  "id_ciudad": 2,
  "id_pais": 1,
  "id_empresa": 3,
  "id_campana": 10,
  "estado": 1
}

Partial Update Client

PATCH /Database/Database/clientes/{id}/

Partially update a client’s information

Path Parameters

id
integer
required
The unique identifier of the client to update

Request Body

Include only the fields you want to update.

Example Request

{
  "id_campana": 15,
  "estado": 1
}

Delete Client

DELETE /Database/Database/clientes/{id}/

Delete a client from the system

Path Parameters

id
integer
required
The unique identifier of the client to delete

Response

HTTP 204 No Content

Relationships

The Cliente model has foreign key relationships with:
  • Usuario (id_usuario): Links to the user account. Each client must have an associated user account with authentication credentials
  • Ciudad (id_ciudad): Links to the city where the client is located
  • Pais (id_pais): Links to the country where the client is located
  • Empresa (id_empresa): Optional link to a company that the client represents or works with
  • CampanaPublicitaria (id_campana): Optional link to an active advertising campaign the client is participating in

Referenced By

Clients are referenced by:
  • Vehiculo model via id_cliente - Links vehicles owned by clients
  • MovimientoCapital model - Tracks financial transactions associated with clients

Business Logic

Client Registration Flow

  1. A user account must be created first with appropriate role
  2. The Cliente record is then created linking to the user via id_usuario
  3. Clients can optionally be associated with a company during or after registration
  4. Clients can enroll in advertising campaigns by setting id_campana

Campaign Association

  • Clients can be associated with advertising campaigns to track their participation
  • The id_campana field allows tracking which campaign a client is currently active in
  • Multiple clients can be associated with the same campaign
  • Clients can change campaigns by updating the id_campana field

Company Association

  • Clients can represent companies by linking via id_empresa
  • This is useful for corporate clients who manage vehicles on behalf of their organization
  • The company association is optional and can be null for individual clients

Status Management

  • Active (1): Client can participate in campaigns and use the system
  • Inactive (0): Client account exists but is not currently active
  • Disabled (3): Client has been disabled by administrators and cannot access the system

Validation Notes

  • cedula_cliente should be exactly 10 digits for most Latin American countries
  • email must be a valid email format
  • telefono should follow local phone number format (typically 10 digits)
  • id_usuario must reference an existing user with appropriate client role
  • id_empresa and id_campana are optional and can be null
  • The same cedula_cliente should not be registered multiple times

Query Parameters

The API supports filtering clients using query parameters:
  • ?estado=1 - Filter by status
  • ?id_empresa=5 - Filter by company
  • ?id_campana=12 - Filter by campaign
  • ?id_ciudad=2 - Filter by city
  • ?id_pais=1 - Filter by country

Example Use Cases

Creating a New Individual Client

curl -X POST https://api.example.com/Database/Database/clientes/ \
  -H "Content-Type: application/json" \
  -d '{
    "id_usuario": 75,
    "cedula_cliente": "5544332211",
    "nombre": "Roberto",
    "apellido": "Torres",
    "fecha_nacimiento": "1991-09-25",
    "email": "[email protected]",
    "sexo": 1,
    "telefono": "0991234567",
    "id_ciudad": 1,
    "id_pais": 1,
    "estado": 1
  }'

Enrolling a Client in a Campaign

curl -X PATCH https://api.example.com/Database/Database/clientes/1/ \
  -H "Content-Type: application/json" \
  -d '{
    "id_campana": 20
  }'

Filtering Active Clients by Company

curl -X GET "https://api.example.com/Database/Database/clientes/?estado=1&id_empresa=5"

Updating Client Contact Information

curl -X PATCH https://api.example.com/Database/Database/clientes/3/ \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "telefono": "0999988777"
  }'

Deactivating a Client

curl -X PATCH https://api.example.com/Database/Database/clientes/2/ \
  -H "Content-Type: application/json" \
  -d '{
    "estado": 0
  }'

Financial Integration

Clients are connected to the financial system through the MovimientoCapital model, which tracks:
  • Capital transactions related to campaigns
  • Payment history
  • Account balances
  • Transaction descriptions
This allows for complete financial tracking per client across their campaign participation.

Data Privacy Notes

  • Client personal information (cedula, email, phone) should be handled according to data protection regulations
  • Email addresses should be validated and verified
  • Phone numbers may be used for notifications and authentication
  • Identification numbers (cedula) are sensitive and should be protected

Build docs developers (and LLMs) love