Skip to main content
POST
/
api
/
v1
/
invoices
Create Invoice
curl --request POST \
  --url https://api.example.com/api/v1/invoices \
  --header 'Content-Type: application/json' \
  --data '
{
  "company_id": 123,
  "branch_id": 123,
  "serie": "<string>",
  "fecha_emision": "<string>",
  "fecha_vencimiento": "<string>",
  "moneda": "<string>",
  "tipo_operacion": "<string>",
  "forma_pago_tipo": "<string>",
  "forma_pago_cuotas": [
    {
      "forma_pago_cuotas[].moneda": "<string>",
      "forma_pago_cuotas[].monto": 123,
      "forma_pago_cuotas[].fecha_pago": "<string>"
    }
  ],
  "client": {
    "client.tipo_documento": "<string>",
    "client.numero_documento": "<string>",
    "client.razon_social": "<string>",
    "client.nombre_comercial": "<string>",
    "client.direccion": "<string>",
    "client.ubigeo": "<string>",
    "client.distrito": "<string>",
    "client.provincia": "<string>",
    "client.departamento": "<string>",
    "client.telefono": "<string>",
    "client.email": {}
  },
  "detalles": [
    {
      "detalles[].codigo": "<string>",
      "detalles[].descripcion": "<string>",
      "detalles[].unidad": "<string>",
      "detalles[].cantidad": 123,
      "detalles[].mto_valor_unitario": 123,
      "detalles[].porcentaje_igv": 123,
      "detalles[].porcentaje_ivap": 123,
      "detalles[].mto_valor_gratuito": 123,
      "detalles[].tip_afe_igv": "<string>",
      "detalles[].codigo_producto_sunat": "<string>"
    }
  ],
  "detraccion": {
    "detraccion.codigo_bien_servicio": "<string>",
    "detraccion.codigo_medio_pago": "<string>",
    "detraccion.cuenta_banco": "<string>",
    "detraccion.porcentaje": 123,
    "detraccion.monto": 123
  },
  "percepcion": {
    "percepcion.cod_regimen": "<string>",
    "percepcion.tasa": 123,
    "percepcion.monto": 123,
    "percepcion.monto_base": 123,
    "percepcion.monto_total": 123
  },
  "retencion": {
    "retencion.cod_regimen": "<string>",
    "retencion.tasa": 123,
    "retencion.monto": 123,
    "retencion.monto_base": 123,
    "retencion.monto_total": 123
  },
  "guias": [
    {}
  ],
  "documentos_relacionados": [
    {}
  ],
  "datos_adicionales": [
    {}
  ],
  "usuario_creacion": "<string>"
}
'
{
  "success": true,
  "data": {
    "id": 123,
    "company_id": 123,
    "branch_id": 123,
    "serie": "<string>",
    "numero": 123,
    "numero_completo": "<string>",
    "fecha_emision": "<string>",
    "estado_sunat": "<string>",
    "company": {},
    "branch": {},
    "client": {}
  },
  "message": "<string>"
}
Creates a new electronic invoice (Factura) for SUNAT. The invoice is created in draft status and must be sent to SUNAT separately.
Facturas are issued to business customers (RUC) and support advanced features like credit terms, detraction, perception, and retention.

Authentication

This endpoint requires authentication using a Bearer token (Sanctum).
Authorization: Bearer YOUR_API_TOKEN

Request Body

Company and Branch

company_id
integer
required
ID of the company issuing the invoice. Must exist in the companies table.
branch_id
integer
required
ID of the branch issuing the invoice. Must belong to the specified company.
serie
string
required
Invoice series code (max 4 characters). Must start with ‘F’ for facturas (e.g., “F001”).

Dates and Currency

fecha_emision
date
required
Invoice issue date in YYYY-MM-DD format.
fecha_vencimiento
date
Due date for the invoice. Must be equal to or after the issue date. Required for credit invoices.
moneda
string
required
Currency code. Allowed values: PEN (Peruvian Sol), USD (US Dollar).
tipo_operacion
string
Type of operation code (max 4 characters).
  • 0101: Internal sale (default)
  • 0200: Export
  • 0112: Sale with IVAP
  • Other SUNAT catalog 51 codes

Payment Terms

forma_pago_tipo
string
required
Payment type. Allowed values: Contado (cash), Credito (credit).
forma_pago_cuotas
array
Payment installments. Required when forma_pago_tipo is Credito.

Client Information

client
object
required
Customer information.

Invoice Items

detalles
array
required
Invoice line items (minimum 1 item required).

Detraction (Optional)

detraccion
object
Detraction information for applicable services/goods.

Perception (Optional)

percepcion
object
Perception information for applicable transactions.

Retention (Optional)

retencion
object
Retention information for applicable transactions.

Additional Data (Optional)

guias
array
Related shipping guides.
documentos_relacionados
array
Related documents.
datos_adicionales
array
Additional custom data.
usuario_creacion
string
Username of the creator (max 100 characters).

Response

success
boolean
Indicates if the invoice was created successfully.
data
object
The created invoice object with relationships.
message
string
Success message.

Request Example

curl -X POST https://api.example.com/api/v1/invoices \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "company_id": 1,
    "branch_id": 1,
    "serie": "F001",
    "fecha_emision": "2024-03-15",
    "fecha_vencimiento": "2024-04-15",
    "moneda": "PEN",
    "tipo_operacion": "0101",
    "forma_pago_tipo": "Credito",
    "forma_pago_cuotas": [
      {
        "moneda": "PEN",
        "monto": 590.00,
        "fecha_pago": "2024-04-15"
      }
    ],
    "client": {
      "tipo_documento": "6",
      "numero_documento": "20123456789",
      "razon_social": "EMPRESA DEMO SAC",
      "direccion": "AV. PRINCIPAL 123",
      "ubigeo": "150101",
      "distrito": "LIMA",
      "provincia": "LIMA",
      "departamento": "LIMA",
      "telefono": "01-1234567",
      "email": "[email protected]"
    },
    "detalles": [
      {
        "codigo": "PROD001",
        "descripcion": "SERVICIO DE CONSULTORIA",
        "unidad": "ZZ",
        "cantidad": 1,
        "mto_valor_unitario": 500.00,
        "porcentaje_igv": 18,
        "tip_afe_igv": "10"
      }
    ],
    "usuario_creacion": "admin"
  }'

Response Example

{
  "success": true,
  "data": {
    "id": 123,
    "company_id": 1,
    "branch_id": 1,
    "serie": "F001",
    "numero": 456,
    "numero_completo": "F001-456",
    "fecha_emision": "2024-03-15",
    "fecha_vencimiento": "2024-04-15",
    "moneda": "PEN",
    "tipo_operacion": "0101",
    "estado_sunat": "PENDIENTE",
    "mto_oper_gravadas": 500.00,
    "mto_igv": 90.00,
    "mto_imp_venta": 590.00,
    "forma_pago_tipo": "Credito",
    "created_at": "2024-03-15T10:30:00.000000Z",
    "updated_at": "2024-03-15T10:30:00.000000Z",
    "company": {
      "id": 1,
      "ruc": "20987654321",
      "razon_social": "MI EMPRESA SAC"
    },
    "branch": {
      "id": 1,
      "nombre": "Sede Principal",
      "codigo": "0000"
    },
    "client": {
      "id": 45,
      "tipo_documento": "6",
      "numero_documento": "20123456789",
      "razon_social": "EMPRESA DEMO SAC"
    }
  },
  "message": "Factura creada correctamente"
}
The invoice is created in PENDIENTE (pending) status. You must call the Send to SUNAT endpoint to submit it for validation.

Tax Calculation

The API automatically calculates taxes based on the item details:
  • Base IGV: Calculated from mto_valor_unitario × cantidad for taxable items
  • IGV Amount: Base × (porcentaje_igv / 100)
  • Unit Price: (Value + IGV) / quantity
  • Export Operations (tipo_operacion: 0200): IGV is set to 0, and tip_afe_igv is set to 40

Build docs developers (and LLMs) love