SIRE · Generar propuesta
Dispara la generación de la propuesta de un periodo y devuelve el número de ticket para consultar su avance.
Consideraciones
- Disponible desde el plan Plus.
- Esta operación no consume consultas de tu plan.
- Requiere el token de
/sire/login. - SUNAT genera la propuesta de forma asíncrona: devuelve un
numTicketque luego se consulta con/sire/ticket.
Pide a SUNAT que genere la propuesta del periodo para el libro indicado. Como
el proceso es asíncrono, no devuelve la propuesta en el momento sino un
número de ticket (numTicket). Con ese ticket consultas el avance en
/sire/ticket y, cuando termina, descargas el archivo con /sire/archivo.
Headers
| Name | Type | Description |
|---|---|---|
| Accept | String | application/json |
| Content-Type | string | application/json |
| Authorization | string | Bearer <token>. Genéralo desde tu panel, en Api Tokens. |
Body
| Name | Type | Description |
|---|---|---|
| token* | string | access_token obtenido en /sire/login. |
| libro* | string | Libro: ventas/rvie o compras/rce. |
| periodo* | string | Periodo tributario en formato AAAAMM. |
Ejemplo de solicitud
Copiar
# https://apiperu.dev también funciona (dominio legacy) anteponiendo /api a la ruta — ver Inicio
URL_BASE="https://api.apiperu.dev"
curl -X POST "$URL_BASE/sire/propuesta" \
-H "Accept: application/json" \
-H "Authorization: Bearer TU_TOKEN" \
-H "Content-Type: application/json" \
-d '{"token":"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...","libro":"ventas","periodo":"202610"}' Copiar
<?php
// https://apiperu.dev también funciona (dominio legacy) anteponiendo /api a la ruta — ver Inicio
$urlBase = 'https://api.apiperu.dev';
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $urlBase . '/sire/propuesta',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode([
'token' => 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...',
'libro' => 'ventas',
'periodo' => '202610',
]),
CURLOPT_HTTPHEADER => [
'Accept: application/json',
'Authorization: Bearer TU_TOKEN',
'Content-Type: application/json',
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response; Copiar
// https://apiperu.dev también funciona (dominio legacy) anteponiendo /api a la ruta — ver Inicio
const URL_BASE = 'https://api.apiperu.dev';
const response = await fetch(`${URL_BASE}/sire/propuesta`, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer TU_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({
token: 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...',
libro: 'ventas',
periodo: '202610',
}),
});
const data = await response.json();
console.log(data); Copiar
import requests
# https://apiperu.dev también funciona (dominio legacy) anteponiendo /api a la ruta — ver Inicio
URL_BASE = 'https://api.apiperu.dev'
response = requests.post(
f'{URL_BASE}/sire/propuesta',
headers={
'Accept': 'application/json',
'Authorization': 'Bearer TU_TOKEN',
'Content-Type': 'application/json',
},
json={
'token': 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...',
'libro': 'ventas',
'periodo': '202610',
},
)
print(response.json()) Respuesta
200 OK application/json
{
"success": true,
"code": "found",
"retryable": false,
"data": {
"numTicket": "1323074839800"
}
}
400 Solicitud inválida application/json
{
"success": false,
"code": "invalid_input",
"retryable": false,
"message": "Datos inválidos"
}
503 Servicio no disponible application/json
{
"success": false,
"code": "upstream_unavailable",
"retryable": true,
"message": "El servicio de SUNAT no está disponible en este momento. Intenta nuevamente en unos segundos."
}