Gerar Arquivo
curl --request POST \
--url https://api.validanfe.com/GuardaNFe/GerarArquivo \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <x-api-key>' \
--data '
{
"ChavesNFe": [
{}
]
}
'import requests
url = "https://api.validanfe.com/GuardaNFe/GerarArquivo"
payload = { "ChavesNFe": [{}] }
headers = {
"X-API-KEY": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-KEY': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({ChavesNFe: [{}]})
};
fetch('https://api.validanfe.com/GuardaNFe/GerarArquivo', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.validanfe.com/GuardaNFe/GerarArquivo",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'ChavesNFe' => [
[
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <x-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.validanfe.com/GuardaNFe/GerarArquivo"
payload := strings.NewReader("{\n \"ChavesNFe\": [\n {}\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-KEY", "<x-api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.validanfe.com/GuardaNFe/GerarArquivo")
.header("X-API-KEY", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"ChavesNFe\": [\n {}\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.validanfe.com/GuardaNFe/GerarArquivo")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"ChavesNFe\": [\n {}\n ]\n}"
response = http.request(request)
puts response.read_body{
"200": {},
"400": {},
"401": {},
"500": {}
}API Guarda
Gerar Arquivo
Gere arquivo ZIP contendo XMLs das NFe armazenadas
POST
/
GuardaNFe
/
GerarArquivo
Gerar Arquivo
curl --request POST \
--url https://api.validanfe.com/GuardaNFe/GerarArquivo \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <x-api-key>' \
--data '
{
"ChavesNFe": [
{}
]
}
'import requests
url = "https://api.validanfe.com/GuardaNFe/GerarArquivo"
payload = { "ChavesNFe": [{}] }
headers = {
"X-API-KEY": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-KEY': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({ChavesNFe: [{}]})
};
fetch('https://api.validanfe.com/GuardaNFe/GerarArquivo', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.validanfe.com/GuardaNFe/GerarArquivo",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'ChavesNFe' => [
[
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <x-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.validanfe.com/GuardaNFe/GerarArquivo"
payload := strings.NewReader("{\n \"ChavesNFe\": [\n {}\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-KEY", "<x-api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.validanfe.com/GuardaNFe/GerarArquivo")
.header("X-API-KEY", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"ChavesNFe\": [\n {}\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.validanfe.com/GuardaNFe/GerarArquivo")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"ChavesNFe\": [\n {}\n ]\n}"
response = http.request(request)
puts response.read_body{
"200": {},
"400": {},
"401": {},
"500": {}
}Objetivo
Este endpoint permite a geração de um arquivo .zip contendo os arquivos XML das NF-e correspondentes às chaves de acesso informadas. Você pode enviar uma ou múltiplas chaves na mesma requisição.Para Operações em Larga EscalaEste endpoint é indicado para consultas pontuais ou pequenos volumes. Para recuperação de todo seu acervo fiscal, entre em contato com nosso suporte.
Endpoint
Headers
string
default:"application/json"
Tipo de conteúdo da requisição
string
required
Token de autenticação da API
Body Parameters
array
required
Lista de chaves de acesso das NF-e para incluir no arquivo ZIPExemplo:
["35170608530528000184550000000154301000771561"]Exemplos de Requisição
curl -X POST "https://api.validanfe.com/GuardaNFe/GerarArquivo" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "X-API-KEY: SEU_TOKEN_AQUI" \
-d '{
"ChavesNFe": [
"35170608530528000184550000000154301000771561",
"22210841816302000110550000000000012824578529"
]
}'
const response = await fetch('https://api.validanfe.com/GuardaNFe/GerarArquivo', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'X-API-KEY': 'SEU_TOKEN_AQUI'
},
body: JSON.stringify({
ChavesNFe: [
"35170608530528000184550000000154301000771561",
"22210841816302000110550000000000012824578529"
]
})
});
const resultado = await response.json();
console.log('URL de Download:', resultado.downloadUrl);
import requests
import json
url = "https://api.validanfe.com/GuardaNFe/GerarArquivo"
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"X-API-KEY": "SEU_TOKEN_AQUI"
}
data = {
"ChavesNFe": [
"35170608530528000184550000000154301000771561",
"22210841816302000110550000000000012824578529"
]
}
response = requests.post(url, headers=headers, data=json.dumps(data))
resultado = response.json()
print(f"URL de Download: {resultado['downloadUrl']}")
<?php
$ch = curl_init();
$data = [
"ChavesNFe" => [
"35170608530528000184550000000154301000771561",
"22210841816302000110550000000000012824578529"
]
];
curl_setopt($ch, CURLOPT_URL, 'https://api.validanfe.com/GuardaNFe/GerarArquivo');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Accept: application/json',
'X-API-KEY: SEU_TOKEN_AQUI'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
$resultado = json_decode($response, true);
curl_close($ch);
echo "URL de Download: " . $resultado['downloadUrl'];
?>
Códigos de Resposta
Success
ZIP gerado com sucesso, retorna URL para download
Bad Request
Nenhuma chave NFe foi fornecida
Unauthorized
Token de autenticação ausente ou inválido
Internal Server Error
Erro ao processar a requisição ou gerar o ZIP
Exemplos de Resposta
{
"downloadUrl": "https://api.validanfe.com/GuardaNFe/Download/NFe_123456_abcdef123456.zip"
}
{
"error": "Nenhuma chave NFe foi fornecida."
}
{
"error": "Erro ao gerar o ZIP."
}
Como Baixar o Arquivo
Após receber a resposta com sucesso, use adownloadUrl retornada para fazer o download:
curl -L -H "X-API-KEY: SEU_TOKEN_AQUI" \
"https://api.validanfe.com/GuardaNFe/Download/NFe_123456_abcdef123456.zip" \
--output nfe-arquivos.zip
const downloadResponse = await fetch(resultado.downloadUrl, {
headers: {
'X-API-KEY': 'SEU_TOKEN_AQUI'
}
});
const blob = await downloadResponse.blob();
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'nfe-arquivos.zip';
document.body.appendChild(a);
a.click();
a.remove();
import requests
download_response = requests.get(
resultado['downloadUrl'],
headers={'X-API-KEY': 'SEU_TOKEN_AQUI'}
)
with open('nfe-arquivos.zip', 'wb') as f:
f.write(download_response.content)
Estrutura do Arquivo ZIP
O arquivo ZIP gerado contém:Organização
NFe_123456_abcdef123456.zip
├── 35170608...71561.xml
├── 22210841...78529.xml
└── ...
Formato dos Arquivos
- Nome: Chave da NFe +
.xml - Conteúdo: XML completo da NFe
- Encoding: UTF-8
Limitações e Considerações
Limites de Volume
Limites de Volume
- Máximo: 100 chaves por requisição
- Tamanho: Arquivos ZIP podem ter até 50MB
- Timeout: Requisições com timeout de 60 segundos
Validade do Link
Validade do Link
- Links de download são temporários
- Válidos por 24 horas após geração
- Após expirar, gere um novo arquivo
Performance
Performance
- Tempo de geração varia com a quantidade de NFe
- Processo assíncrono para grandes volumes
- Arquivos ficam em cache por 1 hora
Dica de UsoPara volumes maiores que 100 NFe, divida em múltiplas requisições ou entre em contato com o suporte para uma solução personalizada.
Verificação PréviaUse o endpoint Verificar NFe antes de gerar arquivos para confirmar quais NFe estão disponíveis.