{
  "info": {
    "name": "MagniFinance REST API - TaxId Validation",
    "description": "Checks whether a tax id is valid for a country (today only `PT`).\n\n1. Open the collection's **Variables** tab and fill in `email` and `token` (see https://developer.magnifinance.com/finance/getting-started/authentication/). Any subscription token works.\n2. Send the request. Change the `taxId` variable to try an invalid one: the answer is `InvalidTaxId` (4).\n\nDocs: https://developer.magnifinance.com/finance/tax-compliance/taxid-validation/rest/",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    { "key": "baseUrl", "value": "https://bo.magnifinance.com" },
    { "key": "email", "value": "", "description": "Your API user email" },
    { "key": "token", "value": "", "type": "secret", "description": "Your subscription token" },
    { "key": "countryCode", "value": "PT" },
    { "key": "taxId", "value": "599138645" }
  ],
  "event": [
    {
      "listen": "test",
      "script": {
        "type": "text/javascript",
        "exec": [
          "pm.test('HTTP 200', () => pm.response.to.have.status(200));",
          "if ((pm.response.headers.get('Content-Type') || '').includes('json')) {",
          "    const body = pm.response.json();",
          "    const error = body.ErrorValue ? `${body.ErrorValue.Name}: ${JSON.stringify(body.ValidationErrors || body.ErrorHumanReadable)}` : '';",
          "    pm.test('Tax id is valid (Type is Success)', () => pm.expect(body.IsError, error).to.be.false);",
          "}"
        ]
      }
    }
  ],
  "item": [
    {
      "name": "TaxId Validation",
      "request": {
        "method": "GET",
        "header": [
          { "key": "email", "value": "{{email}}" },
          { "key": "token", "value": "{{token}}" }
        ],
        "url": { "raw": "{{baseUrl}}/api/v1.1/taxIdValidation?countryCode={{countryCode}}&taxId={{taxId}}", "host": ["{{baseUrl}}"], "path": ["api", "v1.1", "taxIdValidation"], "query": [{ "key": "countryCode", "value": "{{countryCode}}" }, { "key": "taxId", "value": "{{taxId}}" }] },
        "description": "Docs: https://developer.magnifinance.com/finance/tax-compliance/taxid-validation/rest/"
      }
    }
  ]
}
