Try the sandbox

How to connect your AI-built app (Lovable, Bolt, v0, Cursor, Claude Code) to Chile's SII to issue receipts

Short answer: your app does not talk to the SII (Servicio de Impuestos Internos, Chile's tax authority). It talks to an API that does (SharkPOS API), and that call has to come from a backend, never from the browser, because it carries a secret API key. You give the agent the SharkPOS guide, ask it to put the issuing call in a server function, and check a few things in the code it generates.

Why can't you issue from the browser?

The API key identifies your issuing RUT (the Chilean tax ID): whoever has it can issue tax documents in your name. According to the SharkPOS agent guide, the key goes only in the backend, never in a mobile app, the browser or the repository, and is read from an environment variable (for example SHARKPOS_API_KEY). Anything that reaches the browser, including your app's code, can be read by anyone.

In tools like Lovable or Bolt, and in apps generated by v0, the backend is a server function (or edge function). The browser calls that function; the function calls SharkPOS with the key stored as a project secret. How a secret is stored depends on each platform: look it up in their documentation.

You also do not build XML or connect to the SII: SharkPOS signs, stamps with the CAF (Código de Autorización de Folios, the SII-issued authorization for document numbers), sends to the SII and follows its response. Your app only sends JSON.

What do I ask the agent?

Give it three things:

  1. The AI integration section of the documentation, which has a ready-made prompt.
  2. The agent guide in Markdown: /en/docs/agents.md. It is a single file with the rules, endpoints and errors.
  3. If your tool supports MCP servers, the documentation one: https://api.sharkpos.cl/mcp. It is read-only and needs no API key.

And a starter message like this one:

We are going to issue Chilean SII electronic boletas (receipts) with SharkPOS API.
Read https://api.sharkpos.cl/en/docs/agents.md before writing code.
The contract is at https://api.sharkpos.cl/docs/openapi.yaml: do not invent fields or endpoints.
Use the sandbox (https://sandbox.sharkpos.cl).
The API key goes in SHARKPOS_API_KEY, only in a server function.
Every issuance carries a stable Idempotency-Key per sale.
Before changing anything, tell me where sales are recorded and where you propose to issue.

The last line matters: the agent proposes and you decide where issuing hooks in. There is more detail in electronic invoicing with Claude Code or ChatGPT (in Spanish) and in issuing receipts with an AI agent and MCP.

What is the flow: sale, issuance and PDF?

  1. The customer pays in your app and you record the sale with its identifier (for example venta-884).
  2. Your server function calls POST /api/v1/dte/boleta/emit/ with the key and an Idempotency-Key equal to the sale identifier.
  3. The 201 response carries folio (the document number), xml_data and links with the path to the PDF and the timbre (stamp). You hand over the receipt at that moment.
  4. The SII result arrives later, by webhook or by querying the document status. A queued or sent document is not issued again: you wait.
curl -X POST https://sandbox.sharkpos.cl/api/v1/dte/boleta/emit/ \
  -H "Authorization: Bearer $SHARKPOS_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: venta-884" \
  -d '{
    "document_type": 39,
    "amount_total": 16980,
    "medio_pago": 1,
    "items": [
      {"name": "Ñoquis a la boloñesa", "qty": 1, "price": 8990},
      {"name": "Café cortado", "qty": 2, "price": 3995}
    ]
  }'

Prices include VAT and amount_total must equal the sum of the lines. Amounts are whole pesos, JSON numbers, not text. The issuer RUT is not in the body: it comes from the API key.

The PDF is downloaded with GET /api/v1/dte/boleta/{dte_id}/pdf/?paper_width=80 (58 or 80 mm), also with the key, so it goes through your server function. If you prefer to build your own ticket, the timbre is in links.ted_png.

What do I check in the AI-generated code?

If something fails, check the list of common errors with their cause and fix.

What if my backend is Python, Node or PHP?

The flow is the same. There are guides with code for Python, Node and PHP (in Spanish).

Try it in the sandbox

Request your test API key at api.sharkpos.cl/sandbox: it arrives with a company, a certificate and test folios, and it never touches the real SII. When everything works, production costs CLP 5,990 a month per RUT, VAT included, with 20,000 documents a month.

Try it today in the sandbox

Get a sandbox API key: a test company with certificate and folios already loaded and a simulated SII. When you are ready, each RUT costs CLP 5,990 a month (VAT included) with 20,000 documents a month.