Skip to main content
GET
/
api
/
v1
/
branches
/
{branch}
/
correlatives
Correlatives Management
curl --request GET \
  --url https://api.example.com/api/v1/branches/{branch}/correlatives \
  --header 'Content-Type: application/json' \
  --data '
{
  "tipo_documento": "<string>",
  "serie": "<string>",
  "correlativo_inicial": 123,
  "correlativo_actual": 123,
  "correlativos": [
    {
      "tipo_documento": "<string>",
      "serie": "<string>",
      "correlativo_inicial": 123
    }
  ]
}
'
{
  "success": true,
  "data": {
    "branch": {
      "id": 123,
      "codigo": "<string>",
      "nombre": "<string>",
      "company_id": 123
    },
    "correlatives": [
      {
        "id": 123,
        "branch_id": 123,
        "tipo_documento": "<string>",
        "tipo_documento_nombre": "<string>",
        "serie": "<string>",
        "correlativo_actual": 123,
        "numero_completo": "<string>",
        "proximo_numero": "<string>",
        "created_at": {},
        "updated_at": {}
      }
    ]
  },
  "meta": {
    "total": 123,
    "tipos_disponibles": {}
  }
}

Overview

Correlatives are sequential document numbering systems required by SUNAT for electronic invoicing in Peru. Each document type (Invoice, Boleta, Credit Note, etc.) requires its own series and correlative counter per branch.

What are Correlatives?

In Peruvian electronic invoicing, every document must have a unique identifier composed of:
  • Serie: A 4-character alphanumeric code (e.g., “F001”, “B001”)
  • Correlativo: A sequential number (e.g., 000001, 000002)
  • Complete Number: Combination in format {serie}-{correlativo} (e.g., “F001-000001”)
Each branch location manages its own set of correlatives, and they must be unique per document type and series combination.
Correlatives are automatically incremented when creating new documents. You can manually set the starting number when creating a new correlative.

List Correlatives

Retrieves all correlatives configured for a specific branch.

Path Parameters

branch
integer
required
The branch ID to retrieve correlatives for

Response

success
boolean
Indicates if the request was successful
data
object
branch
object
Information about the branch
id
integer
Branch ID
codigo
string
Branch code (e.g., “0000”)
nombre
string
Branch name
company_id
integer
Company ID this branch belongs to
correlatives
array
List of correlatives for the branch
id
integer
Correlative ID
branch_id
integer
Branch ID
tipo_documento
string
Document type code (01, 03, 07, 08, etc.)
tipo_documento_nombre
string
Document type name in Spanish
serie
string
Series code (4 characters max)
correlativo_actual
integer
Current correlative number
numero_completo
string
Full document number (serie-correlativo)
proximo_numero
string
Next available document number
created_at
timestamp
Creation timestamp
updated_at
timestamp
Last update timestamp
meta
object
total
integer
Total number of correlatives
tipos_disponibles
object
Available document types with codes and names

Example Request

curl -X GET "https://api.example.com/api/v1/branches/1/correlatives" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Accept: application/json"

Example Response

{
  "success": true,
  "data": {
    "branch": {
      "id": 1,
      "codigo": "0000",
      "nombre": "Sucursal Principal",
      "company_id": 1
    },
    "correlatives": [
      {
        "id": 1,
        "branch_id": 1,
        "tipo_documento": "01",
        "tipo_documento_nombre": "Factura",
        "serie": "F001",
        "correlativo_actual": 125,
        "numero_completo": "F001-000125",
        "proximo_numero": "F001-000126",
        "created_at": "2024-01-15T10:30:00Z",
        "updated_at": "2024-03-05T14:22:00Z"
      },
      {
        "id": 2,
        "branch_id": 1,
        "tipo_documento": "03",
        "tipo_documento_nombre": "Boleta de Venta",
        "serie": "B001",
        "correlativo_actual": 458,
        "numero_completo": "B001-000458",
        "proximo_numero": "B001-000459",
        "created_at": "2024-01-15T10:30:00Z",
        "updated_at": "2024-03-05T15:10:00Z"
      }
    ]
  },
  "meta": {
    "total": 2,
    "tipos_disponibles": {
      "01": "Factura",
      "03": "Boleta de Venta",
      "07": "Nota de Crédito",
      "08": "Nota de Débito",
      "09": "Guía de Remisión",
      "20": "Comprobante de Retención",
      "RC": "Resumen de Anulaciones",
      "RA": "Resumen Diario"
    }
  }
}

Create Correlative

Creates a new correlative for a specific branch.

Path Parameters

branch
integer
required
The branch ID to create the correlative for

Request Body

tipo_documento
string
required
Document type code. Valid values: 01, 03, 07, 08, 09, 20, RC, RA
serie
string
required
Series code (max 4 alphanumeric characters, uppercase). Example: “F001”, “B002”
correlativo_inicial
integer
default:"0"
Starting correlative number (0-99999999). Defaults to 0 if not provided
The combination of branch_id, tipo_documento, and serie must be unique. You cannot create duplicate correlatives.

Document Type Codes

  • 01: Factura (Invoice)
  • 03: Boleta de Venta (Sales Receipt)
  • 07: Nota de Crédito (Credit Note)
  • 08: Nota de Débito (Debit Note)
  • 09: Guía de Remisión (Delivery Guide)
  • 20: Comprobante de Retención (Retention Voucher)
  • RC: Resumen de Anulaciones (Voided Summary)
  • RA: Resumen Diario (Daily Summary)

Example Request

curl -X POST "https://api.example.com/api/v1/branches/1/correlatives" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "tipo_documento": "01",
    "serie": "F001",
    "correlativo_inicial": 0
  }'

Example Response

{
  "success": true,
  "message": "Correlativo creado exitosamente",
  "data": {
    "id": 3,
    "branch_id": 1,
    "tipo_documento": "01",
    "tipo_documento_nombre": "Factura",
    "serie": "F001",
    "correlativo_actual": 0,
    "numero_completo": "F001-000000",
    "proximo_numero": "F001-000001"
  }
}

Update Correlative

Updates an existing correlative configuration.

Path Parameters

branch
integer
required
The branch ID
correlative
integer
required
The correlative ID to update

Request Body

tipo_documento
string
required
Document type code
serie
string
required
Series code (max 4 alphanumeric characters)
correlativo_actual
integer
required
Current correlative number (0-99999999)
Changing the correlativo_actual value should be done carefully as it affects document numbering. Make sure the new value doesn’t conflict with existing documents.

Example Request

curl -X PUT "https://api.example.com/api/v1/branches/1/correlatives/3" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "tipo_documento": "01",
    "serie": "F001",
    "correlativo_actual": 100
  }'

Example Response

{
  "success": true,
  "message": "Correlativo actualizado exitosamente",
  "data": {
    "id": 3,
    "branch_id": 1,
    "tipo_documento": "01",
    "tipo_documento_nombre": "Factura",
    "serie": "F001",
    "correlativo_actual": 100,
    "numero_completo": "F001-000100",
    "proximo_numero": "F001-000101"
  }
}

Delete Correlative

Deletes a correlative from a branch.

Path Parameters

branch
integer
required
The branch ID
correlative
integer
required
The correlative ID to delete
Use with caution. Deleting a correlative that has been used for existing documents may cause issues with document references.

Example Request

curl -X DELETE "https://api.example.com/api/v1/branches/1/correlatives/3" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Accept: application/json"

Example Response

{
  "success": true,
  "message": "Correlativo eliminado exitosamente"
}

Batch Create Correlatives

Creates multiple correlatives at once for a branch.

Path Parameters

branch
integer
required
The branch ID

Request Body

correlativos
array
required
Array of correlative objects to create
tipo_documento
string
required
Document type code
serie
string
required
Series code
correlativo_inicial
integer
default:"0"
Starting correlative number

Example Request

curl -X POST "https://api.example.com/api/v1/branches/1/correlatives/batch" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "correlativos": [
      {
        "tipo_documento": "01",
        "serie": "F001",
        "correlativo_inicial": 0
      },
      {
        "tipo_documento": "03",
        "serie": "B001",
        "correlativo_inicial": 0
      },
      {
        "tipo_documento": "07",
        "serie": "FC01",
        "correlativo_inicial": 0
      }
    ]
  }'

Example Response

{
  "success": true,
  "message": "3 correlativos creados exitosamente",
  "data": {
    "created": [
      {
        "id": 4,
        "tipo_documento": "01",
        "tipo_documento_nombre": "Factura",
        "serie": "F001",
        "correlativo_actual": 0,
        "numero_completo": "F001-000000"
      },
      {
        "id": 5,
        "tipo_documento": "03",
        "tipo_documento_nombre": "Boleta de Venta",
        "serie": "B001",
        "correlativo_actual": 0,
        "numero_completo": "B001-000000"
      },
      {
        "id": 6,
        "tipo_documento": "07",
        "tipo_documento_nombre": "Nota de Crédito",
        "serie": "FC01",
        "correlativo_actual": 0,
        "numero_completo": "FC01-000000"
      }
    ],
    "errors": []
  },
  "meta": {
    "created_count": 3,
    "error_count": 0,
    "total_requested": 3
  }
}

Increment Correlative

Manually increments a correlative counter. This is typically used internally by the system when creating documents.

Path Parameters

branch
integer
required
The branch ID
correlative
integer
required
The correlative ID to increment
This endpoint is usually called automatically by the system when creating new documents. Manual use should be rare and done carefully.

Example Request

curl -X POST "https://api.example.com/api/v1/branches/1/correlatives/4/increment" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Accept: application/json"

Example Response

{
  "success": true,
  "message": "Correlativo incrementado exitosamente",
  "data": {
    "id": 4,
    "serie": "F001",
    "correlativo_anterior": 100,
    "correlativo_actual": 101,
    "numero_usado": "F001-000101",
    "proximo_numero": "F001-000102"
  }
}

Get Document Types

Retrieves a list of all available document types for correlatives.

Example Request

curl -X GET "https://api.example.com/api/v1/correlatives/document-types" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Accept: application/json"

Example Response

{
  "success": true,
  "data": [
    {
      "codigo": "01",
      "nombre": "Factura"
    },
    {
      "codigo": "03",
      "nombre": "Boleta de Venta"
    },
    {
      "codigo": "07",
      "nombre": "Nota de Crédito"
    },
    {
      "codigo": "08",
      "nombre": "Nota de Débito"
    },
    {
      "codigo": "09",
      "nombre": "Guía de Remisión"
    },
    {
      "codigo": "20",
      "nombre": "Comprobante de Retención"
    },
    {
      "codigo": "RC",
      "nombre": "Resumen de Anulaciones"
    },
    {
      "codigo": "RA",
      "nombre": "Resumen Diario"
    }
  ]
}

Error Responses

Validation Error

{
  "success": false,
  "message": "Errores de validación",
  "errors": {
    "tipo_documento": [
      "El campo tipo_documento es obligatorio."
    ],
    "serie": [
      "El campo serie debe tener máximo 4 caracteres."
    ]
  }
}

Duplicate Correlative

{
  "success": false,
  "message": "Ya existe un correlativo para esta sucursal con el mismo tipo de documento y serie"
}

Correlative Not Found

{
  "success": false,
  "message": "El correlativo no pertenece a esta sucursal"
}

Best Practices

Follow these conventions for series codes:
  • Facturas (01): F001, F002, F003…
  • Boletas (03): B001, B002, B003…
  • Notas de Crédito (07): FC01, BC01 (F=Factura, B=Boleta, C=Crédito)
  • Notas de Débito (08): FD01, BD01 (F=Factura, B=Boleta, D=Débito)
  • Guías (09): T001, T002 (T=Traslado)
  • Create correlatives during branch setup
  • Use batch creation to set up multiple series at once
  • Set appropriate starting numbers for each series
  • Monitor correlative usage regularly
  • Keep backup records of correlative configurations
  • Never manually modify correlatives that are actively in use
  • Each document type requires a separate series
  • Series must be unique per branch
  • Correlatives must be sequential without gaps
  • Once a number is used, it cannot be reused
  • Keep audit trails of all correlative changes

Build docs developers (and LLMs) love