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

# Export Multiple Documents

POST https://api.staple.io/v1/documents/export
Content-Type: application/json

Select the export format and specify the doc IDs in an array to get the exported information. This function only supports exporting documents in the COMPLETED, EXPORT\_FAILED, EXPORTED tabs.

Reference: https://docs.staple.ai/api-reference/v1/documents/export-multiple-documents

## 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)

## Response

### 200

OK

## Examples

### Export Multiple Documents

**Request**

```json
undefined
```

**Response**

```json
{
  "exportDocumentByDocIds": {
    "data": "\"Name\",\"Engine Number\",\"Brand\",\"Color\",\"Plate Number\",\"Registration Date\",\"Expiry Date\",\"Expiry Year\",\"Expiry Month\",\"Address\",\"Model\",\"Frame Number\",\"ID Number\",\"First Place of Issue\",\"Second Place of Issue\",\"File Name\",\"Invoice Number\",\"PO Number\",\"Account Number\",\"Account Name\",\"Swift Code\",\"IBAN\",\"Email\",\"URL\",\"Total\",\"Subtotal\",\"Tax Total\",\"Currency\",\"Freight\",\"Billing Address\",\"Shipping Address\",\"Vendor Name\",\"Vendor Address\",\"Other Address\",\"Invoice Date\",\"Payment Date\",\"Other Date\"\n\"DƯƠNG NGỌC THÀ\",\"E-5118608\",\"HONDA\",\"Đỏ - Đen\",\"66P1-149.94\",\"2008-01-04\",,\"2013\",\"\",\"Phú Thọ | -Phú Thọ -TN- ĐT\",\"AIRBLADE\",\" Y618527\",\"010782\",\"CÔNG AN TỈNH ĐỒNG THÁP\",\"CÔNG AN HUYỆN TAM NÔNG\",\"3601.pdf\",,,,,,,,,,,,,,,,,,,,,\n,,,,,,,,,,,,,,,\"3606.pdf\",,,,,,,,,,,,,,,,,,,,,",
    "message": "Downloaded document successfully."
  }
}
```

**SDK Code**

```python Export Multiple Documents
import requests

url = "https://api.staple.io/v1/documents/export"

headers = {"x-api-key": "<apiKey>"}

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

print(response.json())
```

```javascript Export Multiple Documents
const url = 'https://api.staple.io/v1/documents/export';
const options = {method: 'POST', headers: {'x-api-key': '<apiKey>'}};

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

```go Export Multiple Documents
package main

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

func main() {

	url := "https://api.staple.io/v1/documents/export"

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

	req.Header.Add("x-api-key", "<apiKey>")

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

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

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

}
```

```ruby Export Multiple Documents
require 'uri'
require 'net/http'

url = URI("https://api.staple.io/v1/documents/export")

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

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<apiKey>'

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

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

HttpResponse<String> response = Unirest.post("https://api.staple.io/v1/documents/export")
  .header("x-api-key", "<apiKey>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.staple.io/v1/documents/export', [
  'headers' => [
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Export Multiple Documents
using RestSharp;

var client = new RestClient("https://api.staple.io/v1/documents/export");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift Export Multiple Documents
import Foundation

let headers = ["x-api-key": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.staple.io/v1/documents/export")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

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()
```

### Documents_exportMultipleDocuments_example

**Request**

```json
{
  "docIds": [
    1,
    2,
    3
  ]
}
```

**Response**

```json
{
  "exportDocumentByDocIds": {
    "data": "\"Name\",\"Engine Number\",\"Brand\",\"Color\",\"Plate Number\",\"Registration Date\",\"Expiry Date\",\"Expiry Year\",\"Expiry Month\",\"Address\",\"Model\",\"Frame Number\",\"ID Number\",\"First Place of Issue\",\"Second Place of Issue\",\"File Name\",\"Invoice Number\",\"PO Number\",\"Account Number\",\"Account Name\",\"Swift Code\",\"IBAN\",\"Email\",\"URL\",\"Total\",\"Subtotal\",\"Tax Total\",\"Currency\",\"Freight\",\"Billing Address\",\"Shipping Address\",\"Vendor Name\",\"Vendor Address\",\"Other Address\",\"Invoice Date\",\"Payment Date\",\"Other Date\"\n\"DƯƠNG NGỌC THÀ\",\"E-5118608\",\"HONDA\",\"Đỏ - Đen\",\"66P1-149.94\",\"2008-01-04\",,\"2013\",\"\",\"Phú Thọ | -Phú Thọ -TN- ĐT\",\"AIRBLADE\",\" Y618527\",\"010782\",\"CÔNG AN TỈNH ĐỒNG THÁP\",\"CÔNG AN HUYỆN TAM NÔNG\",\"3601.pdf\",,,,,,,,,,,,,,,,,,,,,\n,,,,,,,,,,,,,,,\"3606.pdf\",,,,,,,,,,,,,,,,,,,,,",
    "message": "Downloaded document successfully."
  }
}
```

**SDK Code**

```python Documents_exportMultipleDocuments_example
import requests

url = "https://api.staple.io/v1/documents/export"

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

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

print(response.json())
```

```javascript Documents_exportMultipleDocuments_example
const url = 'https://api.staple.io/v1/documents/export';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"docIds":[1,2,3]}'
};

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

```go Documents_exportMultipleDocuments_example
package main

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

func main() {

	url := "https://api.staple.io/v1/documents/export"

	payload := strings.NewReader("{\n  \"docIds\": [\n    1,\n    2,\n    3\n  ]\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 Documents_exportMultipleDocuments_example
require 'uri'
require 'net/http'

url = URI("https://api.staple.io/v1/documents/export")

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}"

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

```java Documents_exportMultipleDocuments_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

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

```php Documents_exportMultipleDocuments_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

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

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

```csharp Documents_exportMultipleDocuments_example
using RestSharp;

var client = new RestClient("https://api.staple.io/v1/documents/export");
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}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Documents_exportMultipleDocuments_example
import Foundation

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

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.staple.io/v1/documents/export")! 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()
```