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

# Gestionar contactos

> Crear, buscar y actualizar contactos desde la API.

## Crear un contacto

```bash theme={null}
curl -X POST https://api.waspytech.com/api/v2/contacts \
  -H "Authorization: Bearer wspy_tu_key" \
  -H "Content-Type: application/json" \
  -d '{
    "phoneNumber": "+5491126032641",
    "name": "María García",
    "email": "maria@email.com",
    "tags": ["Cliente", "VIP"]
  }'
```

Si ya existe un contacto con ese número, recibís `409 CONTACT_ALREADY_EXISTS`.

***

## Buscar contactos

Por nombre, teléfono o email:

```bash theme={null}
curl "https://api.waspytech.com/api/v2/contacts?search=maria" \
  -H "Authorization: Bearer wspy_tu_key"
```

Por tag:

```bash theme={null}
curl "https://api.waspytech.com/api/v2/contacts?tag=VIP" \
  -H "Authorization: Bearer wspy_tu_key"
```

***

## Actualizar un contacto

Enviá solo los campos que querés cambiar:

```bash theme={null}
curl -X PATCH https://api.waspytech.com/api/v2/contacts/CONTACT_ID \
  -H "Authorization: Bearer wspy_tu_key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "María García López",
    "tags": ["VIP", "Mayorista"],
    "customFields": { "empresa": "Acme Corp", "rubro": "Indumentaria" }
  }'
```

<Info>
  `tags` reemplaza todos los tags anteriores. `customFields` hace merge con los existentes.
</Info>

***

## Sincronizar desde tu CRM

Si necesitás sincronizar contactos desde otro sistema:

1. **Buscar** si ya existe: `GET /contacts?search=+549...`
2. Si no existe, **crear**: `POST /contacts`
3. Si existe, **actualizar**: `PATCH /contacts/:id`

Usá el número de teléfono como identificador único para evitar duplicados.
