Skip to main content

Overview

The Clients API provides endpoints for creating, updating, searching, and deleting client records. All endpoints require authentication via session.

Create Client

curl -X POST https://your-domain.com/ajax/nuevo_cliente.php \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -H "Cookie: PHPSESSID=your-session-id" \
  -d "nombre=Acme Corp" \
  -d "telefono=555-0123" \
  -d "email=contact@acme.com" \
  -d "direccion=123 Main St" \
  -d "estado=1"
nombre
string
required
Client name
telefono
string
Client phone number (up to 30 characters)
email
string
Client email address (up to 64 characters)
direccion
string
Client address (up to 255 characters)
estado
integer
required
Client status: 1 for active, 0 for inactive
success
html
Returns HTML alert with success message: “Cliente ha sido ingresado satisfactoriamente.”
error
html
Returns HTML alert with error message if validation fails

Update Client

curl -X POST https://your-domain.com/ajax/editar_cliente.php \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -H "Cookie: PHPSESSID=your-session-id" \
  -d "mod_id=5" \
  -d "mod_nombre=Acme Corporation" \
  -d "mod_telefono=555-0123" \
  -d "mod_email=info@acme.com" \
  -d "mod_direccion=456 Market St" \
  -d "mod_estado=1"
mod_id
integer
required
Client ID to update
mod_nombre
string
required
Updated client name
mod_telefono
string
Updated phone number
mod_email
string
Updated email address
mod_direccion
string
Updated address
mod_estado
integer
required
Updated status: 1 for active, 0 for inactive
success
html
Returns HTML alert with message: “Cliente ha sido actualizado satisfactoriamente.”
error
html
Returns HTML alert with error message if validation fails

Search Clients

curl -X GET "https://your-domain.com/ajax/buscar_clientes.php?action=ajax&q=Acme&page=1" \
  -H "Cookie: PHPSESSID=your-session-id"
action
string
required
Must be set to "ajax" to trigger search
q
string
Search term to filter clients by name. Leave empty to return all clients.
page
integer
Page number for pagination (default: 1, 10 results per page)
html_table
html
Returns HTML table with client data including:
  • id_cliente - Client ID
  • nombre_cliente - Client name
  • telefono_cliente - Phone number
  • email_cliente - Email address
  • direccion_cliente - Address
  • status_cliente - Status (1 = Active, 0 = Inactive)
  • date_added - Date added (formatted as d/m/Y)

Delete Client

curl -X GET "https://your-domain.com/ajax/buscar_clientes.php?id=5" \
  -H "Cookie: PHPSESSID=your-session-id"
id
integer
required
Client ID to delete
success
html
Returns success alert if client is deleted successfully
error
html
Returns error alert if:
  • Client has associated invoices (foreign key constraint)
  • Database error occurs
Clients cannot be deleted if they have associated invoices in the system.

Autocomplete Clients

curl -X GET "https://your-domain.com/ajax/autocomplete/clientes.php?term=Acme" \
  -H "Cookie: PHPSESSID=your-session-id"
term
string
required
Search term for autocomplete (partial client name)
results
array
Returns JSON array (max 50 results) with objects containing:
  • value - Client name
  • id_cliente - Client ID
  • nombre_cliente - Client name
  • telefono_cliente - Phone number
  • email_cliente - Email address
[
  {
    "value": "Acme Corporation",
    "id_cliente": "5",
    "nombre_cliente": "Acme Corporation",
    "telefono_cliente": "555-0123",
    "email_cliente": "contact@acme.com"
  },
  {
    "value": "Acme Industries",
    "id_cliente": "12",
    "nombre_cliente": "Acme Industries",
    "telefono_cliente": "555-0456",
    "email_cliente": "info@acmeindustries.com"
  }
]

Build docs developers (and LLMs) love