Examples by country
📄 Get MIPYME document
Note: 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: /
{
"certificate_pfx_base64": "MIIKpAIBAzCCCl4GCSqGSIb3DQEHAaCCCk8EggpLMIIKRzCCBXsGCSqGSIb3DQEHBqCCBWwwggVoAgEAMIIFYQYJKoZIhvcNAQcBMBwGCiqGSIb3DQEMAQYwDgQI...",
"certificate_password": "your_certificate_password",
"tax_id_code": "12345678-9",
"document_type_taxbureau": "33",
"document_number": "12345"
}
Request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
certificate_pfx_base64 |
string | Yes | Base64 encoded PFX certificate used in the MIPYME system |
certificate_password |
string | Yes | Password for the PFX certificate |
tax_id_code |
string | Yes | Company RUT in format 12345678-9 |
document_type_taxbureau |
string | Yes | Document type according to SII (e.g., "33" for Factura Electrónica) |
document_number |
string | Yes | Document folio number |
Response
The API will return a response with the following structure:
{
"status": 0,
"message": "XML obtenido correctamente",
"document_xml": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>..."
}
Response status codes
The status field indicates the result of the operation:
| Status | Description |
|---|---|
| 0 | XML obtenido ok - Document retrieved successfully |
| 1 | Parámetros con error - Invalid parameters |
| 2 | No fue posible abrir el certificado con la clave entregada - Could not open certificate with provided password |
| 3 | No fue posible iniciar sesión en el SII - Could not login to SII |
| 5 | Documento no encontrado - Document not found |
Example responses
Success response (status 0):
{
"status": 0,
"message": "XML obtenido correctamente",
"document_xml": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>..."
}
Error response - Invalid parameters (status 1):
{
"status": 1,
"message": "Parámetros con error",
"document_xml": ""
}
Error response - Certificate error (status 2):
{
"status": 2,
"message": "No fue posible abrir el certificado con la clave entregada",
"document_xml": ""
}
Error response - SII login error (status 3):
{
"status": 3,
"message": "No fue posible iniciar sesión en el SII",
"document_xml": ""
}
Error response - Document not found (status 5):
{
"status": 5,
"message": "Documento no encontrado",
"document_xml": ""
}
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:
| Code | Document Type |
|---|---|
| 30 | Factura |
| 33 | Factura Electrónica |
| 34 | Factura Exenta |
| 39 | Boletas de Ventas y Servicios |
| 46 | Factura de Compra |
| 52 | Guía de Despacho |
| 56 | Nota de Débito |
| 61 | Nota de Crédito |
API Reference POST /mipyme_get_document
Detailed endpoint documentation: /english/billing/api-reference/billing-api/mipyme-documents/get-mipyme-document