Clientes
CRUD completo para la gestión de clientes del despacho
curl https://app.getplea.com/api/clients?limit=20&search=martinez \
-H "Authorization: Bearer TOKEN" \
-H "x-organization-id: ORG_ID"
const clients = await fetch('/api/clients?limit=20&search=martinez', {
headers: {
'Authorization': 'Bearer TOKEN',
'x-organization-id': 'ORG_ID'
}
}).then(r => r.json());
[
{
"id": "client-uuid-1",
"name": "Elena Martínez Ruiz",
"email": "elena.martinez@email.com",
"phone": "+34 612 345 678",
"isCompany": false,
"taxId": "12345678A",
"address": "Calle Mayor 15, 28001 Madrid",
"createdAt": "2026-01-15T09:00:00Z"
},
{
"id": "client-uuid-2",
"name": "Martínez Construcciones S.L.",
"email": "admin@martinez-sl.com",
"phone": "+34 915 111 222",
"isCompany": true,
"taxId": "B11223344",
"address": "Polígono Industrial Sur 23, Getafe",
"createdAt": "2026-02-20T14:30:00Z"
}
]
curl https://app.getplea.com/api/clients/client-uuid-1 \
-H "Authorization: Bearer TOKEN" \
-H "x-organization-id: ORG_ID"
const client = await fetch('/api/clients/client-uuid-1', {
headers: {
'Authorization': 'Bearer TOKEN',
'x-organization-id': 'ORG_ID'
}
}).then(r => r.json());
{
"id": "client-uuid-1",
"name": "Elena Martínez Ruiz",
"email": "elena.martinez@email.com",
"phone": "+34 612 345 678",
"isCompany": false,
"taxId": "12345678A",
"address": "Calle Mayor 15, 28001 Madrid",
"notes": "Clienta habitual desde 2024",
"cases": [
{
"id": "case-uuid-1",
"caseNumber": "2026/0042",
"status": "open"
}
],
"createdAt": "2026-01-15T09:00:00Z",
"updatedAt": "2026-03-01T11:20:00Z"
}
{
"error": "Not Found",
"message": "Cliente no encontrado"
}
curl -X POST https://app.getplea.com/api/clients \
-H "Authorization: Bearer TOKEN" \
-H "Content-Type: application/json" \
-H "x-organization-id: ORG_ID" \
-d '{
"name": "Roberto García Díaz",
"email": "roberto.garcia@email.com",
"phone": "+34 655 432 100",
"isCompany": false,
"taxId": "87654321B",
"address": "Av. de la Constitución 8, Sevilla"
}'
const client = await fetch('/api/clients', {
method: 'POST',
headers: {
'Authorization': 'Bearer TOKEN',
'Content-Type': 'application/json',
'x-organization-id': 'ORG_ID'
},
body: JSON.stringify({
name: 'Roberto García Díaz',
email: 'roberto.garcia@email.com',
phone: '+34 655 432 100',
isCompany: false,
taxId: '87654321B',
address: 'Av. de la Constitución 8, Sevilla'
})
}).then(r => r.json());
{
"id": "client-uuid-new",
"name": "Roberto García Díaz",
"email": "roberto.garcia@email.com",
"phone": "+34 655 432 100",
"isCompany": false,
"taxId": "87654321B",
"address": "Av. de la Constitución 8, Sevilla",
"createdAt": "2026-03-07T12:00:00Z"
}
{
"error": "Bad Request",
"message": "El campo 'name' es obligatorio"
}
curl -X PATCH https://app.getplea.com/api/clients/client-uuid-1 \
-H "Authorization: Bearer TOKEN" \
-H "Content-Type: application/json" \
-H "x-organization-id: ORG_ID" \
-d '{"phone": "+34 612 999 888", "address": "Nueva dirección 10, Madrid"}'
await fetch('/api/clients/client-uuid-1', {
method: 'PATCH',
headers: {
'Authorization': 'Bearer TOKEN',
'Content-Type': 'application/json',
'x-organization-id': 'ORG_ID'
},
body: JSON.stringify({
phone: '+34 612 999 888',
address: 'Nueva dirección 10, Madrid'
})
});
{
"id": "client-uuid-1",
"name": "Elena Martínez Ruiz",
"email": "elena.martinez@email.com",
"phone": "+34 612 999 888",
"address": "Nueva dirección 10, Madrid",
"updatedAt": "2026-03-07T12:30:00Z"
}
curl -X DELETE https://app.getplea.com/api/clients/client-uuid-1 \
-H "Authorization: Bearer TOKEN" \
-H "x-organization-id: ORG_ID"
await fetch('/api/clients/client-uuid-1', {
method: 'DELETE',
headers: {
'Authorization': 'Bearer TOKEN',
'x-organization-id': 'ORG_ID'
}
});
{
"message": "Cliente eliminado correctamente"
}
{
"error": "Conflict",
"message": "No se puede eliminar: el cliente tiene 3 expedientes activos"
}
curl https://app.getplea.com/api/clients/client-uuid-1/dependencies \
-H "Authorization: Bearer TOKEN" \
-H "x-organization-id: ORG_ID"
const deps = await fetch('/api/clients/client-uuid-1/dependencies', {
headers: {
'Authorization': 'Bearer TOKEN',
'x-organization-id': 'ORG_ID'
}
}).then(r => r.json());
{
"cases": 3,
"invoices": 7,
"documents": 12,
"tasks": 5,
"canDelete": false
}
curl https://app.getplea.com/api/client-overview/client-uuid-1 \
-H "Authorization: Bearer TOKEN" \
-H "x-organization-id: ORG_ID"
const overview = await fetch('/api/client-overview/client-uuid-1', {
headers: {
'Authorization': 'Bearer TOKEN',
'x-organization-id': 'ORG_ID'
}
}).then(r => r.json());
{
"client": {
"id": "client-uuid-1",
"name": "Elena Martínez Ruiz"
},
"activeCases": 2,
"totalInvoiced": 15750.00,
"pendingPayments": 3200.00,
"lastActivity": "2026-03-06T16:45:00Z",
"recentCases": [
{
"id": "case-uuid-1",
"caseNumber": "2026/0042",
"status": "open",
"caseType": "civil"
}
]
}
Endpoints para crear, consultar, actualizar y eliminar clientes. Un cliente puede ser una persona física o una empresa.
GET /api/clients
Lista todos los clientes de la organización.
Número máximo de resultados. Default: 50.
Desplazamiento para paginación. Default: 0.
Búsqueda por nombre, email o NIF.
GET /api/clients/:id
Obtiene los detalles completos de un cliente.
UUID del cliente.
POST /api/clients
Crea un nuevo cliente.
Nombre del cliente o razón social.
Email de contacto.
Teléfono de contacto.
true si es persona jurídica (empresa). Default: false.
NIF (persona física) o CIF (empresa).
Dirección postal completa.
PATCH /api/clients/:id
Actualiza los datos de un cliente existente.
UUID del cliente.
Nuevo nombre.
Nuevo email.
Nuevo teléfono.
Nueva dirección.
DELETE /api/clients/:id
Elimina un cliente. Solo es posible si no tiene expedientes activos.
UUID del cliente a eliminar.
GET /api/clients/:id/dependencies
Consulta las dependencias de un cliente antes de eliminarlo (expedientes, facturas, documentos vinculados).
UUID del cliente.
GET /api/client-overview/:id
Obtiene un resumen general del cliente: expedientes, facturas pendientes, última actividad.
UUID del cliente.
Last updated today