# Contactos

Gestión del CRM de tu cuenta. Todas las rutas cuelgan de `https://panel.anunzi.net/api/v1/contacts/` y llevan `Authorization: Bearer anz_live_…`.

| Método | Ruta | Descripción |
| ------ | ---- | ----------- |
| `GET`  | `list.php` | Lista contactos (paginado, con filtros). |
| `GET`  | `get.php?id=` | Detalle de un contacto + notas. |
| `POST` | `create.php` | Crea o actualiza (upsert por teléfono/email). |
| `POST` | `update.php?id=` | Actualiza campos, estado, score y etiquetas. |
| `POST` | `import.php` | Importa un lote de contactos. |
| `GET/POST` | `notes.php?id=` | Lista o agrega notas. |

***

## Listar

`GET /api/v1/contacts/list.php`

Filtros (query): `search`, `status`, `tag`, `segment_id`, más `limit`/`offset`.

```bash
curl "https://panel.anunzi.net/api/v1/contacts/list.php?tag=VIP&limit=20" \
  -H "Authorization: Bearer anz_live_TU_API_KEY"
```

## Crear / actualizar

`POST /api/v1/contacts/create.php`

```json
{
  "name": "Ana", "last_name": "Pérez",
  "phone": "+5491123456789", "email": "ana@x.com",
  "status": "Nuevo", "tags": ["VIP"], "custom": { "empresa": "Acme" }
}
```

Devuelve `{ "id": 123, "result": "inserted" | "updated" }`. Requiere al menos teléfono o email.

## Actualizar

`POST /api/v1/contacts/update.php?id=123` — todos los campos son opcionales:

```json
{ "status": "Contactado", "score": 60, "add_tags": ["Interesado"], "remove_tags": ["Frío"] }
```

`tags` reemplaza la lista completa; `add_tags`/`remove_tags` la modifican.

## Importar lote

`POST /api/v1/contacts/import.php`

```json
{ "contacts": [ {"name":"Juan","phone":"+54911..."}, {"email":"b@x.com"} ], "tags": ["Feria 2026"] }
```

Devuelve `{ "inserted": N, "updated": N, "skipped": N, "total": N }`. Máximo 5000 por lote.

## Notas

- `GET /api/v1/contacts/notes.php?id=123` → lista las notas.
- `POST /api/v1/contacts/notes.php?id=123` con `{ "body": "texto", "author": "opcional" }` → agrega una.
