# SubmitDocument

Submits a document to Avalara E-Invoicing API

`POST /documents`

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

## Description

When a UBL document is sent to this endpoint, it generates a document in the required format as mandated by the specified country. Additionally, it initiates the workflow to transmit the generated document to the relevant tax authority, if necessary.The response from the endpoint contains a unique document ID, which can be used to request the status of the document and verify if it was successfully accepted at the destination.Furthermore, the unique ID enables the download of a copy of the generated document for reference purposes.

## 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:** `multipart/form-data`
**Schema:** `SubmitDocument`

Allows submission of a document.

| Property | Type | Required | Description |
|---|---|---|---|
| `metadata` | object | **Yes** | Key value pairs of metadata for a document submission {  "workflowId": "partner-einvoicing", "dataFormat": "ubl-invoice", "dataFormatVersion": "2.1", "countryCode": "SA", "countryMandate": "SA-Phase1-B2B" } |
| `data` | object | **Yes** | The document to be submitted, as indicated by the metadata fields 'dataFormat' and 'dataFormatVersion' |

## Responses

| Status | Description | Schema |
|---|---|---|
| 201 | Created | `DocumentSubmitResponse` |
| 400 | Bad request |  |
| 401 | Unauthorized |  |
| 403 | Forbidden | `ForbiddenError` |

### 201 Response: `DocumentSubmitResponse`

Returns the unique ID of a successful document submission

| 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`. |

## Example Request

```bash
curl -X POST "https://api.sbx.avalara.com/einvoicing/documents" \
  -H "Authorization: Basic <credentials>" \
  -H "Accept: application/json" \
  -d '{
  "metadata": {
    "workflowId": "partner-einvoicing",
    "dataFormat": "ubl-invoice",
    "dataFormatVersion": "2.1",
    "countryCode": "SA",
    "countryMandate": "SA-Phase1-B2B"
  },
  "data": {}
}'
```