> 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 Document By ID

POST https://api.staple.io/v1/documents/{docId}/export

Select the export format and specify a doc ID to get the exported information.

If you are looking to get the json of the document, look at the 'Get Document by ID' endpoint instead.

Reference: https://docs.staple.ai/api-reference/v1/documents/export-document-by-id

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: v1
  version: 1.0.0
paths:
  /v1/documents/{docId}/export:
    post:
      operationId: exportDocumentById
      summary: Export Document By ID
      description: >-
        Select the export format and specify a doc ID to get the exported
        information.


        If you are looking to get the json of the document, look at the 'Get
        Document by ID' endpoint instead.
      tags:
        - documents
      parameters:
        - name: docId
          in: path
          required: true
          schema:
            type: string
        - name: x-api-key
          in: header
          description: API key issued by Staple.
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Documents_exportDocumentById_Response_200'
servers:
  - url: https://api.staple.io
    description: https://api.staple.io
components:
  schemas:
    Documents_exportDocumentById_Response_200:
      type: object
      properties: {}
      description: Empty response body
      title: Documents_exportDocumentById_Response_200
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: API key issued by Staple.
    bearerAuth:
      type: http
      scheme: bearer
      description: JWT obtained from the login endpoint.

```

## Examples



**Response**

```json
{
  "exportDocumentById": {
    "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\"\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\"",
    "docId": 1,
    "status": "COMPLETED"
  }
}
```

**SDK Code**

```python Export Document By ID
import requests

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

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

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

print(response.json())
```

```javascript Export Document By ID
const url = 'https://api.staple.io/v1/documents/docId/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 Document By ID
package main

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

func main() {

	url := "https://api.staple.io/v1/documents/docId/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 Document By ID
require 'uri'
require 'net/http'

url = URI("https://api.staple.io/v1/documents/docId/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 Document By ID
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

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

```php Export Document By ID
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

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

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

```csharp Export Document By ID
using RestSharp;

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

```swift Export Document By ID
import Foundation

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

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