> For the complete documentation index, see [llms.txt](https://developers.alephee.com/v2/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.alephee.com/v2/orders/post-methods/attach-a-document-to-an-order/request.md).

# Request and Response

## Attach document to an order

<mark style="color:green;">`POST`</mark> `https://api.alephcrm.com/v2/orders/{orderId}/documents`

#### Query Parameters

| Name                                         | Type     | Description                                                                   |
| -------------------------------------------- | -------- | ----------------------------------------------------------------------------- |
| API\_KEY<mark style="color:red;">\*</mark>   | String   | (default=none)                                                                |
| accountId <mark style="color:red;">\*</mark> | Integer  | (default=none)                                                                |
| orderId                                      | Integer  | Internal Alephee's order ID. It is NOT the marketplace-assigned order number. |
| file                                         | File     |                                                                               |
| fileBase64                                   | String   |                                                                               |
| documentName                                 | String   |                                                                               |
| documentExtension                            | String   |                                                                               |
| documentType                                 | Integer  |                                                                               |
| documentNumber                               | String   |                                                                               |
| documentDate                                 | Datetime |                                                                               |
| messageText                                  | String   |                                                                               |
| fiscalKey                                    | String   |                                                                               |
| seriesNumber                                 | String   |                                                                               |

{% tabs %}
{% tab title="201: Created {"Status": integer, "Message": string}" %}

{% endtab %}

{% tab title="400: Bad Request {"Status": integer, "Message": string}" %}

{% endtab %}

{% tab title="401: Unauthorized {"Status": integer, "Message": string}" %}

{% endtab %}

{% tab title="403: Forbidden {"Status": integer, "Message": string}" %}

{% endtab %}

{% tab title="404: Not Found {"Status": integer, "Message": string}" %}

{% endtab %}

{% tab title="409: Conflict {"Status": integer, "Message": string}" %}

{% endtab %}

{% tab title="412: Precondition Failed {"Status": integer, "Message": string}" %}

{% endtab %}

{% tab title="429: Too Many Requests {"Status": integer, "Message": string}" %}

{% endtab %}

{% tab title="500: Internal Server Error string" %}

{% endtab %}
{% endtabs %}

<mark style="color:orange;">**There are two different ways of attaching the document: through form-data, or through JSON body with a base64-encoded file.**</mark>

### &#x20;1.  With form-data parameters:

This is the most common way, and the endpoint expects to receive the following parameters using URL\_PARAM (via query string) parameters and values. See [example here](/v2/orders/post-methods/attach-a-document-to-an-order/examples-1.md).

### 2. With a JSON body including a base64-encoded file:

This is the easiest way, and the endpoint expects to receive the following parameters using URL\_PARAM (via query string) parameters and values one JSON object in the BODY with some attributes, including a base64-encoded file. See [example here](/v2/orders/post-methods/attach-a-document-to-an-order/examples-2.md).

### API\_KEY

The API\_KEY that was provided.

### accountId

The Alephee account ID of the orders you are trying to get.

### orderId

Alephee ID to identify the order.\
The Alephee order number. It is not the marketplace order number.

### file

Document file to attach into an order.

### fileBase64

The document to attach into an order.\
Must be an encoded base64 string of the document´s full content.

### documentName

Document name, only for base64 encoded files

### documentExtension

Document extension, only for base64 encoded files

### documentType

Type of document to attach.\
Available values are:

* 0 = Invoice
* 1 = Receipt
* 2 = Electronic fiscal invoice (exclusive for Brazilian customers)

This parameter is extremely important.\
Invoices and electronic fiscal invoices are sent to the order’s origin marketplace. Receipts don’t.

### documentNumber

Internal number for the document

### documentDate

The date the document was issued.

### messageText

This field is to specify a text message that will travel with the attached file.

### fiscalKey (only electronic invoice)

Fiscal key of the electronic invoice

### seriesNumber (only electronic invoice)

Series number of the electronic invoice
