# FetchDocuments

Fetch the inbound document from a tax authority

`POST /documents/$fetch`

**API:** Avalara E-Invoicing API
**Tag:** Documents
**API Version:** 1.6
**Base URL:** https://api.sbx.avalara.com/einvoicing
**Authentication:** Bearer token

Source: https://developer.avalara.com/products/e-invoicing/api/v1.6/methods/Documents/FetchDocuments/

## Description

Retrieves an inbound document. Provide key-value pairs as request parameters. Supported parameters vary by tax authority and country.

## Parameters

| Name | Type | In | Required | Description |
|---|---|---|---|---|
| `avalara-version` | string | header | Yes | Header that specifies the API version to use (for example "1.6"). |
| `X-Avalara-Client` | string | header | No | Optional header for a client identifier string used for diagnostics (for example "Fingerprint"). |

## Request Body

**Content-Type:** `application/json`

## Responses

| Status | Description | Schema |
|---|---|---|
| 200 | Response from the inbound document fetch endpoint. Contains the platform documentId for status checks and downloads, the returned status (e.g. Accepted), and eventDateTime when the document was accepted. | `documentFetch` |
| 401 | Unauthorized. |  |
| 403 | Forbidden. | `ForbiddenError` |
| 500 | Internal server error. | `InternalServerError` |

### 200 Response: `documentFetch`

| Property | Type | Required | Description |
|---|---|---|---|
| `id` | string | No | Unique ID for this document that can be used for status checking and file downloads. This is a UID created by the Avalara E-Invoicing platform. Example: `52f60401-44d0-4667-ad47-4afe519abb53`. |
| `status` | string | No | Status of the document Example: `Accepted`. |
| `eventDateTime` | string | No | The date and time when the inbound document was accepted by the Avalara E-Invoicing Platform Example: `2024-05-27T14:20:07:723`. |

## Example Request

```bash
curl -X POST "https://api.sbx.avalara.com/einvoicing/documents/$fetch" \
  -H "Authorization: Basic <credentials>" \
  -H "Accept: application/json" \
  -d '{
  "data": [
    {
      "key": "Confirmation_Number",
      "value": "987654321"
    },
    {
      "key": "Customer_VAT_Number",
      "value": "777777715"
    }
  ],
  "metadata": {
    "workflowId": "partner-einvoicing",
    "dataFormat": "ubl-invoice",
    "dataFormatVersion": 2.1,
    "outputDataFormat": "ubl-invoice",
    "outputDataFormatVersion": 2.1,
    "countryCode": "IL",
    "countryMandate": "IL-B2B-CLEARANCE"
  }
}'
```