# Autofatture (https://docs.getbeel.com/en/api/autofatture)

Read a reverse-charge autofattura (TD17, TD18, TD19) and send it to SDI, exactly like the Send to SDI button.

An autofattura is the document you send to SDI for a purchase from a foreign supplier (reverse charge): **TD17** for services from abroad, **TD18** for goods from another EU country, **TD19** for goods already in Italy. getbeel proposes and generates them from your bank debits, the Autofatture import and the foreign invoices you receive. The id is the one on the Autofatture page (the bank transaction it belongs to).

Reads take `invoices:read` (both key modes). Sending takes `invoices:write` and a **live key**: it is a real fiscal act.

## Read an autofattura [#read-an-autofattura]

```bash
curl "https://www.getbeel.com/api/v1/autofatture/$AUTOFATTURA_ID" \
  -H "Authorization: Bearer $GETBEEL_API_KEY"
```

```json title="Response"
{
  "id": "9ea93ca3-fb8b-4ac3-b991-bdec63081696",
  "object": "autofattura",
  "date": "2026-11-02",
  "supplier": "Vercel Inc.",
  "supplier_country": "US",
  "supplier_invoice_number": "INV-1102",
  "amount": "-20.00",
  "currency": "USD",
  "tipo_documento": "TD17",
  "numero": "AF-2026-7",
  "status": "generated",
  "xml_ready": true,
  "sdi": { "status": null, "id": null, "error": null, "updated_at": null }
}
```

`status` is the XML: `generated` means it is ready to send. `sdi.status` is `null` until you send it, then `queued`, `sending`, `sent_to_sdi`, and SDI's answer: `consegnata` (delivered), `non_consegnata`, `scartata` (rejected, with `sdi.error`).

## Send it to SDI [#send-it-to-sdi]

```bash
curl -X POST "https://www.getbeel.com/api/v1/autofatture/$AUTOFATTURA_ID/send" \
  -H "Authorization: Bearer $GETBEEL_API_KEY"
```

It runs the same steps as the **Send to SDI** button on the Autofatture page:

- the XML must be generated (`409 autofattura_xml_missing` or `autofattura_not_generated` otherwise);
- the send is paid from your prepaid balance at the SDI send price (see [Pricing](/en/api/pricing)). When the balance does not cover it the answer is `402 insufficient_balance` ([Errors](/en/api/errors#insufficient_balance)) and nothing is sent;
- it is queued: the response is the autofattura with `sdi.status: "queued"`. Read it again later for SDI's answer.

**Safe to repeat.** A second call never sends or charges again: `409 autofattura_already_queued` while it is on its way, `409 autofattura_already_sent` once SDI has it. A corrected resend after a rejection is not charged again. Other refusals: `409 sdi_monthly_cap_reached` (the monthly limit of live sends), `409 sdi_not_available` (an account still on a legacy plan without the SDI service), `404 resource_missing`, `403 livemode_required` with a test key.

The MCP tools `get_autofattura` and `send_autofattura_to_sdi` do the same (see [MCP](/en/api/mcp)).
