> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.staple.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.staple.ai/_mcp/server.

# Download Multiple Documents Data

POST https://api.staple.io/v2/documents/download/data
Content-Type: application/json

Select the download format and specify the doc IDs in an array to get the downloaded information.

Reference: https://docs.staple.ai/api-reference/v2/documents/download-multiple-documents-data

## Authentication

- `x-api-key` header (required) — API key issued by Staple.
- `Authorization` header (bearer token, required) — JWT obtained from the login endpoint.

## Request

### Body (application/json)

- `docIds` (list of integer, optional)
- `docType` (string, optional)
- `language` (string, optional)
- `includeConfidence` (boolean, optional, default: false) — JSON and XML only — adds a "Confidence" block per document with scores for document fields, table column headers, table cells and each table (complex tables only). Has no effect on CSV and TXT. Must be true or false; any other value returns HTTP 400. Scores are 0–1 rounded to 2 decimals; null means unmeasured. Documents with no measured scores (predefined models such as Invoice, or documents scanned before confidence scoring existed) return "Confidence": null in JSON and an empty `<Confidence/>` element in XML — integrations must handle both forms. "Confidence" is a reserved key name.

## Response

### 200

OK

## Examples

### Download Multiple Documents Data

**Request**

```json
{
  "docIds": [
    1,
    2,
    3
  ],
  "docType": "JSON",
  "language": "EN"
}
```

**Response**

```json
{
  "downloadDataByDocIds": {
    "data": [
      {
        "Account Name": "",
        "Account Number": "",
        "Additional PO Numbers": "PO 3330",
        "Advance Tax": "",
        "BIR Number": "",
        "Bank Name": "",
        "Billing Address": "PAYMENT ADVICE     T / A Vistalite Central 19 Manuka Street  TAUPO 3330",
        "Comments": [],
        "Currency": "NZD",
        "Customer GST Number": "",
        "Customer Name": "Great Lake Aluminium & Glass Limited",
        "Delivery Order Number": "",
        "Description Text": "",
        "Discount": "",
        "Discount Percent": "",
        "Email": "admin@vistalitetaupo.co.nz - admin@vistalitetaupo.co",
        "Exchange Currency From": "NZD",
        "Exchange Currency To": "",
        "FX Rate": "",
        "File Name": "i4.pdf",
        "Form Number": "",
        "Freight": "",
        "Govt. Verification": "",
        "HSN SAC": "",
        "IBAN": "",
        "ISOCountryCode": "NZ",
        "Invoice Date": "2019-02-21",
        "Invoice Number": "INV-1441",
        "Invoice Type": "Tax Invoice",
        "Items": [
          {
            "Description": "Manufacture and install of 1 x bi fold",
            "Quantity": "1.00",
            "TableTitle": "Default Table",
            "UnitAmount": "2,000.00",
            "unmapped-text: Amount NZD0": "2,000.00"
          }
        ],
        "Less Amount Paid": "450.0",
        "Line Rows Check": "",
        "NTN": "",
        "Other Date": "",
        "PO Number": "",
        "Payment Date": "2019-03-08",
        "Payment Term": "07",
        "Project Name": "",
        "Public Lighting Tax": "",
        "Public Lighting Tax Percent": "",
        "Registered Vendor Name": "",
        "Registered Vendor Status": "",
        "RubberStamp": "",
        "Sales Order Number": "",
        "Sales Tax": "",
        "Sales Tax Percent": "",
        "Serial Number": "",
        "Shipping Address": "",
        "Signature": "",
        "Specific Tax": "",
        "Specific Tax Percent": "",
        "Subtotal": "2000.0",
        "Subtotal Check": "",
        "Swift Code": "",
        "Tax Percent": "15%",
        "Tax Total": "300.0",
        "Total": "2300.0",
        "Total Check": "",
        "Total Rounding": "",
        "URL": "",
        "Unique Stamp": "",
        "Vendor Address": "Great Lake Aluminium & Glass Limited T / A Vistalite Central 19 Manuka Street  TAUPO 3330 admin@vistalitetaupo.co.n",
        "Vendor Fax Number": "",
        "Vendor GST Number": "112-572-457",
        "Vendor Name": "Glass Limited T/A",
        "Vendor Name Check": "",
        "Vendor Phone Number": "",
        "Withholding Tax Total": ""
      },
      {
        "Account Name": "",
        "Account Number": "",
        "Additional PO Numbers": "PO 3330",
        "Advance Tax": "",
        "BIR Number": "",
        "Bank Name": "",
        "Billing Address": "PAYMENT ADVICE     T / A Vistalite Central 19 Manuka Street  TAUPO 3330",
        "Comments": [
          {
            "createdAt": "2022-11-30T04:13:06.765Z",
            "message": "Message 1",
            "receivers": [
              {
                "receiver": "staple@staple.io"
              }
            ],
            "sender": "staple@staple.io"
          },
          {
            "createdAt": "2022-11-30T04:15:43.958Z",
            "message": "Message 2",
            "receivers": [
              {
                "receiver": "staple@staple.io"
              }
            ],
            "sender": "staple@staple.io"
          },
          {
            "createdAt": "2022-11-30T04:17:51.142Z",
            "message": "Message 3",
            "receivers": [
              {
                "receiver": "staple@staple.io"
              }
            ],
            "sender": "staple@staple.io"
          }
        ],
        "Currency": "NZD",
        "Customer GST Number": "",
        "Customer Name": "Great Lake Aluminium & Glass Limited",
        "Delivery Order Number": "",
        "Description Text": "",
        "Discount": "",
        "Discount Percent": "",
        "Email": "admin@vistalitetaupo.co.nz - admin@vistalitetaupo.co",
        "Exchange Currency From": "NZD",
        "Exchange Currency To": "",
        "FX Rate": "",
        "File Name": "i4.pdf",
        "Form Number": "",
        "Freight": "",
        "Govt. Verification": "",
        "HSN SAC": "",
        "IBAN": "",
        "ISOCountryCode": "NZ",
        "Invoice Date": "2019-02-21",
        "Invoice Number": "INV-1441",
        "Invoice Type": "Tax Invoice",
        "Items": [
          {
            "Description": "Manufacture and install of 1 x bi fold",
            "Quantity": "1.00",
            "TableTitle": "Default Table",
            "UnitAmount": "2,000.00",
            "unmapped-text: Amount NZD0": "2,000.00"
          }
        ],
        "Less Amount Paid": "450.0",
        "Line Rows Check": "",
        "NTN": "",
        "Other Date": "",
        "PO Number": "",
        "Payment Date": "2019-03-08",
        "Payment Term": "07",
        "Project Name": "",
        "Public Lighting Tax": "",
        "Public Lighting Tax Percent": "",
        "Registered Vendor Name": "",
        "Registered Vendor Status": "",
        "RubberStamp": "",
        "Sales Order Number": "",
        "Sales Tax": "",
        "Sales Tax Percent": "",
        "Serial Number": "",
        "Shipping Address": "",
        "Signature": "",
        "Specific Tax": "",
        "Specific Tax Percent": "",
        "Subtotal": "2000.0",
        "Subtotal Check": "",
        "Swift Code": "",
        "Tax Percent": "15%",
        "Tax Total": "300.0",
        "Total": "2300.0",
        "Total Check": "",
        "Total Rounding": "",
        "URL": "",
        "Unique Stamp": "",
        "Vendor Address": "Great Lake Aluminium & Glass Limited T / A Vistalite Central 19 Manuka Street  TAUPO 3330 admin@vistalitetaupo.co.n",
        "Vendor Fax Number": "",
        "Vendor GST Number": "112-572-457",
        "Vendor Name": "Glass Limited T/A",
        "Vendor Name Check": "",
        "Vendor Phone Number": "",
        "Withholding Tax Total": ""
      },
      {
        "Account Name": "",
        "Account Number": "",
        "Additional PO Numbers": "",
        "Advance Tax": "",
        "BIR Number": "",
        "Bank Name": "",
        "Billing Address": "",
        "Comments": [],
        "Currency": "USD",
        "Customer GST Number": "",
        "Customer Name": "",
        "Delivery Order Number": "",
        "Description Text": "",
        "Discount": "",
        "Discount Percent": "",
        "Email": "herve@quod.ai",
        "Exchange Currency From": "USD",
        "Exchange Currency To": "",
        "FX Rate": "",
        "File Name": "re-in.pdf",
        "Form Number": "",
        "Freight": "",
        "Govt. Verification": "",
        "HSN SAC": "",
        "IBAN": "",
        "ISOCountryCode": "US",
        "Invoice Date": "2019-08-22",
        "Invoice Number": "21640",
        "Invoice Type": "Invoice",
        "Items": [
          {
            "TableTitle": "Default Table",
            "TaxRate": "USD 35",
            "UnitAmount": "USD 160.30",
            "unmapped-text: Hours1": "4.58 h",
            "unmapped-text: Projects0": "37972-Improve Existing Presentation Date: 22/Aug/2019-02/Sep/2019 Customer: herve@quod.ai"
          },
          {
            "LineAmount": "USD 160.30",
            "Other": "CREDITCARD Date: 03/09/2019",
            "TableTitle": "Default Table"
          }
        ],
        "Less Amount Paid": "",
        "Line Rows Check": "",
        "NTN": "",
        "Other Date": "2019-08-22",
        "PO Number": "",
        "Payment Date": "2019-09-17",
        "Payment Term": "",
        "Project Name": "",
        "Public Lighting Tax": "",
        "Public Lighting Tax Percent": "",
        "Registered Vendor Name": "",
        "Registered Vendor Status": "",
        "RubberStamp": "",
        "Sales Order Number": "",
        "Sales Tax": "",
        "Sales Tax Percent": "",
        "Serial Number": "",
        "Shipping Address": "",
        "Signature": "",
        "Specific Tax": "",
        "Specific Tax Percent": "",
        "Subtotal": "",
        "Subtotal Check": "",
        "Swift Code": "",
        "Tax Percent": "",
        "Tax Total": "",
        "Total": "160.3",
        "Total Check": "",
        "Total Rounding": "",
        "URL": "",
        "Unique Stamp": "",
        "Vendor Address": "Konsus Inc  EIN : 61-1776321 470 Ramona Street Palo Alto CA 94301 United States",
        "Vendor Fax Number": "",
        "Vendor GST Number": "",
        "Vendor Name": "",
        "Vendor Name Check": "",
        "Vendor Phone Number": "",
        "Withholding Tax Total": ""
      }
    ],
    "message": "Downloaded document successfully."
  }
}
```

**SDK Code**

```python Download Multiple Documents Data
import requests

url = "https://api.staple.io/v2/documents/download/data"

payload = {
    "docIds": [1, 2, 3],
    "docType": "JSON",
    "language": "EN"
}
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Download Multiple Documents Data
const url = 'https://api.staple.io/v2/documents/download/data';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"docIds":[1,2,3],"docType":"JSON","language":"EN"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Download Multiple Documents Data
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.staple.io/v2/documents/download/data"

	payload := strings.NewReader("{\n  \"docIds\": [\n    1,\n    2,\n    3\n  ],\n  \"docType\": \"JSON\",\n  \"language\": \"EN\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Download Multiple Documents Data
require 'uri'
require 'net/http'

url = URI("https://api.staple.io/v2/documents/download/data")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"docIds\": [\n    1,\n    2,\n    3\n  ],\n  \"docType\": \"JSON\",\n  \"language\": \"EN\"\n}"

response = http.request(request)
puts response.read_body
```

```java Download Multiple Documents Data
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.staple.io/v2/documents/download/data")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"docIds\": [\n    1,\n    2,\n    3\n  ],\n  \"docType\": \"JSON\",\n  \"language\": \"EN\"\n}")
  .asString();
```

```php Download Multiple Documents Data
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.staple.io/v2/documents/download/data', [
  'body' => '{
  "docIds": [
    1,
    2,
    3
  ],
  "docType": "JSON",
  "language": "EN"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Download Multiple Documents Data
using RestSharp;

var client = new RestClient("https://api.staple.io/v2/documents/download/data");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"docIds\": [\n    1,\n    2,\n    3\n  ],\n  \"docType\": \"JSON\",\n  \"language\": \"EN\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Download Multiple Documents Data
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "docIds": [1, 2, 3],
  "docType": "JSON",
  "language": "EN"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.staple.io/v2/documents/download/data")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### With Confidence Scores (includeConfidence: true)

**Request**

```json
{
  "docIds": [
    1
  ],
  "docType": "JSON",
  "language": "EN",
  "includeConfidence": true
}
```

**Response**

```json
{
  "downloadDataByDocIds": {
    "data": [
      {
        "Confidence": {
          "Fields": {
            "Invoice Number": {
              "confidence": 0.96,
              "extraction_confidence": 0.97,
              "ocr_confidence": 0.96
            }
          },
          "Tables": [
            {
              "Headers": {
                "Description": {
                  "confidence": 0.98,
                  "extraction_confidence": null,
                  "ocr_confidence": 0.98
                },
                "PD Code": {
                  "confidence": 0,
                  "extraction_confidence": null,
                  "ocr_confidence": null
                }
              },
              "Items": [
                {
                  "Description": {
                    "confidence": 0.99,
                    "extraction_confidence": 0.99,
                    "ocr_confidence": 0.99
                  },
                  "ItemIndex": 0,
                  "PD Code": {
                    "confidence": 0,
                    "extraction_confidence": 0,
                    "ocr_confidence": 0
                  }
                },
                {
                  "Description": {
                    "confidence": 0.97,
                    "extraction_confidence": 0.97,
                    "ocr_confidence": 0.97
                  },
                  "ItemIndex": 1,
                  "PD Code": {
                    "confidence": 0,
                    "extraction_confidence": 0,
                    "ocr_confidence": 0
                  }
                }
              ],
              "TableIndex": 0,
              "TableTitle": "LINE ITEMS",
              "header_confidence": 1
            },
            {
              "Headers": {
                "Tax Amount": {
                  "confidence": 0.88,
                  "extraction_confidence": 0.9,
                  "ocr_confidence": 0.88
                },
                "Tax Code": {
                  "confidence": 0.86,
                  "extraction_confidence": 0.89,
                  "ocr_confidence": 0.86
                }
              },
              "Items": [
                {
                  "ItemIndex": 2,
                  "Tax Amount": {
                    "confidence": 0.9,
                    "extraction_confidence": 0.9,
                    "ocr_confidence": 0.9
                  },
                  "Tax Code": {
                    "confidence": 0.87,
                    "extraction_confidence": 0.87,
                    "ocr_confidence": 0.87
                  }
                }
              ],
              "TableIndex": 1,
              "TableTitle": "TAX SUMMARY",
              "header_confidence": 0.89
            }
          ]
        },
        "File Name": "invoice_complex_multi_table.pdf",
        "Invoice Number": "INV-003",
        "Items": [
          {
            "Description": "Tamagotchi",
            "PD Code": "14001519_KG",
            "TableTitle": "LINE ITEMS"
          },
          {
            "Description": "Coca Cola",
            "PD Code": "14001924_KG",
            "TableTitle": "LINE ITEMS"
          },
          {
            "TableTitle": "TAX SUMMARY",
            "Tax Amount": "58.77",
            "Tax Code": "SR"
          }
        ],
        "Labels": []
      }
    ],
    "message": "Downloaded document successfully."
  }
}
```

**SDK Code**

```python With Confidence Scores (includeConfidence: true)
import requests

url = "https://api.staple.io/v2/documents/download/data"

payload = {
    "docIds": [1],
    "docType": "JSON",
    "language": "EN",
    "includeConfidence": True
}
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript With Confidence Scores (includeConfidence: true)
const url = 'https://api.staple.io/v2/documents/download/data';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"docIds":[1],"docType":"JSON","language":"EN","includeConfidence":true}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go With Confidence Scores (includeConfidence: true)
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.staple.io/v2/documents/download/data"

	payload := strings.NewReader("{\n  \"docIds\": [\n    1\n  ],\n  \"docType\": \"JSON\",\n  \"language\": \"EN\",\n  \"includeConfidence\": true\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby With Confidence Scores (includeConfidence: true)
require 'uri'
require 'net/http'

url = URI("https://api.staple.io/v2/documents/download/data")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"docIds\": [\n    1\n  ],\n  \"docType\": \"JSON\",\n  \"language\": \"EN\",\n  \"includeConfidence\": true\n}"

response = http.request(request)
puts response.read_body
```

```java With Confidence Scores (includeConfidence: true)
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.staple.io/v2/documents/download/data")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"docIds\": [\n    1\n  ],\n  \"docType\": \"JSON\",\n  \"language\": \"EN\",\n  \"includeConfidence\": true\n}")
  .asString();
```

```php With Confidence Scores (includeConfidence: true)
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.staple.io/v2/documents/download/data', [
  'body' => '{
  "docIds": [
    1
  ],
  "docType": "JSON",
  "language": "EN",
  "includeConfidence": true
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp With Confidence Scores (includeConfidence: true)
using RestSharp;

var client = new RestClient("https://api.staple.io/v2/documents/download/data");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"docIds\": [\n    1\n  ],\n  \"docType\": \"JSON\",\n  \"language\": \"EN\",\n  \"includeConfidence\": true\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift With Confidence Scores (includeConfidence: true)
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "docIds": [1],
  "docType": "JSON",
  "language": "EN",
  "includeConfidence": true
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.staple.io/v2/documents/download/data")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```