Download Mexico document CFDI XML
curl --request POST \
--url https://api.prod.payana.cloud/public/api/v1/documents/{reference}/xml \
--header 'api-key: <api-key>'import requests
url = "https://api.prod.payana.cloud/public/api/v1/documents/{reference}/xml"
headers = {"api-key": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {'api-key': '<api-key>'}};
fetch('https://api.prod.payana.cloud/public/api/v1/documents/{reference}/xml', 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.prod.payana.cloud/public/api/v1/documents/{reference}/xml",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"api-key: <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"
"net/http"
"io"
)
func main() {
url := "https://api.prod.payana.cloud/public/api/v1/documents/{reference}/xml"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("api-key", "<api-key>")
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.prod.payana.cloud/public/api/v1/documents/{reference}/xml")
.header("api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.prod.payana.cloud/public/api/v1/documents/{reference}/xml")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body<string>Documentos
Download Document XML
Descargar el XML (CFDI) de un documento fiscal de México
POST
/
documents
/
{reference}
/
xml
Download Mexico document CFDI XML
curl --request POST \
--url https://api.prod.payana.cloud/public/api/v1/documents/{reference}/xml \
--header 'api-key: <api-key>'import requests
url = "https://api.prod.payana.cloud/public/api/v1/documents/{reference}/xml"
headers = {"api-key": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {'api-key': '<api-key>'}};
fetch('https://api.prod.payana.cloud/public/api/v1/documents/{reference}/xml', 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.prod.payana.cloud/public/api/v1/documents/{reference}/xml",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"api-key: <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"
"net/http"
"io"
)
func main() {
url := "https://api.prod.payana.cloud/public/api/v1/documents/{reference}/xml"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("api-key", "<api-key>")
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.prod.payana.cloud/public/api/v1/documents/{reference}/xml")
.header("api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.prod.payana.cloud/public/api/v1/documents/{reference}/xml")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body<string>Descarga el XML del CFDI de un documento sincronizado desde el SAT. La respuesta es el archivo binario (
Guardá la respuesta como archivo (flag
Para marcar el documento como recibido sin descargar el XML, usá
application/xml), no JSON.
Requisitos
- Compañía de México (la API key debe pertenecer a esa compañía).
- Documento con origen
fiscal_entity(creado por sincronización SAT, no manual ni CSV). {reference}: UUID interno de Payana. Obtenelo conGET /documentsoGET /documents/{reference}.
Comportamiento
- Si Payana ya tiene el XML almacenado, lo devuelve desde el cache.
- Si no, lo obtiene del SAT en el momento, lo guarda en Payana y lo devuelve en la misma respuesta.
- El nombre del archivo viene en
Content-Disposition(típicamente{fiscal_reference}.xml).
Ejemplo
curl -X POST "https://api.prod.payana.cloud/public/api/v1/documents/aaea7db4-647c-4d92-9f86-89e34a68e1aa/xml" \
-H "api-key: YOUR_API_KEY" \
-o factura.xml
-o en curl). No esperes un cuerpo JSON en 200.
Errores
| Código HTTP | Código de error | Cuándo |
|---|---|---|
404 | document_not_found | La referencia no existe o no pertenece a tu compañía. |
422 | document_not_mexico | La compañía de la API key no es México. |
422 | document_wrong_origin | El documento no proviene del SAT (fiscal_entity). |
422 | document_missing_satws_reference | El documento no tiene referencia Satws para obtener el CFDI. |
422 | mexico_document_xml_upload_failed | Falló almacenar el XML en Payana tras obtenerlo del SAT. |
422 | mexico_document_xml_fetch_failed | Falló leer el XML previamente cacheado. |
POST /documents/{reference}/acknowledge.Authorizations
API key provista por Payana.
Path Parameters
Referencia interna del documento en Payana (UUID, ej. aaea7db4-647c-4d92-9f86-89e34a68e1aa). Obtenela con GET /documents o GET /documents/{reference}.
Response
Archivo XML del CFDI
The response is of type file.