API Integration

How to integrate your own software with the LibreDTE API and start invoicing.

General Integration Flow

The process for issuing a DTE (Electronic Tax Document) consists of the following steps:

  1. Data Preparation – Structuring the document’s information.
  2. Consuming REST Services - Communicating with the LibreDTE API.
  3. Replicating the Basic Issuance Flow - Executing the standard flow to issue a DTE using LibreDTE services.

1. Preparing DTE Data

You must structure the data that will be used to create the DTE. You can refer to example files covering the most common use cases in the following repository: Example YAML Files.

Other scenarios should be constructed using the official documentation provided by the SII (Chilean Internal Revenue Service).

2. Consuming the REST Web Services

You have several options to interact with LibreDTE’s REST services:

  • Use the official SDKs provided by LibreDTE for your programming language. You can find them here: LibreDTE Client Repositories.

  • Develop your own client (SDK) to consume the services directly from your application.

  • Use an HTTP library appropriate for your language to handle REST interactions (e.g., Guzzle HTTP for PHP or Requests for Python).

3. Replicating the Basic Issuance Flow

The minimum steps required to issue a DTE are:

  1. Issue a temporary DTE
  2. Generate a real DTE from the temporary version.
  3. Check the status of the DTE submitted to the SII.
  4. Retrieve the PDF of the finalized DTE.

Note: There are additional optional steps such as emailing documents or listing issued DTEs. These are not mandatory and are not covered here. If you wish to perform these actions, please refer to the full documentation: Web Service Documentation

To issue a DTE and obtain its corresponding PDF, your code must perform the API calls illustrated in the following sequence diagram:

LibreDTE Sequence Diagram

DTE Normalization

LibreDTE includes a DTE normalization process, which helps reduce the amount of information required when building a DTE. For instance, the VAT amount on an invoice is calculated automatically based on the net amount and VAT rate, so if these values are not explicitly provided in the request, LibreDTE will compute them.

The normalization process performs the following actions:

  • Adds missing discount/charge numbers and references.
  • Normalizes the line item details: item numbers and item-level discounts.
  • Applies global discounts or surcharges, calculating the respective amounts.
  • Applies additional taxes or withholdings.
  • Calculates VAT and/or total amounts.

Request Format

The JSON object structure used to submit a DTE (Electronic Tax Document) follows the same fields, data types, and constraints as the corresponding DTE XML format. The full specification of the available fields in the XML can be found in the official documentation provided by the Chilean IRS (SII) at the following links:

In addition to JSON, other formats can be used to submit DTE data: XML and YAML. These formats must follow the same structural rules as JSON, adapted to their respective syntax.

If the submitted format is not JSON, the content must be sent encoded in Base64.

All examples in this documentation use JSON, which is the default and recommended format for integrating with LibreDTE’s Web Services.

If you have any questions or need assistance regarding the supported formats, please open a support ticket at: Technical Support Request.

On this page

Last updated on 01/08/2025 by Anonymous