# FetchDocuments

Fetch the inbound document from a tax authority

`POST /documents/$fetch`

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

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

## Description

This API allows you to retrieve an inbound document. Pass key-value pairs as parameters in the request, such as the confirmation number, supplier number, and buyer VAT number.

## Parameters

| Name | Type | In | Required | Description |
|---|---|---|---|---|
| `avalara-version` | string | header | Yes | The HTTP Header meant to specify the version of the API intended to be used |
| `X-Avalara-Client` | string | header | No | You can freely use any text you wish for this value. This feature can help you diagnose and solve problems with your software. The header can be treated like a fingerprint. |

## Request Body

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

## Responses

| Status | Description | Schema |
|---|---|---|
| 200 | Accepted DocumentFetch Request | `documentFetch` |
| 401 | Unauthorized |  |
| 403 | Forbidden | `ForbiddenError` |
| 500 | Internal Server Error | `InternalServerError` |

### 200 Response: `documentFetch`

An object of the inbound document

| 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,
    "countryCode": "IL",
    "countryMandate": "IL-B2B-CLEARANCE"
  }
}'
```