{
  "info": {
    "name": "ERPly Pro — Identity Validation API v1",
    "description": "Colección Postman para la API de Validación de Identidad ERPly Pro.\n\nDocumentación: https://api.erply.pro/docs/concepts/identity-validation",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    {
      "key": "base_url",
      "value": "https://api.erply.pro",
      "description": "URL base del API. Cambiar a https://dev.api.erply.pro para sandbox."
    },
    {
      "key": "api_key",
      "value": "YOUR_API_KEY",
      "description": "API key de sandbox o producción."
    },
    {
      "key": "document",
      "value": "130862346",
      "description": "RNC o Cédula para consultas."
    }
  ],
  "auth": {
    "type": "apikey",
    "apikey": [
      {
        "key": "key",
        "value": "x-api-key",
        "type": "string"
      },
      {
        "key": "value",
        "value": "{{api_key}}",
        "type": "string"
      },
      {
        "key": "in",
        "value": "header",
        "type": "string"
      }
    ]
  },
  "item": [
    {
      "name": "Document Lookup",
      "item": [
        {
          "name": "Lookup by RNC",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/v1/dgii/document/130862346",
              "host": ["{{base_url}}"],
              "path": ["v1", "dgii", "document", "130862346"]
            },
            "description": "Consulta un contribuyente por RNC de 9 dígitos.\n\nRef: https://api.erply.pro/docs/reference/identity/identity-document-lookup-ref"
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Status is 200', function () {",
                  "  pm.response.to.have.status(200);",
                  "});",
                  "pm.test('Response has rnc field', function () {",
                  "  const json = pm.response.json();",
                  "  pm.expect(json).to.have.property('rnc');",
                  "  pm.expect(json).to.have.property('name');",
                  "  pm.expect(json).to.have.property('status');",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "Lookup by Cédula",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/v1/dgii/document/00112345678",
              "host": ["{{base_url}}"],
              "path": ["v1", "dgii", "document", "00112345678"]
            },
            "description": "Consulta un contribuyente por Cédula de 11 dígitos.\n\nRef: https://api.erply.pro/docs/reference/identity/identity-document-lookup-ref"
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Status is 200 or 404', function () {",
                  "  pm.expect(pm.response.code).to.be.oneOf([200, 404]);",
                  "});",
                  "pm.test('Response has expected shape', function () {",
                  "  const json = pm.response.json();",
                  "  if (pm.response.code === 200) {",
                  "    pm.expect(json).to.have.property('rnc');",
                  "  } else {",
                  "    pm.expect(json).to.have.property('type');",
                  "  }",
                  "});"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "Document Search",
      "item": [
        {
          "name": "Search by Name",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/v1/dgii/document:search?q=ERPly&field=name&limit=5",
              "host": ["{{base_url}}"],
              "path": ["v1", "dgii", "document:search"],
              "query": [
                { "key": "q", "value": "ERPly" },
                { "key": "field", "value": "name" },
                { "key": "limit", "value": "5" }
              ]
            },
            "description": "Búsqueda de contribuyentes por nombre.\n\nRef: https://api.erply.pro/docs/reference/identity/identity-document-search-ref"
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Status is 200', function () {",
                  "  pm.response.to.have.status(200);",
                  "});",
                  "pm.test('Response has items array', function () {",
                  "  const json = pm.response.json();",
                  "  pm.expect(json).to.have.property('items');",
                  "  pm.expect(json.items).to.be.an('array');",
                  "  pm.expect(json).to.have.property('count');",
                  "  pm.expect(json).to.have.property('partial');",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "Search by Trade Name",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/v1/dgii/document:search?q=ERPLY&field=trade_name",
              "host": ["{{base_url}}"],
              "path": ["v1", "dgii", "document:search"],
              "query": [
                { "key": "q", "value": "ERPLY" },
                { "key": "field", "value": "trade_name" }
              ]
            },
            "description": "Búsqueda por nombre comercial.\n\nRef: https://api.erply.pro/docs/reference/identity/identity-document-search-ref"
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Status is 200', function () {",
                  "  pm.response.to.have.status(200);",
                  "});",
                  "pm.test('Items array present', function () {",
                  "  pm.expect(pm.response.json().items).to.be.an('array');",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "Search by Economic Activity",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/v1/dgii/document:search?q=INFORMATICA&field=economic_activity",
              "host": ["{{base_url}}"],
              "path": ["v1", "dgii", "document:search"],
              "query": [
                { "key": "q", "value": "INFORMATICA" },
                { "key": "field", "value": "economic_activity" }
              ]
            },
            "description": "Búsqueda por actividad económica.\n\nRef: https://api.erply.pro/docs/reference/identity/identity-document-search-ref"
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Status is 200', function () {",
                  "  pm.response.to.have.status(200);",
                  "});",
                  "pm.test('Items array present', function () {",
                  "  pm.expect(pm.response.json().items).to.be.an('array');",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "Search Any Field",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/v1/dgii/document:search?q=ERPly&field=any",
              "host": ["{{base_url}}"],
              "path": ["v1", "dgii", "document:search"],
              "query": [
                { "key": "q", "value": "ERPly" },
                { "key": "field", "value": "any" }
              ]
            },
            "description": "Búsqueda en todos los campos indexados.\n\nRef: https://api.erply.pro/docs/reference/identity/identity-document-search-ref"
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Status is 200', function () {",
                  "  pm.response.to.have.status(200);",
                  "});",
                  "pm.test('Items array present', function () {",
                  "  pm.expect(pm.response.json().items).to.be.an('array');",
                  "});"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "Registry",
      "item": [
        {
          "name": "Registry Status",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/v1/dgii/registry/status",
              "host": ["{{base_url}}"],
              "path": ["v1", "dgii", "registry", "status"]
            },
            "description": "Estado y frescura del registro DGII local.\n\nRef: https://api.erply.pro/docs/reference/identity/identity-registry-status-ref"
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Status is 200', function () {",
                  "  pm.response.to.have.status(200);",
                  "});",
                  "pm.test('Has registry fields', function () {",
                  "  const json = pm.response.json();",
                  "  pm.expect(json).to.have.property('last_ingest');",
                  "  pm.expect(json).to.have.property('record_count');",
                  "  pm.expect(json).to.have.property('stale');",
                  "});"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "Habeas Data",
      "item": [
        {
          "name": "Purge (Habeas Data)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/v1/dgii/document/{{document}}:purge",
              "host": ["{{base_url}}"],
              "path": ["v1", "dgii", "document", "{{document}}:purge"]
            },
            "description": "Solicitud de eliminación de datos personales bajo Ley 172-13.\n\nEste endpoint requiere autenticación de nivel tenant (Bearer token)."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Status is 202 or 403', function () {",
                  "  pm.expect(pm.response.code).to.be.oneOf([202, 403]);",
                  "});"
                ]
              }
            }
          ]
        }
      ]
    }
  ]
}
