Descargar el XML firmado
Devuelve el XML UBL 2.1 firmado (Content-Type: application/xml), con el nombre oficial que exige SUNAT en la cabecera Content-Disposition: <RUC>-<tipo>-<serie>-<correlativo>.xml (p. ej. 20000000001-03-B001-1.xml).
Método: GET
Endpoint
Sección titulada «Endpoint»GET https://faktura-test.cgallardo.me/v1/documents/{id}/xmlGET https://faktura.cgallardo.me/v1/documents/{id}/xmlEjemplo
Sección titulada «Ejemplo»Guarda el archivo con el nombre que indica la API:
curl -OJ https://faktura-test.cgallardo.me/v1/documents/<id>/xml -H "Authorization: Bearer sk_test_..."use Illuminate\Support\Facades\Http;
$response = Http::withToken('sk_test_...') ->get('https://faktura-test.cgallardo.me/v1/documents/<id>/xml');
// Guarda el archivo con el nombre que indica la API (Content-Disposition).preg_match('/filename="?([^";]+)/', $response->header('Content-Disposition'), $match);file_put_contents($match[1], $response->body());import { writeFile } from 'node:fs/promises';
const response = await fetch('https://faktura-test.cgallardo.me/v1/documents/<id>/xml', { headers: { Authorization: 'Bearer sk_test_...', },});
// Guarda el archivo con el nombre que indica la API (Content-Disposition).const [, name] = /filename="?([^";]+)/.exec(response.headers.get('content-disposition'));await writeFile(name, Buffer.from(await response.arrayBuffer()));Respuestas y errores
Sección titulada «Respuestas y errores»| Estado | reason |
Significado |
|---|---|---|
200 |
— | Devuelve el XML UBL 2.1 firmado (application/xml). |
401 |
Unauthenticated |
Falta la API key, es inválida o venció. |
403 |
ApiKeyScopeInsufficient |
La clave es de alcance lookup. |
404 |
NotFound |
El comprobante no existe para tu clave o aún no tiene XML firmado. |
429 |
TooManyRequests |
Superaste las 120 peticiones por minuto. |