> For the complete documentation index, see [llms.txt](https://docs.apisunat.pe/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apisunat.pe/integracion/facturacion-electronica/factura/factura-con-anexo.md).

# Factura con anexo

### Endpoint de pruebas

<mark style="color:green;">`POST`</mark> `https://sandbox.apisunat.pe/api/v3/documents`

### Token

Es obligatorio incluir el encabezado `Authorization` en cada solicitud.\
El **token es único por empresa** y puedes obtenerlo ingresando a [https://app.apisunat.pe](https://app.apisunat.pe/), en el módulo de **organizaciones**.

```powershell
header 'Authorization: Bearer {TOKEN}'
```

### Datos del comprobante

<pre class="language-json" data-full-width="false"><code class="lang-json">{
    "documento": "factura",
    "serie": "F001",
    "numero": 123,
    "fecha_de_emision": "2025-01-03",
    "hora_de_emision": "19:40:00", //Opcional
    "moneda": "PEN",
    "tipo_operacion": "0101",
<strong>    "emisor_codigo_de_anexo": "0001",
</strong><strong>    "emisor_direccion": "AV. POBLADO - LIMA",
</strong>    "cliente_tipo_de_documento": "6",
    "cliente_numero_de_documento": "20123456789",
    "cliente_denominacion": "EMPRESA DE SERVICIOS S.A.C",
    "cliente_direccion": "AV. SAN MARTIN - LIMA",
    "items": [
        {
            "unidad_de_medida": "NIU",
            "descripcion": "Nombre del producto",
            "cantidad": "2",
            "valor_unitario": "254.237288", //Se recomienda usar 6 decimales
            "porcentaje_igv": "18",
            "codigo_tipo_afectacion_igv": "10",
            "nombre_tributo": "IGV"
        }
    ],
    "total": "600.00"
}
</code></pre>

### Respuestas

{% tabs %}
{% tab title="200 OK" %}

<pre class="language-json" data-title="El comprobante está firmado y aceptado por SUNAT" data-full-width="false"><code class="lang-json">{
    "success": true,
    "message": "El comprobante fue enviado y aceptado por SUNAT.",
    "payload": {
<strong>        "estado": "ACEPTADO",
</strong>        "hash": "4HY34uR7a+Vc1Ax3/zrUk1Ng+tjTLwlqa9mRFysy15E=",
        "xml": "https://apisunat.pe/20123456789-01-B001-123.xml",
        "cdr": "https://apisunat.pe/R-20123456789-01-B001-123.xml",
        "pdf": {
            "ticket": "https://apisunat.pe/pdf/ticket/20123456789-03-B001-123",
            "a4": "https://apisunat.pe/pdf/a4/20123456789-03-B001-123"
        }
    }
}
</code></pre>

<pre class="language-json" data-title="El comprobante está firmado y pendiente de la aceptación de SUNAT"><code class="lang-json">{
    "success": true,
    "message": "El comprobante aún está siendo procesado por SUNAT, consulte su estado en unos minutos.",
    "payload": {
<strong>        "estado": "PENDIENTE",
</strong>        "hash": "4HY34uR7a+Vc1Ax3/zrUk1Ng+tjTLwlqa9mRFysy15E=",
        "xml": "https://apisunat.pe/20123456789-01-B001-123.xml",
        "cdr": null,
        "pdf": {
            "ticket": "https://apisunat.pe/pdf/ticket/20123456789-01-B001-123",
            "a4": "https://apisunat.pe/pdf/a4/20123456789-03-B001-123"
        }
    }
}
</code></pre>

<pre class="language-json" data-title="El comprobante fue rechazado por SUNAT debido a datos incorrectos" data-full-width="false"><code class="lang-json">{
    "success": true,
    "message": "El comprobante presenta errores o datos incorrectos",
    "payload": {
<strong>        "estado": "RECHAZADO",
</strong>        "hash": "4HY34uR7a+Vc1Ax3/zrUk1Ng+tjTLwlqa9mRFysy15E=",
        "xml": "https://apisunat.pe/20123456789-01-B001-123.xml",
        "cdr": "https://apisunat.pe/R-20123456789-01-B001-123.xml",
        "pdf": {
            "ticket": "https://apisunat.pe/pdf/ticket/20123456789-01-B001-123",
            "a4": "https://apisunat.pe/pdf/a4/20123456789-03-B001-123"
        }
    }
}
</code></pre>

{% endtab %}

{% tab title="422 Error en datos" %}

```json
{
    "success": false,
    "message": "El campo documento es requerido"
}
```

{% endtab %}

{% tab title="400 Error al procesar" %}
{% code title="Documento duplicado" overflow="wrap" %}

```json
{
    "success": false,
    "message": "ERROR: boleta B002-1 fue emitido anteriormente."
}
```

{% endcode %}
{% endtab %}

{% tab title="401 Error de permisos" %}

```json
{
    "success": false,
    "message": "Acceso no autorizado."
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apisunat.pe/integracion/facturacion-electronica/factura/factura-con-anexo.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
