# API CartecWeb (Node) — Endpoints (curl one-liner)

**Base:** `http://34.41.180.210:3000`

---

## Auth / JWT

```bash
curl -s -X POST "http://34.41.180.210:3000/api/auth/token" -H "Content-Type: application/json" -d '{"apiKey":"cartecst"}'
curl -s "http://34.41.180.210:3000/api/test/protected" -H "Authorization: Bearer TOKEN"
```

---

## Health

```bash
curl -s "http://34.41.180.210:3000/api/health"
curl -s "http://34.41.180.210:3000/api/health?db=1"
```

---

## OT

```bash
curl -s "http://34.41.180.210:3000/api/ot/list"
curl -s "http://34.41.180.210:3000/api/ot/list?limit=20"
curl -s "http://34.41.180.210:3000/api/ot/list?estado=pendiente"
curl -s "http://34.41.180.210:3000/api/ot/list?rut_tecnico=11111111-1"
curl -s "http://34.41.180.210:3000/api/ot/latest"
curl -s "http://34.41.180.210:3000/api/ot/1"

curl -s -X POST "   " -H "Content-Type: application/json" -d '{"cliente":{"rut":"12345678-5","nombre":"Test","direccion":"Av. Test 123","comuna":"Santiago"},"tecnico":{"rut":"11111111-1"},"servicio":{"presGPS":"gpsimple","tiposerv":"instalacion_gps","taller_install":"domicilio"},"vehiculos":[{"patente":"TEST99"}]}'

curl -s -X PATCH "http://34.41.180.210:3000/api/ot/1/complete" -H "Content-Type: application/json" -d '{"hora_llegada":"09:00","hora_salida":"10:30","observaciones":"OK"}'
```

---

## Cliente

```bash
curl -s "http://34.41.180.210:3000/api/cliente/12345678-5"
```

---

## GPS (requiere GPS_DB_* en .env)

```bash
curl -s "http://34.41.180.210:3000/api/gps/position/IMEI_DEVICE"
curl -s "http://34.41.180.210:3000/api/gps/info/ID"
curl -s "http://34.41.180.210:3000/api/tecnicos"
```

---

## Vehículo (VIN — Carcloud)

```bash
curl -s "http://34.41.180.210:3000/api/vehiculo/vin/WBAPH5C5XBA123456"
```

---

## Resumen por método

| Método | Ruta | One-liner (reemplazar :param y TOKEN) |
|--------|------|--------------------------------------|
| POST | `/api/auth/token` | `curl -s -X POST "http://34.41.180.210:3000/api/auth/token" -H "Content-Type: application/json" -d '{"apiKey":"cartecst"}'` |
| GET | `/api/test/protected` | `curl -s "http://34.41.180.210:3000/api/test/protected" -H "Authorization: Bearer TOKEN"` |
| GET | `/api/health` | `curl -s "http://34.41.180.210:3000/api/health"` |
| GET | `/api/health?db=1` | `curl -s "http://34.41.180.210:3000/api/health?db=1"` |
| GET | `/api/ot/list` | `curl -s "http://34.41.180.210:3000/api/ot/list"` |
| GET | `/api/ot/list?limit=N` | `curl -s "http://34.41.180.210:3000/api/ot/list?limit=20"` |
| GET | `/api/ot/list?estado=X` | `curl -s "http://34.41.180.210:3000/api/ot/list?estado=pendiente"` |
| GET | `/api/ot/list?rut_tecnico=X` | `curl -s "http://34.41.180.210:3000/api/ot/list?rut_tecnico=11111111-1"` |
| GET | `/api/ot/latest` | `curl -s "http://34.41.180.210:3000/api/ot/latest"` |
| GET | `/api/ot/:id` | `curl -s "http://34.41.180.210:3000/api/ot/1"` |
| POST | `/api/ot/create` | `curl -s -X POST "http://34.41.180.210:3000/api/ot/create" -H "Content-Type: application/json" -d '{"cliente":{"rut":"12345678-5","nombre":"Test","direccion":"Av. Test 123","comuna":"Santiago"},"tecnico":{"rut":"11111111-1"},"servicio":{"presGPS":"gpsimple","tiposerv":"instalacion_gps","taller_install":"domicilio"},"vehiculos":[{"patente":"TEST99"}]}'` |
| PATCH | `/api/ot/:id/complete` | `curl -s -X PATCH "http://34.41.180.210:3000/api/ot/1/complete" -H "Content-Type: application/json" -d '{"observaciones":"OK"}'` |
| GET | `/api/cliente/:rut` | `curl -s "http://34.41.180.210:3000/api/cliente/12345678-5"` |
| GET | `/api/gps/position/:imei` | `curl -s "http://34.41.180.210:3000/api/gps/position/IMEI_DEVICE"` |
| GET | `/api/gps/info/:id` | `curl -s "http://34.41.180.210:3000/api/gps/info/ID"` |
| GET | `/api/tecnicos` | `curl -s "http://34.41.180.210:3000/api/tecnicos"` |
| GET | `/api/vehiculo/vin/:vin` | `curl -s "http://34.41.180.210:3000/api/vehiculo/vin/WBAPH5C5XBA123456"` |
