Crear Cliente
Registra un nuevo cliente en tu organización para agilizar la emisión de facturas. Los clientes registrados permiten emitir CFDIs usando solo su ID, sin necesidad de enviar los datos fiscales completos cada vez.
Endpoint
POST https://api.lummy.io/v1/customers
| Entorno | URL |
|---|---|
| Producción | https://api.lummy.io/v1/customers |
| Sandbox | https://sandbox.lummy.io/v1/customers |
Request
Headers
"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...""550e8400-e29b-41d4-a716-446655440000""application/json"Body
"XEXX010101000""EMPRESA EJEMPLO SA DE CV""601""603""605""606""607""608""610""611""612""614""615""616""620""621""622""623""624""625""626""601""06500""facturacion@empresa-ejemplo.com""+52 55 1234 5678"Response
201 Created
Cliente creado exitosamente. El cliente queda disponible inmediatamente para ser usado en la emisión de facturas.
"req_abc123-def456-ghi789""550e8400-e29b-41d4-a716-446655440000""XEXX010101000""EMPRESA EJEMPLO SA DE CV""601""06500""facturacion@empresa-ejemplo.com""+52 55 1234 5678""2025-01-15T10:30:00.000Z""2025-01-15T10:30:00.000Z""2025-01-15T10:30:00.000Z""/customers""POST"400 Bad Request
Error de validación en los datos enviados.
{
"requestId": "req_abc123-def456",
"error": {
"message": "RFC inválido: debe tener 12 o 13 caracteres",
"code": "ValidationError",
"status": 400
},
"timestamp": "2025-01-15T10:30:00.000Z",
"path": "/customers",
"method": "POST"
}
409 Conflict
Ya existe un cliente con el mismo RFC en esta organización.
{
"requestId": "req_abc123-def456",
"error": {
"message": "Ya existe un cliente con el RFC XEXX010101000 en esta organización",
"code": "ConflictException",
"status": 409
},
"timestamp": "2025-01-15T10:30:00.000Z",
"path": "/customers",
"method": "POST"
}
401 Unauthorized
Token de autenticación inválido o expirado.
{
"requestId": "req_abc123-def456",
"error": {
"message": "Token inválido o expirado",
"code": "UnauthorizedException",
"status": 401
},
"timestamp": "2025-01-15T10:30:00.000Z",
"path": "/customers",
"method": "POST"
}
Ejemplos de Código
- cURL
- Node.js
- Python
curl -X POST "https://api.lummy.io/customers" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "x-organization-id: ${ORG_ID}" \
-d '{
"rfc": "XEXX010101000",
"legalName": "EMPRESA EJEMPLO SA DE CV",
"fiscalRegime": "601",
"fiscalZipCode": "06500",
"email": "facturacion@empresa-ejemplo.com",
"phone": "+52 55 1234 5678"
}'
const response = await fetch('https://api.lummy.io/customers', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${ACCESS_TOKEN}`,
'x-organization-id': ORG_ID,
},
body: JSON.stringify({
rfc: 'XEXX010101000',
legalName: 'EMPRESA EJEMPLO SA DE CV',
fiscalRegime: '601',
fiscalZipCode: '06500',
email: 'facturacion@empresa-ejemplo.com',
phone: '+52 55 1234 5678',
}),
});
const data = await response.json();
console.log('Cliente creado:', data.data.id);
import requests
response = requests.post(
'https://api.lummy.io/customers',
headers={
'Content-Type': 'application/json',
'Authorization': f'Bearer {ACCESS_TOKEN}',
'x-organization-id': ORG_ID,
},
json={
'rfc': 'XEXX010101000',
'legalName': 'EMPRESA EJEMPLO SA DE CV',
'fiscalRegime': '601',
'fiscalZipCode': '06500',
'email': 'facturacion@empresa-ejemplo.com',
'phone': '+52 55 1234 5678',
}
)
data = response.json()
print(f"Cliente creado: {data['data']['id']}")
Notas Importantes
Se recomienda validar el RFC del cliente usando el endpoint POST /rfc/validate antes de registrarlo, para verificar que no aparezca en las listas 69 y 69-B del SAT.
El RFC, razón social y régimen fiscal deben coincidir exactamente con los registrados en la Constancia de Situación Fiscal del cliente. Discrepancias causarán que el PAC rechace las facturas con el error CFDI40139.