Postman
Postman
  • Documentación

    • Información general
    • Entornos
    • Primeros pasos
    • Listar CFDI's
    • Buscar CFDI
    • Crear CFDI 4.0
    • Crear CFDI Global 4.0
    • Borradores CFDI 4.0
    • Descargar CFDI
    • Cancelar CFDI 4.0
    • Descargar acuse CFDI 4.0
    • Enviar CFDI
    • Consultar estatus de cancelación de un CFDI
    • Grupos de empleados
    • Empleados
    • Nóminas
    • Complementos
    • Retenciones
    • Complementos de retenciones
    • Carta porte v3.1
    • Catálogos
    • Clientes
    • Empresas
    • Migraciones
    • Series
    • Productos
    • Addendas
    • Fundamentos legales del SAT

Descargar CFDI

A continuación se explica como descargar un CFDI 4.0

Cada CFDI puede ser descargado a través de nuestra API en dos tipos de archivo distintos:

  • PDF
  • XML

Para obtener uno u otro solo es necesario cambiar el endpoint al que estamos apuntando:

  • /pdf
  • /xml

Tambien para descargar un CFDI es necesario el uso del siguiente parámetro el cual se utiliza en la construcción del enpoint para identificar el CFDI que deseamos descargar:

ParámetroTipoRequeridoDetalles
cfdi_uidStringRequerido Indica el UID o UUID del CFDI que deseas descargar.
Ejemplo:
55c0fdc67593d

Construcción de la URL

Host: https://facturaonline.com.mx/api (producción) / https://sandbox.facturaonline.com.mx/api (sandbox)

  • Endpoint PDF: /v4/cfdi40/{cfdi_uid}/pdf
  • Endpoint XML: /v4/cfdi40/{cfdi_uid}/xml

Ejemplo: https://facturaonline.com.mx/api/v4/cfdi40/55c0fdc67593d/pdf

Tip

Para probar el código de ejemplo es necesario que reemplaces el texto Tu API key por el API KEY de tu cuenta e Tu Secret key por el SECRET KEY correspondiente.

Además de reemplazar cfdi_uid por el UID del CFDI que deseas descargar.

Ejemplo para descargar CFDI en formato PDF

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => '{ HOST }/v4/cfdi40/61d4c3fe77dd8/pdf',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'F-PLUGIN: 9d4095c8f7ed5785cb14c0e3b033eeb8252416ed',
    'F-Api-Key: Tu API key',
    'F-Secret-Key: Tu Secret key'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var request = require('request');
var options = {
  'method': 'GET',
  'url': '{ HOST }/v4/cfdi40/61d4c3fe77dd8/pdf',
  'headers': {
    'Content-Type': 'application/json',
    'F-PLUGIN': '9d4095c8f7ed5785cb14c0e3b033eeb8252416ed',
    'F-Api-Key': 'Tu API key',
    'F-Secret-Key': 'Tu Secret key'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

import requests
import json

url = "{ HOST }/v4/cfdi40/61d4c3fe77dd8/pdf"

payload = ""
headers = {
  'Content-Type': 'application/json',
  'F-PLUGIN': '9d4095c8f7ed5785cb14c0e3b033eeb8252416ed',
  'F-Api-Key': 'Tu API key',
  'F-Secret-Key': 'Tu Secret key'
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)

require "uri"
require "json"
require "net/http"

url = URI("{ HOST }/v4/cfdi40/61d4c3fe77dd8/pdf")

http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["F-PLUGIN"] = "9d4095c8f7ed5785cb14c0e3b033eeb8252416ed"
request["F-Api-Key"] = "Tu API key"
request["F-Secret-Key"] = "Tu Secret key"

response = http.request(request)
puts response.read_body

Ejemplo para descargar CFDI en formato XML

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => '{ HOST }/v4/cfdi40/61d4c3fe77dd8/xml',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'F-PLUGIN: 9d4095c8f7ed5785cb14c0e3b033eeb8252416ed',
    'F-Api-Key: Tu API key',
    'F-Secret-Key: Tu Secret key'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var request = require('request');
var options = {
  'method': 'GET',
  'url': '{ HOST }/v4/cfdi40/61d4c3fe77dd8/xml',
  'headers': {
    'Content-Type': 'application/json',
    'F-PLUGIN': '9d4095c8f7ed5785cb14c0e3b033eeb8252416ed',
    'F-Api-Key': 'Tu API key',
    'F-Secret-Key': 'Tu Secret key'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

import requests
import json

url = "{ HOST }/v4/cfdi40/61d4c3fe77dd8/xml"

payload = ""
headers = {
  'Content-Type': 'application/json',
  'F-PLUGIN': '9d4095c8f7ed5785cb14c0e3b033eeb8252416ed',
  'F-Api-Key': 'Tu API key',
  'F-Secret-Key': 'Tu Secret key'
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)

require "uri"
require "json"
require "net/http"

url = URI("{ HOST }/v4/cfdi40/61d4c3fe77dd8/xml")

http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["F-PLUGIN"] = "9d4095c8f7ed5785cb14c0e3b033eeb8252416ed"
request["F-Api-Key"] = "Tu API key"
request["F-Secret-Key"] = "Tu Secret key"

response = http.request(request)
puts response.read_body

Last Updated:
Prev
Borradores CFDI 4.0
Next
Cancelar CFDI 4.0