Clientes y Contactos

Gestiona registros de clientes e información de contacto a través de la API.

Descripción General

La API de Customers te permite crear, obtener y gestionar registros de clientes. Úsala para construir integraciones CRM, programas de lealtad o automatización de marketing.

Listar Clientes

curl -X GET https://api.whatalo.com/v1/customers \
  -H "X-API-Key: wk_live_your_key_here"

Scope requerido: read:customers

Obtener un Cliente

curl -X GET https://api.whatalo.com/v1/customers/cus_abc123 \
  -H "X-API-Key: wk_live_your_key_here"

Crear un Cliente

curl -X POST https://api.whatalo.com/v1/customers \
  -H "X-API-Key: wk_live_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "María García",
    "email": "[email protected]",
    "phone": "+18095551234"
  }'

Scope requerido: write:customers

Solo name es requerido. email, phone y notes son opcionales.

Actualizar un Cliente

curl -X PATCH https://api.whatalo.com/v1/customers/cus_abc123 \
  -H "X-API-Key: wk_live_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "phone": "+18095559876"
  }'

Scope requerido: write:customers

Obtener Conteo de Clientes

curl -X GET https://api.whatalo.com/v1/customers/count \
  -H "X-API-Key: wk_live_your_key_here"

Patrones Comunes

Sincronización CRM

Sincroniza datos de clientes con un CRM externo:

async function syncToCRM(customerId) {
  const res = await fetch(
    `https://api.whatalo.com/v1/customers/${customerId}`,
    { headers: { 'X-API-Key': API_KEY } }
  );

  if (!res.ok) {
    throw new Error(`Failed to fetch customer: ${res.status}`);
  }

  const { data } = await res.json();

  await crm.upsertContact({
    email: data.email,
    name: data.name,
    phone: data.phone,
    source: 'whatalo'
  });
}

Importar Clientes en Masa

async function importCustomers(csvRows) {
  const results = { success: 0, failed: 0 };

  for (const row of csvRows) {
    const res = await fetch('https://api.whatalo.com/v1/customers', {
      method: 'POST',
      headers: {
        'X-API-Key': API_KEY,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        name: row.name,
        email: row.email,
        phone: row.phone
      })
    });

    if (res.ok) {
      results.success++;
    } else {
      results.failed++;
      console.error(`Failed to import ${row.email}:`, await res.json());
    }
  }

  return results;
}

Para importaciones masivas, ten en cuenta el límite de tasa (1,000 peticiones/minuto). Agrega una demora entre peticiones para conjuntos de datos grandes.

On this page