# Document

## Get Documents

<mark style="color:blue;">`GET`</mark> `https://open-api.zortout.com/v4/Document/GetDocuments`

Get list of documents.

#### Query Parameters

| Name          | Type   | Description                                                                                                                                                                                       |
| ------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| page          | Int    | Page (Default = 1)                                                                                                                                                                                |
| limit         | Int    | Limit per page (Max = 200)                                                                                                                                                                        |
| createdafter  | String | <p>Created Date After ..... </p><p>(yyyy-MM-dd)</p>                                                                                                                                               |
| createdbefore | String | <p>Created Date Before .....<br>(yyyy-MM-dd)</p>                                                                                                                                                  |
| searchnumber  | String | Document Number or Reference Number                                                                                                                                                               |
| documenttype  | Int    | <p>Document Type <br>1 – Receipt<br>2 – Tax Invoice<br>3 – Invoice<br>4 – Quotation<br>5 – Withholding Tax<br>If documenttype is not defined or equals 0, the system will show all documents.</p> |
| idtype        | Int    | <p>Related Transaction Type</p><p>1 – Order/Purchase Order<br>2 – Income/Expense<br>3 – Quotation<br>If idtype is not defined or equals 0, the system will show all.</p>                          |

#### Headers

| Name                                        | Type   | Description                                                                                                                                                        |
| ------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| storename<mark style="color:red;">\*</mark> | String | Store Name                                                                                                                                                         |
| apikey<mark style="color:red;">\*</mark>    | String | API Key                                                                                                                                                            |
| apisecret<mark style="color:red;">\*</mark> | String | API Secret                                                                                                                                                         |
| idlist                                      | String | <p>List Of Related Transaction ID</p><p>Ex. “123,124,125“<br>This will be active when idtype is defined and not equals 0. So this will be related on "idtype".</p> |

{% tabs %}
{% tab title="Response" %}

| Parameter | Type             | Description/Example                   |
| --------- | ---------------- | ------------------------------------- |
| res       | Response         | <p>Response Code <br>200- Success</p> |
| list      | Document (Array) | Document List (Array)                 |
| count     | Int              | Total document number by filter       |

<table><thead><tr><th>Document (Array)</th><th width="158">Type</th><th>Description/Example</th></tr></thead><tbody><tr><td>id</td><td>Int</td><td>Document ID</td></tr><tr><td>header</td><td>String</td><td>Document Header</td></tr><tr><td>documentnumber</td><td>String</td><td>Document Number</td></tr><tr><td>referenceid</td><td>Int</td><td>Reference ID of Document</td></tr><tr><td>referencetype</td><td>Int</td><td><p>Reference Type of Document</p><p>0 - Undefined</p><p>1 – Order <br>2 – Purchase Order</p><p>3 – Return Order<br>4 – Return Purchase Order<br>5 – Other Income</p><p>6 – Other Expense</p></td></tr><tr><td>referencenumber</td><td>String</td><td>Reference Number</td></tr><tr><td>linkurl</td><td>String</td><td>Document Url</td></tr><tr><td>documentdate</td><td>Date</td><td>Document Date</td></tr><tr><td>documentdateString</td><td>String</td><td>Document Date<br>(yyyy-MM-dd)</td></tr><tr><td>createdatetime</td><td>Datetime</td><td>Created Datetime</td></tr><tr><td>createdatetimeString</td><td>String</td><td>Created Datetime Text <br>(yyyy-MM-dd HH:mm)</td></tr><tr><td>detail</td><td>Detail</td><td>Document Detail</td></tr></tbody></table>

| Detail              | Type                | Description/Example   |
| ------------------- | ------------------- | --------------------- |
| order               | Order               | Order                 |
| purchase            | PurchaseOrder       | Purchase Order        |
| returnOrder         | ReturnOrder         | Return Order          |
| returnPurchaseOrder | ReturnPurchaseOrder | Return Purchase Order |
| income              | Income              | Income                |
| expense             | Expense             | Expense               |
| quotation           | Quotation           | Quotation             |
| {% endtab %}        |                     |                       |
| {% endtabs %}       |                     |                       |

## Get Documents of Order

<mark style="color:blue;">`GET`</mark> `https://open-api.zortout.com/v4/Document/GetDocumentOrders`

Get list of documents in order.

#### Query Parameters

| Name                                 | Type | Description                                                                                                                                               |
| ------------------------------------ | ---- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| id<mark style="color:red;">\*</mark> | Int  | Order ID                                                                                                                                                  |
| documenttype                         | Int  | <p>Document Type <br>1 – Receipt<br>2 – Tax Invoice<br>3 – Invoice<br>If documenttype is not defined or equals 0, the system will show all documents.</p> |

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| storename<mark style="color:red;">\*</mark> | String | Store Name  |
| apikey<mark style="color:red;">\*</mark>    | String | API Key     |
| apisecret<mark style="color:red;">\*</mark> | String | API Secret  |

{% tabs %}
{% tab title="Response" %}

| Parameter | Type             | Description/Example                   |
| --------- | ---------------- | ------------------------------------- |
| res       | Response         | <p>Response Code <br>200- Success</p> |
| list      | Document (Array) | Document List (Array)                 |
| count     | Int              | Total document number by filter       |

| Document (Array)     | Type     | Description/Example                                                                                                                                                                          |
| -------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| id                   | Int      | Document ID                                                                                                                                                                                  |
| header               | String   | Document Header                                                                                                                                                                              |
| documentnumber       | String   | Document Number                                                                                                                                                                              |
| referenceid          | Int      | Reference ID of Document                                                                                                                                                                     |
| referencetype        | Int      | <p>Reference Type of Document</p><p>0 - Undefined</p><p>1 – Order <br>2 – Purchase Order</p><p>3 – Return Order<br>4 – Return Purchase Order<br>5 – Other Income</p><p>6 – Other Expense</p> |
| referencenumber      | String   | Reference Number                                                                                                                                                                             |
| linkurl              | String   | Document Url                                                                                                                                                                                 |
| documentdate         | Date     | Document Date                                                                                                                                                                                |
| documentdateString   | String   | <p>Document Date<br>(yyyy-MM-dd)</p>                                                                                                                                                         |
| createdatetime       | Datetime | Created Datetime                                                                                                                                                                             |
| createdatetimeString | String   | <p>Created Datetime Text <br>(yyyy-MM-dd HH:mm)</p>                                                                                                                                          |
| detail               | Detail   | Document Detail                                                                                                                                                                              |

| Detail              | Type                | Description/Example   |
| ------------------- | ------------------- | --------------------- |
| order               | Order               | Order                 |
| purchase            | PurchaseOrder       | Purchase Order        |
| returnOrder         | ReturnOrder         | Return Order          |
| returnPurchaseOrder | ReturnPurchaseOrder | Return Purchase Order |
| income              | Income              | Income                |
| expense             | Expense             | Expense               |
| quotation           | Quotation           | Quotation             |
| {% endtab %}        |                     |                       |
| {% endtabs %}       |                     |                       |

## Add Document of Order

<mark style="color:green;">`POST`</mark> `https://open-api.zortout.com/v4/Document/AddDocumentOrder`

Add document in order.

#### Query Parameters

| Name                                 | Type | Description                                                   |
| ------------------------------------ | ---- | ------------------------------------------------------------- |
| id<mark style="color:red;">\*</mark> | Int  | Order ID                                                      |
| useexist                             | Int  | If this value = 1, the system will return existing documents. |

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| storename<mark style="color:red;">\*</mark> | String | Store Name  |
| apikey<mark style="color:red;">\*</mark>    | String | API Key     |
| apisecret<mark style="color:red;">\*</mark> | String | API Secret  |

{% tabs %}
{% tab title="Response" %}

| Parameter     | Type   | Description/Example                   |
| ------------- | ------ | ------------------------------------- |
| resCode       | String | <p>Response Code <br>200- Success</p> |
| resDesc       | String | Response Description                  |
| {% endtab %}  |        |                                       |
| {% endtabs %} |        |                                       |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.zortout.com/api-reference/document.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
