# Received documents (/en/docs/referencia/recibidos)

Base: `https://api.facturia.cl/v1`. Every endpoint in this chapter authenticates with `Authorization: Bearer` unless stated otherwise, and the error envelope is the one in [Errors](/en/docs/errores).

| Method | Path                                                                                                                                  | What it does                                               |
| ------ | ------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- |
| `GET`  | [`/received_documents`](#get-received-documents)                                                                                      | List supplier DTEs received for this empresa               |
| `GET`  | [`/received_documents/{received_document_id}`](#get-received-documents-received-document-id)                                          | Retrieve a received document                               |
| `GET`  | [`/received_documents/{received_document_id}/xml`](#get-received-documents-received-document-id-xml)                                  | Download the original supplier XML                         |
| `GET`  | [`/received_documents/{received_document_id}/pdf`](#get-received-documents-received-document-id-pdf)                                  | Render the received document as PDF                        |
| `POST` | [`/received_documents/{received_document_id}/accept`](#post-received-documents-received-document-id-accept)                           | Accept the content (SII acción ACD)                        |
| `POST` | [`/received_documents/{received_document_id}/reject`](#post-received-documents-received-document-id-reject)                           | Reclamar the document (RCD / RFP / RFT)                    |
| `POST` | [`/received_documents/{received_document_id}/acknowledge_receipt`](#post-received-documents-received-document-id-acknowledge-receipt) | Otorgar recibo de mercaderías o servicios (SII acción ERM) |

## `GET /received_documents` [#get-received-documents]

**List supplier DTEs received for this empresa**

Supplier DTEs that arrived at the empresa's reception address, newest first, filterable by `tipo_dte` and acceptance `status`.

```bash
curl -sS https://api.facturia.cl/v1/received_documents \
  -H "Authorization: Bearer $FACTURIA_KEY" \
  -H "Facturia-Empresa: $EMPRESA"
```

**Parameters**

| Parameter                   | In     | Required | Type                                                                                                 | Notes                                                                                                                                                                                                                                                                                                                                                       |
| --------------------------- | ------ | -------- | ---------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Facturia-Empresa`          | header | —        | string                                                                                               | Target empresa: canonical RUT (`77928532-4`) or empresa id (`emp_…`). Required on every empresa-scoped call unless the key is an empresa token. This header is the ONLY mechanism: there is no `?empresa=` query parameter and no `empresa` body field. Omitted where required → `400 empresa_required`; outside the allowlist → `403 empresa_not_allowed`. |
| `limit`                     | query  | —        | integer                                                                                              |                                                                                                                                                                                                                                                                                                                                                             |
| `cursor`                    | query  | —        | string                                                                                               | Opaque cursor from a previous response's `next_cursor`.                                                                                                                                                                                                                                                                                                     |
| `expand`                    | query  | —        | string                                                                                               | Accepts nothing on this list, and says so rather than ignoring it. `raw_xml` inlines the supplier's entire signed envelope, so it is available on `GET /received_documents/\{received_document_id\}` only; any value here is `400 invalid_field` (§5.4).                                                                                                    |
| `tipo_dte`                  | query  | —        | `33` · `34` · `39` · `41` · `46` · `52` · `56` · `61`                                                |                                                                                                                                                                                                                                                                                                                                                             |
| `emisor_rut`                | query  | —        | Rut                                                                                                  |                                                                                                                                                                                                                                                                                                                                                             |
| `commercial_response_state` | query  | —        | `pending` · `accepted` · `rejected` · `receipt_acknowledged` · `expired_accepted` · `not_applicable` |                                                                                                                                                                                                                                                                                                                                                             |
| `source`                    | query  | —        | `intercambio` · `rcv` · `manual`                                                                     |                                                                                                                                                                                                                                                                                                                                                             |
| `issue_date[gte]`           | query  | —        | string                                                                                               |                                                                                                                                                                                                                                                                                                                                                             |
| `issue_date[lte]`           | query  | —        | string                                                                                               |                                                                                                                                                                                                                                                                                                                                                             |

**Responses**

| Code      | Meaning                                                                                                                                                                                                                                                                                                 | Body                      |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------- |
| `200`     | A list of received documents.                                                                                                                                                                                                                                                                           | lista de ReceivedDocument |
| `401`     | Missing, malformed or revoked key.                                                                                                                                                                                                                                                                      | ErrorResponse             |
| `403`     | Valid key, not permitted — scope, empresa allowlist, or mode.                                                                                                                                                                                                                                           | ErrorResponse             |
| `429`     | Too many requests.                                                                                                                                                                                                                                                                                      | ErrorResponse             |
| `default` | An error not otherwise enumerated for this operation, in the same §5.5 envelope as every other refusal. Branch on `error.code`, never on the HTTP status alone or on `error.message` — a code this operation has not been seen to throw yet is still safer to route on than a string meant for a human. | ErrorResponse             |

## `GET /received_documents/{received_document_id}` [#get-received-documents-received-document-id]

**Retrieve a received document**

One received DTE, including whatever commercial response (`accept`/`reject`/`acknowledge_receipt`) has been registered for it.

```bash
curl -sS https://api.facturia.cl/v1/received_documents/rdoc_01K2R9M3D8V5QW7N \
  -H "Authorization: Bearer $FACTURIA_KEY" \
  -H "Facturia-Empresa: $EMPRESA"
```

**Parameters**

| Parameter              | In     | Required | Type   | Notes                                                                                                                                                                                                                                                                                                                                                       |
| ---------------------- | ------ | -------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `received_document_id` | path   | yes      | string |                                                                                                                                                                                                                                                                                                                                                             |
| `Facturia-Empresa`     | header | —        | string | Target empresa: canonical RUT (`77928532-4`) or empresa id (`emp_…`). Required on every empresa-scoped call unless the key is an empresa token. This header is the ONLY mechanism: there is no `?empresa=` query parameter and no `empresa` body field. Omitted where required → `400 empresa_required`; outside the allowlist → `403 empresa_not_allowed`. |
| `expand`               | query  | —        | string | `raw_xml` returns the supplier's original XML inline, signature intact.                                                                                                                                                                                                                                                                                     |

**Responses**

| Code      | Meaning                                                                                                                                                                                                                                                                                                 | Body             |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- |
| `200`     | The received document.                                                                                                                                                                                                                                                                                  | ReceivedDocument |
| `401`     | Missing, malformed or revoked key.                                                                                                                                                                                                                                                                      | ErrorResponse    |
| `403`     | Valid key, not permitted — scope, empresa allowlist, or mode.                                                                                                                                                                                                                                           | ErrorResponse    |
| `404`     | No such object under this key.                                                                                                                                                                                                                                                                          | ErrorResponse    |
| `429`     | Too many requests.                                                                                                                                                                                                                                                                                      | ErrorResponse    |
| `default` | An error not otherwise enumerated for this operation, in the same §5.5 envelope as every other refusal. Branch on `error.code`, never on the HTTP status alone or on `error.message` — a code this operation has not been seen to throw yet is still safer to route on than a string meant for a human. | ErrorResponse    |

## `GET /received_documents/{received_document_id}/xml` [#get-received-documents-received-document-id-xml]

**Download the original supplier XML**

The exact XML the SII delivered for this received document.

```bash
curl -sS https://api.facturia.cl/v1/received_documents/rdoc_01K2R9M3D8V5QW7N/xml \
  -H "Authorization: Bearer $FACTURIA_KEY" \
  -H "Facturia-Empresa: $EMPRESA"
```

**Parameters**

| Parameter              | In     | Required | Type   | Notes                                                                                                                                                                                                                                                                                                                                                       |
| ---------------------- | ------ | -------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `received_document_id` | path   | yes      | string |                                                                                                                                                                                                                                                                                                                                                             |
| `Facturia-Empresa`     | header | —        | string | Target empresa: canonical RUT (`77928532-4`) or empresa id (`emp_…`). Required on every empresa-scoped call unless the key is an empresa token. This header is the ONLY mechanism: there is no `?empresa=` query parameter and no `empresa` body field. Omitted where required → `400 empresa_required`; outside the allowlist → `403 empresa_not_allowed`. |

**Responses**

| Code      | Meaning                                                                                                                                                                                                                                                                                                 | Body            |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------- |
| `200`     | The XML as received. This file is the legal artifact.                                                                                                                                                                                                                                                   | application/xml |
| `401`     | Missing, malformed or revoked key.                                                                                                                                                                                                                                                                      | ErrorResponse   |
| `403`     | Valid key, not permitted — scope, empresa allowlist, or mode.                                                                                                                                                                                                                                           | ErrorResponse   |
| `429`     | Too many requests.                                                                                                                                                                                                                                                                                      | ErrorResponse   |
| `default` | An error not otherwise enumerated for this operation, in the same §5.5 envelope as every other refusal. Branch on `error.code`, never on the HTTP status alone or on `error.message` — a code this operation has not been seen to throw yet is still safer to route on than a string meant for a human. | ErrorResponse   |

## `GET /received_documents/{received_document_id}/pdf` [#get-received-documents-received-document-id-pdf]

**Render the received document as PDF**

A rendered PDF of the received document, for display or archival outside the API.

```bash
curl -sS https://api.facturia.cl/v1/received_documents/rdoc_01K2R9M3D8V5QW7N/pdf \
  -H "Authorization: Bearer $FACTURIA_KEY" \
  -H "Facturia-Empresa: $EMPRESA"
```

**Parameters**

| Parameter              | In     | Required | Type   | Notes                                                                                                                                                                                                                                                                                                                                                       |
| ---------------------- | ------ | -------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `received_document_id` | path   | yes      | string |                                                                                                                                                                                                                                                                                                                                                             |
| `Facturia-Empresa`     | header | —        | string | Target empresa: canonical RUT (`77928532-4`) or empresa id (`emp_…`). Required on every empresa-scoped call unless the key is an empresa token. This header is the ONLY mechanism: there is no `?empresa=` query parameter and no `empresa` body field. Omitted where required → `400 empresa_required`; outside the allowlist → `403 empresa_not_allowed`. |

**Responses**

| Code      | Meaning                                                                                                                                                                                                                                                                                                 | Body            |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------- |
| `200`     | The rendered PDF.                                                                                                                                                                                                                                                                                       | application/pdf |
| `401`     | Missing, malformed or revoked key.                                                                                                                                                                                                                                                                      | ErrorResponse   |
| `403`     | Valid key, not permitted — scope, empresa allowlist, or mode.                                                                                                                                                                                                                                           | ErrorResponse   |
| `429`     | Too many requests.                                                                                                                                                                                                                                                                                      | ErrorResponse   |
| `default` | An error not otherwise enumerated for this operation, in the same §5.5 envelope as every other refusal. Branch on `error.code`, never on the HTTP status alone or on `error.message` — a code this operation has not been seen to throw yet is still safer to route on than a string meant for a human. | ErrorResponse   |

## `POST /received_documents/{received_document_id}/accept` [#post-received-documents-received-document-id-accept]

**Accept the content (SII acción ACD)**

Types 33/34/43 only, inside the 8-day window, once. Doing nothing is also a valid,
legally meaningful choice: silence accepts on day 8.

```bash
curl -sS -X POST https://api.facturia.cl/v1/received_documents/rdoc_01K2R9M3D8V5QW7N/accept \
  -H "Authorization: Bearer $FACTURIA_KEY" \
  -H "Facturia-Empresa: $EMPRESA" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"note":"…"}'
```

**Parameters**

| Parameter              | In     | Required | Type   | Notes                                                                                                                                                                                                                                                                                                                                                       |
| ---------------------- | ------ | -------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `received_document_id` | path   | yes      | string |                                                                                                                                                                                                                                                                                                                                                             |
| `Facturia-Empresa`     | header | —        | string | Target empresa: canonical RUT (`77928532-4`) or empresa id (`emp_…`). Required on every empresa-scoped call unless the key is an empresa token. This header is the ONLY mechanism: there is no `?empresa=` query parameter and no `empresa` body field. Omitted where required → `400 empresa_required`; outside the allowlist → `403 empresa_not_allowed`. |
| `Idempotency-Key`      | header | —        | string | Client-generated key, unique per logical operation, retained 24h and scoped to (account, empresa, endpoint). Replays return the original response with `Facturia-Idempotent-Replay: true`. Same key + different body → `409`.                                                                                                                               |

**Body**

| Field         | Type   | Required | Notes |
| ------------- | ------ | -------- | ----- |
| `note`        | string | —        |       |
| **Responses** |        |          |       |

| Code      | Meaning                                                                                                                                                                                                                                                                                                 | Body               |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
| `201`     | The registered commercial response.                                                                                                                                                                                                                                                                     | CommercialResponse |
| `401`     | Missing, malformed or revoked key.                                                                                                                                                                                                                                                                      | ErrorResponse      |
| `403`     | Valid key, not permitted — scope, empresa allowlist, or mode.                                                                                                                                                                                                                                           | ErrorResponse      |
| `409`     | State conflict — idempotency reuse, duplicate external\_id, artifact not ready.                                                                                                                                                                                                                         | ErrorResponse      |
| `422`     | Well-formed but violates a domain rule — folios exhausted, acuse window closed.                                                                                                                                                                                                                         | ErrorResponse      |
| `429`     | Too many requests.                                                                                                                                                                                                                                                                                      | ErrorResponse      |
| `default` | An error not otherwise enumerated for this operation, in the same §5.5 envelope as every other refusal. Branch on `error.code`, never on the HTTP status alone or on `error.message` — a code this operation has not been seen to throw yet is still safer to route on than a string meant for a human. | ErrorResponse      |

## `POST /received_documents/{received_document_id}/reject` [#post-received-documents-received-document-id-reject]

**Reclamar the document (RCD / RFP / RFT)**

Irreversible. There is no un-reclamar.

```bash
curl -sS -X POST https://api.facturia.cl/v1/received_documents/rdoc_01K2R9M3D8V5QW7N/reject \
  -H "Authorization: Bearer $FACTURIA_KEY" \
  -H "Facturia-Empresa: $EMPRESA" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"reason":"content"}'
```

**Parameters**

| Parameter              | In     | Required | Type   | Notes                                                                                                                                                                                                                                                                                                                                                       |
| ---------------------- | ------ | -------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `received_document_id` | path   | yes      | string |                                                                                                                                                                                                                                                                                                                                                             |
| `Facturia-Empresa`     | header | —        | string | Target empresa: canonical RUT (`77928532-4`) or empresa id (`emp_…`). Required on every empresa-scoped call unless the key is an empresa token. This header is the ONLY mechanism: there is no `?empresa=` query parameter and no `empresa` body field. Omitted where required → `400 empresa_required`; outside the allowlist → `403 empresa_not_allowed`. |
| `Idempotency-Key`      | header | —        | string | Client-generated key, unique per logical operation, retained 24h and scoped to (account, empresa, endpoint). Replays return the original response with `Facturia-Idempotent-Replay: true`. Same key + different body → `409`.                                                                                                                               |

**Body**

| Field         | Type                                            | Required | Notes                                                        |
| ------------- | ----------------------------------------------- | -------- | ------------------------------------------------------------ |
| `reason`      | `content` · `partial_missing` · `total_missing` | yes      | content → RCD, partial\_missing → RFP, total\_missing → RFT. |
| `note`        | string                                          | —        |                                                              |
| **Responses** |                                                 |          |                                                              |

| Code      | Meaning                                                                                                                                                                                                                                                                                                 | Body               |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
| `201`     | The registered commercial response.                                                                                                                                                                                                                                                                     | CommercialResponse |
| `401`     | Missing, malformed or revoked key.                                                                                                                                                                                                                                                                      | ErrorResponse      |
| `403`     | Valid key, not permitted — scope, empresa allowlist, or mode.                                                                                                                                                                                                                                           | ErrorResponse      |
| `409`     | State conflict — idempotency reuse, duplicate external\_id, artifact not ready.                                                                                                                                                                                                                         | ErrorResponse      |
| `422`     | Well-formed but violates a domain rule — folios exhausted, acuse window closed.                                                                                                                                                                                                                         | ErrorResponse      |
| `429`     | Too many requests.                                                                                                                                                                                                                                                                                      | ErrorResponse      |
| `default` | An error not otherwise enumerated for this operation, in the same §5.5 envelope as every other refusal. Branch on `error.code`, never on the HTTP status alone or on `error.message` — a code this operation has not been seen to throw yet is still safer to route on than a string meant for a human. | ErrorResponse      |

## `POST /received_documents/{received_document_id}/acknowledge_receipt` [#post-received-documents-received-document-id-acknowledge-receipt]

**Otorgar recibo de mercaderías o servicios (SII acción ERM)**

Register the `acuse de recibo` — receipt of the goods or service, distinct from `accept`/`reject`'s commercial acceptance — inside the statutory 8-day window.

```bash
curl -sS -X POST https://api.facturia.cl/v1/received_documents/rdoc_01K2R9M3D8V5QW7N/acknowledge_receipt \
  -H "Authorization: Bearer $FACTURIA_KEY" \
  -H "Facturia-Empresa: $EMPRESA" \
  -H "Idempotency-Key: $(uuidgen)"
```

**Parameters**

| Parameter              | In     | Required | Type   | Notes                                                                                                                                                                                                                                                                                                                                                       |
| ---------------------- | ------ | -------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `received_document_id` | path   | yes      | string |                                                                                                                                                                                                                                                                                                                                                             |
| `Facturia-Empresa`     | header | —        | string | Target empresa: canonical RUT (`77928532-4`) or empresa id (`emp_…`). Required on every empresa-scoped call unless the key is an empresa token. This header is the ONLY mechanism: there is no `?empresa=` query parameter and no `empresa` body field. Omitted where required → `400 empresa_required`; outside the allowlist → `403 empresa_not_allowed`. |
| `Idempotency-Key`      | header | —        | string | Client-generated key, unique per logical operation, retained 24h and scoped to (account, empresa, endpoint). Replays return the original response with `Facturia-Idempotent-Replay: true`. Same key + different body → `409`.                                                                                                                               |

**Responses**

| Code      | Meaning                                                                                                                                                                                                                                                                                                 | Body               |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
| `201`     | The registered commercial response.                                                                                                                                                                                                                                                                     | CommercialResponse |
| `401`     | Missing, malformed or revoked key.                                                                                                                                                                                                                                                                      | ErrorResponse      |
| `403`     | Valid key, not permitted — scope, empresa allowlist, or mode.                                                                                                                                                                                                                                           | ErrorResponse      |
| `422`     | Well-formed but violates a domain rule — folios exhausted, acuse window closed.                                                                                                                                                                                                                         | ErrorResponse      |
| `429`     | Too many requests.                                                                                                                                                                                                                                                                                      | ErrorResponse      |
| `default` | An error not otherwise enumerated for this operation, in the same §5.5 envelope as every other refusal. Branch on `error.code`, never on the HTTP status alone or on `error.message` — a code this operation has not been seen to throw yet is still safer to route on than a string meant for a human. | ErrorResponse      |
