{
  "info": {
    "name": "Valida API v1",
    "_postman_id": "8c1e2b8a-valida-2026-09-08",
    "description": "API de Valida (MeTRIK SAS). Guia del integrador: https://app.valida.metrikone.co/docs. Configure las variables base_url y api_key en el entorno. Soporte: mauricio.moreno@metrik.com.co / WhatsApp +57 315 950 9103.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "bearer",
    "bearer": [
      {
        "key": "token",
        "value": "{{api_key}}",
        "type": "string"
      }
    ]
  },
  "variable": [
    {
      "key": "base_url",
      "value": "https://api.valida.metrikone.co"
    },
    {
      "key": "api_key",
      "value": ""
    },
    {
      "key": "consulta_id",
      "value": ""
    }
  ],
  "event": [
    {
      "listen": "prerequest",
      "script": {
        "type": "text/javascript",
        "exec": [
          "// Idempotency-Key nueva por peticion (POST /validate). Reutilice la misma clave solo para reintentar la misma consulta.",
          "pm.variables.set('idempotency_key', (crypto && crypto.randomUUID) ? crypto.randomUUID() : Date.now().toString(36) + Math.random().toString(36).slice(2));"
        ]
      }
    }
  ],
  "item": [
    {
      "name": "Salud",
      "item": [
        {
          "name": "GET /health",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/health",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "health"
              ]
            },
            "description": "Sin autenticacion."
          }
        }
      ]
    },
    {
      "name": "Validacion",
      "item": [
        {
          "name": "POST /validate — persona natural",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Idempotency-Key",
                "value": "{{idempotency_key}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/validate",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "validate"
              ]
            },
            "description": "Guarda consulta_id en la variable de coleccion (ver Tests).",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"tipo\": \"natural\",\n  \"nombre\": \"Juan Perez Gomez\",\n  \"documento\": {\n    \"tipo\": \"CC\",\n    \"numero\": \"1077089147\"\n  },\n  \"fecha_nacimiento\": \"1985-03-15\",\n  \"pais\": \"CO\",\n  \"referencia_externa\": \"EXP-2026-00123\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.response.code === 200) { pm.collectionVariables.set('consulta_id', pm.response.json().consulta_id); }",
                  "pm.test('X-Valida-Request-Id presente', () => pm.expect(pm.response.headers.has('X-Valida-Request-Id')).to.be.true);"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /validate — juridica con sujeto obligado (agregador)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Idempotency-Key",
                "value": "{{idempotency_key}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/validate",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "validate"
              ]
            },
            "description": "Obligatorio si su cliente API opera para terceros.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"tipo\": \"juridica\",\n  \"nombre\": \"Acme Trading SAS\",\n  \"documento\": {\n    \"tipo\": \"NIT\",\n    \"numero\": \"900123456\"\n  },\n  \"sujeto_obligado\": {\n    \"razon_social\": \"Transportes La Sabana SAS\",\n    \"nit\": \"800.123.456-7\"\n  },\n  \"referencia_externa\": \"vinculacion-8841\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        },
        {
          "name": "POST /validate — solo documento (parcial)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Idempotency-Key",
                "value": "{{idempotency_key}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/validate",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "validate"
              ]
            },
            "description": "",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"tipo\": \"natural\",\n  \"documento\": {\n    \"tipo\": \"CC\",\n    \"numero\": \"1077089147\"\n  }\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        },
        {
          "name": "GET /consultas",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/consultas?limite=50&severidad=alto&referencia_externa=EXP-2026-00123",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "consultas"
              ],
              "query": [
                {
                  "key": "limite",
                  "value": "50"
                },
                {
                  "key": "severidad",
                  "value": "alto"
                },
                {
                  "key": "referencia_externa",
                  "value": "EXP-2026-00123"
                }
              ]
            },
            "description": ""
          }
        }
      ]
    },
    {
      "name": "Reportes",
      "item": [
        {
          "name": "GET /reporte/{consulta_id} (PDF)",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/reporte/{{consulta_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "reporte",
                "{{consulta_id}}"
              ]
            },
            "description": "Descarga el PDF: en Postman use 'Send and Download'."
          }
        },
        {
          "name": "POST /reporte-lote (PDF)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/reporte-lote",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "reporte-lote"
              ]
            },
            "description": "",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"consulta_ids\": [\n    \"{{consulta_id}}\"\n  ],\n  \"titulo\": \"Cargue plantilla septiembre 2026\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        }
      ]
    },
    {
      "name": "Cuenta",
      "item": [
        {
          "name": "GET /cuenta/consumo",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/cuenta/consumo",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "cuenta",
                "consumo"
              ]
            },
            "description": ""
          }
        },
        {
          "name": "GET /cuenta/consumo/historial",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/cuenta/consumo/historial?periodos=6",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "cuenta",
                "consumo",
                "historial"
              ],
              "query": [
                {
                  "key": "periodos",
                  "value": "6"
                }
              ]
            },
            "description": ""
          }
        },
        {
          "name": "GET /cuenta/alertas",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/cuenta/alertas",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "cuenta",
                "alertas"
              ]
            },
            "description": ""
          }
        },
        {
          "name": "PUT /cuenta/alertas",
          "request": {
            "method": "PUT",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/cuenta/alertas",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "cuenta",
                "alertas"
              ]
            },
            "description": "webhook.secret viene UNA sola vez, al configurar la URL por primera vez.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"umbrales\": [\n    80,\n    100\n  ],\n  \"emails\": [\n    \"cumplimiento@suempresa.co\"\n  ],\n  \"webhook\": {\n    \"url\": \"https://suempresa.co/valida/webhook\"\n  },\n  \"activa\": true\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        },
        {
          "name": "POST /cuenta/alertas/webhook/rotar-secreto",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/cuenta/alertas/webhook/rotar-secreto",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "cuenta",
                "alertas",
                "webhook",
                "rotar-secreto"
              ]
            },
            "description": ""
          }
        },
        {
          "name": "POST /cuenta/alertas/prueba",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/cuenta/alertas/prueba",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "cuenta",
                "alertas",
                "prueba"
              ]
            },
            "description": ""
          }
        }
      ]
    }
  ]
}
