# DownloadDocument

Returns a copy of the document

`GET /documents/{documentId}/$download`

**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/DownloadDocument/

## Description

When the document is available, use this endpoint to download it as text, XML, or PDF. The output format needs to be specified in the Accept header, and it will vary depending on the mandate. If the file has not yet been created, then status code 404 (not found) is returned.

## 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 |
| `Accept` | string | header | Yes | This header indicates the MIME type of the document |
| `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. |
| `documentId` |  | path | Yes | The unique ID for this document that was returned in the POST /einvoicing/document response body |

## Responses

| Status | Description | Schema |
|---|---|---|
| 200 | OK |  |
| 401 | Unauthorized |  |
| 403 | Forbidden | `ForbiddenError` |
| 404 | A document for the specified ID was not found. | `NotFoundError` |
| 406 | Unsupported document format was requested in the Accept header | `BadDownloadRequest` |

## Example Request

```bash
curl -X GET "https://api.sbx.avalara.com/einvoicing/documents/{documentId}/$download" \
  -H "Authorization: Basic <credentials>" \
  -H "Accept: application/json"
```