### Example cURL Request Source: https://docsapi-openfactura.haulmer.com/?version=latest/index This snippet shows an example of a cURL request, likely used for interacting with an API or service related to OpenFactura or Haulmer. It demonstrates how to make a request to a specified endpoint. ```curl curl --location '' ``` -------------------------------- ### GET /organization/document Example Source: https://docsapi-openfactura.haulmer.com/?version=latest/index Example of retrieving authorized document types and available folios for a taxpayer. ```APIDOC GET /organization/document URL: https://dev-api.haulmer.com/v2/dte/organization/document Description: Proporciona la información de los tipos de documentos que tiene autorizados el contribuyente junto con la cantidad de folios disponibles. Headers: apikey: * | string Response: rut: string documentos: array dte: string disponible: int vencimiento: string ``` -------------------------------- ### Get Organization Documents Source: https://docsapi-openfactura.haulmer.com/?version=latest/index Retrieves a list of electronic documents (DTE) for an organization, including their availability and expiration dates. Requires an API key for authentication. ```APIDOC Endpoint: POST /v2/dte/organization/document Headers: apikey: * (string) - Your API key for authentication. Request Body Example: { "rut": "76795561-8" } Response Body Example: { "documentos": [ { "dte": 39, "disponibles": 399298, "vencimiento": "2025-10-01" }, { "dte": 43, "disponibles": 48500, "vencimiento": "2025-10-01" } ] } Status Codes: 200 OK - Successfully retrieved document information. ``` ```curl curl --location 'https://dev-api.haulmer.com/v2/dte/organization/document' \ --header 'apikey: 928e15a2d14d4a6292345f04960f4bd3' \ --header 'Content-Type: application/json' \ --data '{ "rut": "76795561-8" }' ``` ```json { "documentos": [ { "dte": 39, "disponibles": 399298, "vencimiento": "2025-10-01" }, { "dte": 43, "disponibles": 48500, "vencimiento": "2025-10-01" }, { "dte": 56, "disponibles": 400000, "vencimiento": "2025-10-01" }, { "dte": 46, "disponibles": 48500, "vencimiento": "2025-10-01" }, { "dte": 41, "disponibles": 299547, "vencimiento": "2025-10-01" }, { "dte": 52, "disponibles": 399997, "vencimiento": "2025-10-01" }, { "dte": 61, "disponibles": 399996, "vencimiento": "2025-10-01" }, { "dte": 34, "disponibles": 299996, "vencimiento": "2025-10-01" }, { "dte": 33, "disponibles": 324968, "vencimiento": "2025-10-01" } ] } ``` -------------------------------- ### Get Taxpayer Information by RUT Source: https://docsapi-openfactura.haulmer.com/?version=latest/index Retrieves basic taxpayer information from the SII, which can be used to supplement 'Receptor' details during document issuance. Requires an API key and the taxpayer's RUT. ```APIDOC Endpoint: GET /v2/dte/taxpayer/:rut URL Parameters: rut (string, required): The RUT of the taxpayer to search for. Headers: apikey: * (string) - Your API key for authentication. Response: rut: string razonSocial: string email: string telefono: string direccion: string comuna: string actividades: array giro: string actividadEconomica: string codigoActividadEconomica: int actividadPrincipal: boolean sucursales: array Description: Provides basic taxpayer information registered with the SII, useful for complementing 'Receptor' data during document issuance. ``` -------------------------------- ### Get Taxpayer Information Source: https://docsapi-openfactura.haulmer.com/?version=latest/index Retrieves detailed information about a taxpayer using their RUT. This includes their social reason, contact details, address, and a list of their economic activities and branches (sucursales). ```APIDOC GET /v2/dte/taxpayer/{rut} Headers: apikey: string (required) Path Variables: rut: string (required) - The RUT of the taxpayer. Example Request: curl --location 'https://dev-api.haulmer.com/v2/dte/taxpayer/76795561-8' \ --header 'apikey: 928e15a2d14d4a6292345f04960f4bd3' Example Response (200 OK): { "rut": "76795561-8", "razonSocial": "HAULMER CHILE SPA", "email": "haulmer1@haulmer.com", "telefono": "0", "direccion": "A PRAT 545 DP 2", "comuna": "Curicó", "actividades": [ { "giro": "PRODUCTOS Y SERVICIOS RELACIONADOS CON INTERNET, SOFTWARE, DISPOSITIVO", "actividadEconomica": "OTROS TIPOS DE INTERMEDIACION MONETARIA N.C.P.", "codigoActividadEconomica": "641990", "actividadPrincipal": true } ], "sucursales": [ { "cdgSIISucur": "81303347", "comuna": "Curicó", "direccion": "A PRAT 545 DP 2", "ciudad": "", "telefono": null } ] } ``` -------------------------------- ### Anular DTE 52 (Guía de Despacho) Source: https://docsapi-openfactura.haulmer.com/?version=latest/index Allows the cancellation of an electronic dispatch guide (DTE 52). It includes a validation to prevent the same document from being annulled more than once. Requires an API key for authorization. ```APIDOC POST /v2/dte/anularDTE52 URL: https://dev-api.haulmer.com/v2/dte/anularDTE52 Description: API que permite anular Guía de Despacho Electrónica dte 52, además realiza la validación que no se pueda anular el documento más de una vez. Authorization: apikey: string (required) JSON Parameters: dte: int (required) - Tipo dte folio: int (required) - Folio del documento Fecha: string (required) - Fecha emisión del documento formato Y-m-d Response: succes: string (required) ``` -------------------------------- ### Anular DTE Request and Response Source: https://docsapi-openfactura.haulmer.com/?version=latest/index Provides an example of how to annul a DTE (Documento Tributario Electrónico) using the Haulmer API. It includes the request headers, the JSON body for the request, and a sample success response. ```curl curl --location 'https://dev-api.haulmer.com/v2/dte/anularDTE52' \ --header 'apikey: 928e15a2d14d4a6292345f04960f4bd3' \ --header 'Content-Type: application/json' \ --data '{"Dte": 52,"Folio": 34972,"Fecha": "2020-10-16"}' ``` ```json { "success": "Se ha anulado el documento Folio: 34972" } ``` -------------------------------- ### FAQ: API Key, Production Transition, DTE Status, CAF Management Source: https://docsapi-openfactura.haulmer.com/?version=latest/index Addresses common questions for users, including how to obtain a production API key, the process for moving to production, verifying DTE emission status, and information about automatic CAF management. ```APIDOC 1.- ¿Dónde solicito mi _API Key_ de producción? Se puede generar _API Key_ desde la Plataforma de Openfactura , [Tutorial de apikey](https://help.haulmer.com/hc/api/como-obtengo-la-api-key-de-openfactura-aa728802-2fe2-4f3d-9bb5-2113c357ba6a?searched=true). 2.- ¿Qué debo hacer para pasar a producción? Además de contar con la _API Key_ de la empresa que se desea integrar, se debe tener especial cuidado en cambiar la URL de conexión con Openfactura por la de producción: `https://api.haulmer.com` 3.- ¿Cómo sé si el DTE fue emitido correctamente? Si luego de la emisión recibes el _token_ del documento esto quiere decir que fue recepcionado correctamente por el sistema Openfactura. Para confirmar que el documento ya fue entregado al S.I.I. puedes consultar la [API `status` del documento](https://docsapi-openfactura.haulmer.com/?version=latest#02d546b8-e424-4533-9a5d-4c53b8912798), cabe destacar que el tiempo de entrega del documento al S.I.I. varía dependiendo la cantidad de emisiones realizadas, en la mayoria de los casos no debe tomar más de 3 minutos. 4.- ¿Dónde subo o gestiono los CAF? Openfactura se encarga de gestionar los CAF automáticamente para todo los clientes, por lo tanto ya no se deben subir los CAF de forma manual en el sistema. ``` -------------------------------- ### Production Best Practices: Idempotency and PDF Generation Source: https://docsapi-openfactura.haulmer.com/?version=latest/index Offers guidance for production environments, emphasizing the use of idempotency keys to prevent duplicate transactions and suggesting to omit PDF generation during DTE emission to reduce response times. The PDF can be generated later if needed. ```APIDOC Idempotency Key: Utilizar siempre que sea posible la idempotencia para las emisiones de DTE, de esta forma se puede tener la seguridad que al reintentar no se producirá una doble emisión en el sistema. Dependiendo de la integración la _Idempotency Key_ va a variar, dado que el cliente es responsable de asegurar su unicidad, los usos más comunes corresponden a; el número de la orden de compra, número aleatorio generado en la sesión del cliente, entre muchos otros. Generación PDF: Con el fin de reducir los tiempos de respuesta durante una emisión, hay que tener en consideración que la generación del PDF puede llegar a representar hasta el 60% del tiempo de una emisión. Dependiendo del tipo de integración pueden haber casos que no es necesario contar con el PDF en ese mismo instante que se está haciendo la emisión del DTE, ya sea porque cuentan con su propia representación de 57mm, 80mm o PDF. Para esos casos de uso se recomienda **no solicitar el PDF** en la respuesta (objeto `response` de la [API Emisión](https://docsapi-openfactura.haulmer.com/?version=latest#be54dff8-48c6-472e-8d6c-1c19fbf828c0)), reduciendo de esta forma drásticamente los tiempos de respuesta. Para la tranquilidad del integrador, si no se solicita el PDF en la emisión, cuando el PDF sea requerido ya sea vía API o interfaz de Openfactura, se generará en el momento con la configuración que se haya mandado en el objeto `response` (`80MM` o `LETTER`). ``` -------------------------------- ### Openfactura API Endpoints Source: https://docsapi-openfactura.haulmer.com/?version=latest/index This section details the available RESTful API endpoints for interacting with Openfactura, including methods for DTE emission, document retrieval, and registry access. ```APIDOC POST /document/issued - Description: Issues a DTE. - Request Body: JSON object containing DTE details. - Headers: apikey (string, required) POST /document/received - Description: Records a received DTE. - Request Body: JSON object containing DTE details. - Headers: apikey (string, required) POST /document/received/accuse - Description: Acknowledges receipt of a DTE. - Request Body: JSON object with acknowledgment details. - Headers: apikey (string, required) GET /document/{rut}/{type}/{document-number}/{value} - Description: Retrieves a specific document by its RUT, type, number, and value. - Parameters: - rut (string, required): Taxpayer's RUT. - type (string, required): Document type. - document-number (string, required): Document number. - value (string, required): Document value. - Headers: apikey (string, required) GET /document/{token}/{value} - Description: Retrieves a document using a token and value. - Parameters: - token (string, required): Access token. - value (string, required): Document value. - Headers: apikey (string, required) GET /registry/sales/{year}/{month}/{day} - Description: Retrieves sales registry for a specific day. - Parameters: - year (int, required): Year. - month (int, required): Month. - day (int, required): Day. - Headers: apikey (string, required) GET /registry/sales/{year}/{month} - Description: Retrieves sales registry for a specific month. - Parameters: - year (int, required): Year. - month (int, required): Month. - Headers: apikey (string, required) GET /registry/purchase/{year}/{month}/{day} - Description: Retrieves purchase registry for a specific day. - Parameters: - year (int, required): Year. - month (int, required): Month. - day (int, required): Day. - Headers: apikey (string, required) GET /registry/purchase/{year}/{month} - Description: Retrieves purchase registry for a specific month. - Parameters: - year (int, required): Year. - month (int, required): Month. - Headers: apikey (string, required) GET /organization - Description: Retrieves organization information. - Headers: apikey (string, required) GET /organization/document - Description: Retrieves authorized document types and available folios for a taxpayer. - Headers: apikey (string, required) - Response: - rut (string): Taxpayer's RUT. - documentos (array): List of documents. - dte (string): Document type. - disponible (int): Available folios. - vencimiento (string): Expiration date. GET /taxpayer/{rut} - Description: Retrieves taxpayer information by RUT. - Parameters: - rut (string, required): Taxpayer's RUT. - Headers: apikey (string, required) POST /anularDTE52 - Description: Cancels a DTE. - Request Body: JSON object with cancellation details. - Headers: apikey (string, required) GET /Buenas Prácticas Producción - Description: Provides information on production best practices. GET /Preguntas Frecuentes - Description: Provides answers to frequently asked questions. ``` -------------------------------- ### Openfactura API URLs Source: https://docsapi-openfactura.haulmer.com/?version=latest/index The base URLs for accessing the Openfactura API in different environments. ```APIDOC Production URL: `https://api.haulmer.com` Development URL: `https://dev-api.haulmer.com` ``` -------------------------------- ### API Key Authentication Source: https://docsapi-openfactura.haulmer.com/?version=latest/index Information on how to authenticate API requests using an API Key and the response for invalid keys. ```APIDOC Authentication: - All API requests must include an 'apikey' in the header. - The API Key is used to verify permissions and identify the requester. Response on Invalid API Key: - Status Code: 401 - Message: "Access denied due to invalid subscription key. Make sure to provide a valid key for an active subscription." Example Response: ```json { "statusCode": 401, "message": "Access denied due to invalid subscription key. Make sure to provide a valid key for an active subscription." } ``` ``` -------------------------------- ### API Rate Limiting Source: https://docsapi-openfactura.haulmer.com/?version=latest/index Details on the API's rate limits and the response received when these limits are exceeded. ```APIDOC Rate Limits: - Queries per second: 3 - Queries per minute: 100 Response on Limit Exceeded: - Status Code: 429 - Message: "Rate limit is exceeded. Try again in X seconds." Example Response: ```json { "statusCode": 429, "message": "Rate limit is exceeded. Try again in X seconds." } ``` ``` -------------------------------- ### Error Response Structure Source: https://docsapi-openfactura.haulmer.com/?version=latest/index Defines the structure for error responses, including a general message, an error code, and an array for detailed issues. The details array contains specific fields and their corresponding issues. ```json { "error": { "message": string, "code": "OF-10", "details": array } } ``` ```json { "details": [ { "field": string, "issue": string }, { "field": string, "issue": string } ] } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.