{
  "name": "GYRA+ | 1. Solicitar An\u00e1lise de Cr\u00e9dito",
  "nodes": [
    {
      "parameters": {
        "content": "## \ud83d\ude80 GYRA+ | Workflow 1: Solicitar An\u00e1lise de Cr\u00e9dito\n\n**O que este workflow faz:**\n1. Recebe uma chamada do seu ERP/CRM com o CNPJ ou CPF\n2. Autentica na API GYRA+\n3. Solicita a cria\u00e7\u00e3o do relat\u00f3rio\n4. Retorna o `reportId` para o sistema chamador\n\n**Como usar:**\n- Configure o n\u00f3 \u2699\ufe0f CONFIGURE AQUI com suas credenciais\n- Envie um POST para a URL do webhook com `{ \"document\": \"12345678000190\", \"type\": \"CNPJ\" }`\n- O workflow retorna `{ reportId, status, message }` imediatamente\n- Use o **Workflow 2 ou 3** para receber a decis\u00e3o quando pronta\n\n\ud83d\udccc **Dica:** Salve o `reportId` no seu sistema para correlacionar com o webhook de resposta.",
        "height": 488,
        "width": 576,
        "color": 5
      },
      "id": "e74dfdff-7142-4286-b811-da486c88fe5f",
      "name": "\ud83d\udccb Sobre este Workflow",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -704,
        208
      ]
    },
    {
      "parameters": {
        "content": "## \u2699\ufe0f Configure suas Credenciais GYRA+\n\nSubstitua os valores abaixo:\n- `clientId` \u2192 seu Client ID (painel GYRA+)\n- `clientSecret` \u2192 seu Client Secret (painel GYRA+)\n- `policyId` \u2192 ID da sua pol\u00edtica de cr\u00e9dito ativa\n- `reportType` \u2192 tipo padr\u00e3o: SIMPLES, ESSENCIAL, COMPLETO ou COMPLETO_PLUS\n\n\ud83d\udd11 Solicite suas credenciais para bizdev@gyramais.com",
        "height": 300,
        "width": 440,
        "color": 4
      },
      "id": "d5fea964-9b1e-4c8f-a509-e8e65c5d0ee3",
      "name": "\u2699\ufe0f Nota de Configura\u00e7\u00e3o",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        64,
        112
      ]
    },
    {
      "parameters": {
        "content": "## \ud83d\udd10 Autentica\u00e7\u00e3o\n\nA GYRA+ usa autentica\u00e7\u00e3o via headers:\n`gyra-client-id` + `gyra-client-secret`\n\nRetorna um `accessToken` JWT v\u00e1lido por **1 hora**.\n\n\ud83d\udca1 Em produ\u00e7\u00e3o, considere cachear o token e renovar apenas quando expirar.",
        "height": 260,
        "width": 348,
        "color": 7
      },
      "id": "3b6441a0-06c3-4f87-baeb-7d78f0c6a01a",
      "name": "\ud83d\udd10 Nota Autentica\u00e7\u00e3o",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        560,
        112
      ]
    },
    {
      "parameters": {
        "content": "## \ud83d\udcc4 Cria\u00e7\u00e3o do Relat\u00f3rio\n\nO campo `document` aceita CNPJ (14 d\u00edgitos) ou CPF (11 d\u00edgitos) sem formata\u00e7\u00e3o.\n\n**Tipos de relat\u00f3rio:**\n- `SIMPLES` \u2014 Score + PEFIN b\u00e1sico\n- `ESSENCIAL` \u2014 + REFIN, Protestos\n- `COMPLETO` \u2014 + Processos, PEP, San\u00e7\u00f5es\n- `COMPLETO_PLUS` \u2014 + Certid\u00f5es em tempo real\n\nO campo `externalId` \u00e9 opcional \u2014 use para correlacionar com seu sistema interno.",
        "height": 348,
        "width": 500,
        "color": 7
      },
      "id": "96eb871a-4c5c-46d6-af12-da46a008ab8f",
      "name": "\ud83d\udcc4 Nota Relat\u00f3rio",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1072,
        80
      ]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "gyra-solicitar-analise",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "3584f4ce-0222-4d93-9cbe-00a31273db0a",
      "name": "\ud83d\udce5 Receber Solicita\u00e7\u00e3o (ERP/CRM)",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -96,
        432
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "cfg-client-id",
              "name": "clientId",
              "value": "SEU_CLIENT_ID_AQUI",
              "type": "string"
            },
            {
              "id": "cfg-client-secret",
              "name": "clientSecret",
              "value": "SEU_CLIENT_SECRET_AQUI",
              "type": "string"
            },
            {
              "id": "cfg-policy-id",
              "name": "policyId",
              "value": "SEU_POLICY_ID_AQUI",
              "type": "string"
            },
            {
              "id": "cfg-report-type",
              "name": "reportType",
              "value": "COMPLETO",
              "type": "string"
            },
            {
              "id": "cfg-api-url",
              "name": "apiBaseUrl",
              "value": "https://gyra-core.gyramais.com.br",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "c66dbf76-91c9-4a70-8248-f090f189be99",
      "name": "\u2699\ufe0f CONFIGURE AQUI",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        224,
        432
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $('\u2699\ufe0f CONFIGURE AQUI').item.json.apiBaseUrl }}/auth/authenticate",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "gyra-client-id",
              "value": "={{ $('\u2699\ufe0f CONFIGURE AQUI').item.json.clientId }}"
            },
            {
              "name": "gyra-client-secret",
              "value": "={{ $('\u2699\ufe0f CONFIGURE AQUI').item.json.clientSecret }}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "options": {
          "timeout": 15000
        }
      },
      "id": "643673db-d0a1-4c42-b070-ef5f35a434b4",
      "name": "\ud83d\udd10 Autenticar na GYRA+",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        576,
        432
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $('\u2699\ufe0f CONFIGURE AQUI').item.json.apiBaseUrl }}/report",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('\ud83d\udd10 Autenticar na GYRA+').item.json.accessToken }}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"document\": \"{{ $('\ud83d\udce5 Receber Solicita\u00e7\u00e3o (ERP/CRM)').item.json.body.document }}\",\n  \"type\": \"{{ $('\ud83d\udce5 Receber Solicita\u00e7\u00e3o (ERP/CRM)').item.json.body.type || 'CNPJ' }}\",\n  \"reportType\": \"{{ $('\ud83d\udce5 Receber Solicita\u00e7\u00e3o (ERP/CRM)').item.json.body.reportType || $('\u2699\ufe0f CONFIGURE AQUI').item.json.reportType }}\",\n  \"policyId\": \"{{ $('\ud83d\udce5 Receber Solicita\u00e7\u00e3o (ERP/CRM)').item.json.body.policyId || $('\u2699\ufe0f CONFIGURE AQUI').item.json.policyId }}\",\n  \"externalId\": \"{{ $('\ud83d\udce5 Receber Solicita\u00e7\u00e3o (ERP/CRM)').item.json.body.externalId || '' }}\"\n}",
        "options": {
          "timeout": 15000
        }
      },
      "id": "e5195359-14fe-4263-bf25-f4a57870040d",
      "name": "\ud83d\udcc4 Criar Relat\u00f3rio GYRA+",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        800,
        432
      ],
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={\n  \"success\": true,\n  \"reportId\": \"{{ $('\ud83d\udcc4 Criar Relat\u00f3rio GYRA+').item.json.id }}\",\n  \"document\": \"{{ $('\ud83d\udce5 Receber Solicita\u00e7\u00e3o (ERP/CRM)').item.json.body.document }}\",\n  \"status\": \"PENDING\",\n  \"message\": \"An\u00e1lise de cr\u00e9dito solicitada com sucesso. Voc\u00ea receber\u00e1 a decis\u00e3o via webhook quando o relat\u00f3rio for processado.\",\n  \"estimatedTimeSeconds\": 90\n}",
        "options": {
          "responseCode": 202
        }
      },
      "id": "445ca20c-d019-4882-85e6-cf15aa856909",
      "name": "\u2705 Retornar reportId ao Chamador",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        1136,
        416
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={\n  \"success\": false,\n  \"error\": \"Falha ao processar a solicita\u00e7\u00e3o de an\u00e1lise\",\n  \"message\": \"{{ $json.message || 'Erro interno. Verifique suas credenciais e tente novamente.' }}\"\n}",
        "options": {
          "responseCode": 500
        }
      },
      "id": "afd6d6b0-3b00-4a21-9c0c-96735fff719c",
      "name": "\u274c Retornar Erro ao Chamador",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        1152,
        592
      ]
    },
    {
      "parameters": {
        "content": "## \u274c Tratamento de Erro\n\nSe a autentica\u00e7\u00e3o ou cria\u00e7\u00e3o do relat\u00f3rio falhar, o workflow responde com HTTP 500 e uma mensagem de erro.\n\nVerifique:\n- Credenciais corretas no n\u00f3 \u2699\ufe0f CONFIGURE AQUI\n- `policyId` existente e ativo\n- `document` com 11 (CPF) ou 14 (CNPJ) d\u00edgitos",
        "height": 308,
        "width": 320
      },
      "id": "b9880c68-05a8-4591-8c6b-2c97c1a3a021",
      "name": "\u274c Nota Erro",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1056,
        736
      ]
    }
  ],
  "connections": {
    "\ud83d\udce5 Receber Solicita\u00e7\u00e3o (ERP/CRM)": {
      "main": [
        [
          {
            "node": "\u2699\ufe0f CONFIGURE AQUI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u2699\ufe0f CONFIGURE AQUI": {
      "main": [
        [
          {
            "node": "\ud83d\udd10 Autenticar na GYRA+",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\ud83d\udd10 Autenticar na GYRA+": {
      "main": [
        [
          {
            "node": "\ud83d\udcc4 Criar Relat\u00f3rio GYRA+",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\ud83d\udcc4 Criar Relat\u00f3rio GYRA+": {
      "main": [
        [
          {
            "node": "\u2705 Retornar reportId ao Chamador",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "\u274c Retornar Erro ao Chamador",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false
  },
  "versionId": "f91984a3-e6da-4f96-b61c-750d9528500d",
  "id": "7zbyAcTSN6bHlxNo",
  "tags": [
    {
      "name": "GYRA+",
      "id": "4nExL8DDYTQeWziF",
      "updatedAt": "2026-03-01T18:30:06.922Z",
      "createdAt": "2026-03-01T18:30:06.922Z"
    },
    {
      "name": "Cr\u00e9dito",
      "id": "pEHOqPPHPfVf3CTJ",
      "updatedAt": "2026-03-01T18:30:07.161Z",
      "createdAt": "2026-03-01T18:30:07.161Z"
    }
  ]
}