📄 Get MIPYME document

This functionality is part of our “Plan factoring” and is only available for companies that use or have used the MIPYME system. This endpoint does not work for retrieving documents issued in market systems.

The /mipyme_get_document endpoint allows you to retrieve documents that were issued using the MIPYME system. This is particularly useful for companies that need to access historical documents or documents that were created in the MIPYME platform.

Important considerations

  • This endpoint is only for companies that use or have used the MIPYME system
  • It does not work for retrieving documents issued in market systems
  • This functionality is part of our “Plan factoring”
  • You will need the PFX certificate and password that were used in the MIPYME system
  • The certificate must be valid and match the company’s RUT

Get a MIPYME document

In order to retrieve a MIPYME document, you need to use the /mipyme_get_document endpoint with the proper parameters. You will need:

  • The PFX certificate in base64 format

  • The certificate password

  • The company RUT (tax ID)

  • The document type according to SII

  • The document folio number

  • Endpoint: https://api-billing.koywe.com/V1/mipyme_get_document

  • Method: POST

  • Required headers:

    • Content-Type: application/json
    • Authorization: Bearer <token>
    • Accept: */*
1{
2 "certificate_pfx_base64": "MIIKpAIBAzCCCl4GCSqGSIb3DQEHAaCCCk8EggpLMIIKRzCCBXsGCSqGSIb3DQEHBqCCBWwwggVoAgEAMIIFYQYJKoZIhvcNAQcBMBwGCiqGSIb3DQEMAQYwDgQI...",
3 "certificate_password": "your_certificate_password",
4 "tax_id_code": "12345678-9",
5 "document_type_taxbureau": "33",
6 "document_number": "12345"
7}

Request parameters

ParameterTypeRequiredDescription
certificate_pfx_base64stringYesBase64 encoded PFX certificate used in the MIPYME system
certificate_passwordstringYesPassword for the PFX certificate
tax_id_codestringYesCompany RUT in format 12345678-9
document_type_taxbureaustringYesDocument type according to SII (e.g., “33” for Factura Electrónica)
document_numberstringYesDocument folio number

Response

The API will return a response with the following structure:

1{
2 "status": 0,
3 "message": "XML obtenido correctamente",
4 "document_xml": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>..."
5}

Response status codes

The status field indicates the result of the operation:

StatusDescription
0XML obtenido ok - Document retrieved successfully
1Parámetros con error - Invalid parameters
2No fue posible abrir el certificado con la clave entregada - Could not open certificate with provided password
3No fue posible iniciar sesión en el SII - Could not login to SII
5Documento no encontrado - Document not found

Example responses

Success response (status 0):

1{
2 "status": 0,
3 "message": "XML obtenido correctamente",
4 "document_xml": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><DTE version=\"1.0\">...</DTE>"
5}

Error response - Invalid parameters (status 1):

1{
2 "status": 1,
3 "message": "Parámetros con error",
4 "document_xml": ""
5}

Error response - Certificate error (status 2):

1{
2 "status": 2,
3 "message": "No fue posible abrir el certificado con la clave entregada",
4 "document_xml": ""
5}

Error response - SII login error (status 3):

1{
2 "status": 3,
3 "message": "No fue posible iniciar sesión en el SII",
4 "document_xml": ""
5}

Error response - Document not found (status 5):

1{
2 "status": 5,
3 "message": "Documento no encontrado",
4 "document_xml": ""
5}

Certificate format

The certificate must be provided as a base64-encoded string of the PFX file. Make sure to:

  • Use the exact certificate that was used in the MIPYME system
  • Encode the entire PFX file content to base64
  • Ensure the certificate is still valid and not expired
  • Use the correct password associated with the certificate

Document types

The document_type_taxbureau parameter should match the SII document type codes:

CodeDocument Type
30Factura
33Factura Electrónica
34Factura Exenta
39Boletas de Ventas y Servicios
46Factura de Compra
52Guía de Despacho
56Nota de Débito
61Nota de Crédito