{
  "name": "My workflow",
  "nodes": [
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -288,
        -16
      ],
      "id": "e359392e-41a0-45a3-859e-7a988523d84c",
      "name": "When clicking ‘Execute workflow’"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "eb204da7-8b5e-448f-ad10-698ec6b4adb6",
              "name": "access_token",
              "value": "TU_ACCESS_TOKEN",
              "type": "string"
            },
            {
              "id": "34ff67d0-ffa9-4ed8-b8ea-1b7f244dc65f",
              "name": "afip-cert",
              "value": "CONTENIDO_DE_CERT",
              "type": "string"
            },
            {
              "id": "37adf472-3264-410f-bbce-6e11d1c00d5d",
              "name": "afip-key",
              "value": "CONTENIDO_DE_KEY",
              "type": "string"
            },
            {
              "id": "3efca71e-e261-4a8a-84d3-bdf8fb0d4172",
              "name": "cuit",
              "value": "TU_CUIT",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -80,
        -16
      ],
      "id": "9db32219-bb5c-410d-b76d-894305a82bfd",
      "name": "Variables"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://app.afipsdk.com/api/v1/afip/auth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('Variables').item.json.access_token }}"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "environment",
              "value": "dev"
            },
            {
              "name": "tax_id",
              "value": "={{ $('Variables').item.json.cuit }}"
            },
            {
              "name": "wsid",
              "value": "wsfe"
            },
            {
              "name": "cert",
              "value": "={{ $('Variables').item.json['afip-cert'] }}"
            },
            {
              "name": "key",
              "value": "={{ $('Variables').item.json['afip-key'] }}"
            }
          ]
        },
        "options": {
          "redirect": {
            "redirect": {}
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        128,
        -16
      ],
      "id": "e2e75f61-6a38-48f3-8210-bb9bae831f1e",
      "name": "Auth"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://app.afipsdk.com/api/v1/afip/requests",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('Variables').item.json.access_token }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n\t\"environment\": \"dev\",\n\t\"method\": \"FECompUltimoAutorizado\",\n\t\"wsid\": \"wsfe\",\n\t\"params\": {\n\t\t\"PtoVta\": 1,\n\t\t\"CbteTipo\": 6,\n\t\t\"Auth\": {\n\t\t\t\"Token\": \"{{$('Auth').item.json.token}}\",\n\t\t\t\"Sign\": \"{{$('Auth').item.json.sign}}\",\n\t\t\t\"Cuit\": \"{{$('Variables').item.json.cuit}}\"\n\t\t}\n\t}\n}\n",
        "options": {
          "redirect": {
            "redirect": {}
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        336,
        -16
      ],
      "id": "17c713ac-ffe5-439c-b01a-20f72a2484fb",
      "name": "HTTP Request"
    },
    {
      "parameters": {
        "operation": "toJson",
        "binaryPropertyName": "result.json",
        "options": {
          "fileName": "result.json"
        }
      },
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [
        544,
        -16
      ],
      "id": "19ef8b86-d220-402d-b874-c9cf50878714",
      "name": "Convert to File"
    }
  ],
  "pinData": {},
  "connections": {
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Variables": {
      "main": [
        [
          {
            "node": "Auth",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Auth": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Convert to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false
  },
  "versionId": "7c6038dd-b40f-4d92-abf2-db5339c39b46",
  "meta": {
    "instanceId": "85ad0911268094f10170f34ee319ffae210b802c1dd824f75f7502a33a707fec"
  },
  "id": "EzXLRmb8WqoyS4cf",
  "tags": []
}