Normacol API — Guía Rápida

Base URL: https://api.normacol.com. Interactúa en /api/docs. OpenAPI: /api/openapi.json.

1) Autenticación

Obtén un access_token:

curl -s -X POST \
 "https://api.normacol.com/api/auth/login" \
 -H "Content-Type: application/json" \
 -d '{
  "username": "admin",
  "password": "<TU_PASSWORD>",
  "app_id": "<APP_ID>"
}'

Guardar token en variable TOKEN:

TOKEN=$(curl -s -X POST \
 "https://api.normacol.com/api/auth/login" \
 -H "Content-Type: application/json" \
 -d '{"username":"admin","password":"<TU_PASSWORD>","app_id":"<APP_ID>"}' \
 | python3 -c "import sys, json; print(json.load(sys.stdin)['access_token'])")
echo "TOKEN=${TOKEN}"

2) Usar el token

# Usuario actual
curl -s "https://api.normacol.com/api/auth/me" -H "Authorization: Bearer ${TOKEN}"

# Salud RBAC (opcional)
curl -s "https://api.normacol.com/api/auth/rbac/health" -H "Authorization: Bearer ${TOKEN}"

3) Productos

Líneas y sublíneas

curl -s "https://api.normacol.com/api/products/lineas" -H "Authorization: Bearer ${TOKEN}"
curl -s "https://api.normacol.com/api/products/sublineas?linea=<LINEA>" -H "Authorization: Bearer ${TOKEN}"

Listado con filtros

curl -s "https://api.normacol.com/api/products?per_page=10&has_stock=true&sort_by=unidad&sort_order=asc" \
 -H "Authorization: Bearer ${TOKEN}"

4) Clientes

Ciudades

curl -s "https://api.normacol.com/api/clients/cities" -H "Authorization: Bearer ${TOKEN}"

Listado

curl -s "https://api.normacol.com/api/clients?per_page=10&sort_by=last_purchase_date&sort_order=desc" \
 -H "Authorization: Bearer ${TOKEN}"

Crear / Actualizar / Consultar

# Crear
curl -s -X POST "https://api.normacol.com/api/clients" \
 -H "Authorization: Bearer ${TOKEN}" -H "Content-Type: application/json" \
 -d '{
  "commercial_name": "API Test",
  "identification": "API-TEST-001",
  "address": "Calle 1",
  "city": "Medellín",
  "department": "Antioquia",
  "client_label": "no_trabajado",
  "seller_id": 1
}'

# Actualizar
curl -s -X PUT "https://api.normacol.com/api/clients/<ID>" \
 -H "Authorization: Bearer ${TOKEN}" -H "Content-Type: application/json" \
 -d '{"commercial_name": "API Test (Editado)", "city": "Bogotá"}'

# Obtener
curl -s "https://api.normacol.com/api/clients/<ID>" -H "Authorization: Bearer ${TOKEN}"

5) Usuarios (admin)

# Listar
curl -s "https://api.normacol.com/api/users?per_page=10" -H "Authorization: Bearer ${TOKEN}"

# Crear
curl -s -X POST "https://api.normacol.com/api/users"  -H "Authorization: Bearer ${TOKEN}" -H "Content-Type: application/json"  -d '{"username":"nuevo_user","password":"MiC0ntr4$eña","role":"user"}'

# Actualizar
curl -s -X PUT "https://api.normacol.com/api/users/<USER_ID>"  -H "Authorization: Bearer ${TOKEN}" -H "Content-Type: application/json"  -d '{"role":"admin","is_active":true}'

# Eliminar
curl -s -X DELETE "https://api.normacol.com/api/users/<USER_ID>" -H "Authorization: Bearer ${TOKEN}"

6) Recursos útiles

Swagger UI OpenAPI JSON Postman Collection