> ## Documentation Index
> Fetch the complete documentation index at: https://docs.plazbot.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Contactos

> CRUD completo de contactos: crear, buscar, actualizar y eliminar

### Introduccion

El modulo de **Contact** te permite gestionar tu base de contactos de forma programatica. Puedes crear, buscar por telefono o email, actualizar y eliminar contactos.

### Inicializacion

<CodeGroup>
  ```ts Plazbot (recomendado) theme={null}
  import { Plazbot } from 'plazbot';

  const plazbot = new Plazbot({
    workspaceId: "YOUR_WORKSPACE_ID",
    apiKey: "YOUR_API_KEY",
    zone: "LA"
  });

  // Usar: plazbot.contact.getContacts()
  ```

  ```ts Contact individual theme={null}
  import { Contact } from 'plazbot';

  const contact = new Contact({
    workspaceId: "YOUR_WORKSPACE_ID",
    apiKey: "YOUR_API_KEY",
    zone: "LA"
  });
  ```
</CodeGroup>

***

### Crear Contacto

```ts theme={null}
const contact = await plazbot.contact.createContact({
  name: "Juan Perez",
  cellphone: "51912345678",
  email: "juan@ejemplo.com",
  tags: ["lead", "web"]
});

console.log("Contacto creado:", contact.id);
```

| Campo       | Tipo       | Requerido | Descripcion                           |
| ----------- | ---------- | --------- | ------------------------------------- |
| `name`      | `string`   | No        | Nombre del contacto                   |
| `cellphone` | `string`   | No        | Numero de telefono con codigo de pais |
| `email`     | `string`   | No        | Correo electronico                    |
| `tags`      | `string[]` | No        | Etiquetas de clasificacion            |
| `stage`     | `string`   | No        | Etapa del contacto en el pipeline     |

***

### Listar Contactos

```ts theme={null}
const contacts = await plazbot.contact.getContacts();
console.log(`Total: ${contacts.length} contactos`);
```

***

### Obtener Contacto por ID

```ts theme={null}
const contact = await plazbot.contact.getContact("contact-id");
console.log(contact.name, contact.email);
```

***

### Buscar por Telefono

```ts theme={null}
const results = await plazbot.contact.searchByPhone("51912345678");
```

***

### Buscar por Email

```ts theme={null}
const results = await plazbot.contact.searchByEmail("juan@ejemplo.com");
```

***

### Actualizar Contacto

```ts theme={null}
const updated = await plazbot.contact.updateContact({
  id: "contact-id",
  name: "Juan Perez Actualizado",
  tags: ["lead", "premium", "web"]
});
```

***

### Eliminar Contactos

Elimina uno o multiples contactos por sus IDs.

```ts theme={null}
await plazbot.contact.deleteContacts([
  "contact-id-1",
  "contact-id-2"
]);
```

***

### Campos del Contacto

| Campo       | Tipo       | Descripcion              |
| ----------- | ---------- | ------------------------ |
| `id`        | `string`   | Identificador unico      |
| `name`      | `string`   | Nombre del contacto      |
| `cellphone` | `string`   | Numero de telefono       |
| `email`     | `string`   | Correo electronico       |
| `tags`      | `string[]` | Etiquetas                |
| `stage`     | `string`   | Etapa en el pipeline     |
| `owner`     | `string`   | Propietario del contacto |
| `createdAt` | `string`   | Fecha de creacion        |
| `updatedAt` | `string`   | Fecha de actualizacion   |

***

### TypeScript

El SDK exporta los tipos para autocompletado:

```ts theme={null}
import type {
  ContactData,
  CreateContactParams,
  UpdateContactParams
} from 'plazbot';
```

<Tip>
  Combina el modulo de Contact con el de Message para enviar plantillas de WhatsApp a contactos de tu base de datos de forma automatizada.
</Tip>
