Descargar XML firmado
Descarga el XML UBL firmado del comprobante (application/xml).
Autenticación: token Bearer de empresa (cpe:sign).
Consideraciones
- La respuesta exitosa es el archivo XML, no un JSON.
- Sirve también para resúmenes (RC, RA, RR) y guías, no solo para facturas y boletas.
Headers
| Name | Type | Description |
|---|---|---|
| Accept | string | application/json |
| Content-Type | string | application/json |
| Authorization | string | Bearer <token>. Genéralo desde tu panel, en Tokens de API. |
Parámetros de URL
| Name | Type | Description |
|---|---|---|
| external_id* | string | Identificador del comprobante devuelto al emitir. |
Ejemplo de solicitud
Copiar
curl -X GET https://api.xmlperu.dev/v1/cpe/9c2f1b7e-0000-0000-0000-000000000000/xml \
-H "Authorization: Bearer $TOKEN_EMPRESA" \
-H "Accept: application/json"Copiar
<?php
$token_empresa = 'pega-aqui-tu-token';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.xmlperu.dev/v1/cpe/9c2f1b7e-0000-0000-0000-000000000000/xml');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $token_empresa,
'Accept: application/json',
]);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);Copiar
const TOKEN_EMPRESA = 'pega-aqui-tu-token';
const res = await fetch('https://api.xmlperu.dev/v1/cpe/9c2f1b7e-0000-0000-0000-000000000000/xml', {
method: 'GET',
headers: {
Authorization: `Bearer ${TOKEN_EMPRESA}`,
Accept: 'application/json',
},
});
const data = await res.json();Copiar
import requests
TOKEN_EMPRESA = "pega-aqui-tu-token"
headers = {
"Authorization": f"Bearer {TOKEN_EMPRESA}",
"Accept": "application/json",
}
res = requests.get("https://api.xmlperu.dev/v1/cpe/9c2f1b7e-0000-0000-0000-000000000000/xml", headers=headers)
data = res.json()Respuesta
404 No existeapplication/json
{
"success": false,
"message": "El comprobante no existe."
}