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

GET https://api.staple.io/reconciliation/v1/linking-sets/{uuid}/document-sets/{id}/export

Downloads one document set as a file — the same documents, cards, and numbers as the reconcile details screen, snapshotted at the current result.

`format=json` (the default) returns the export document; `format=csv` returns the flattened form described below. `Content-Disposition` carries the filename, for example `INV-500.reconciliation.json`. Numbers are strings so quantities and amounts do not round.

The CSV form has 18 columns. Each comparison writes a `comparison` row (source value, compared value, remaining, excess and status), followed by one `match` row per matched target (`matches_document_identifier`, `matches_row_id`, `matches_value`). Use the `kind` column to tell them apart; columns that do not apply to a row are empty. Column names follow the JSON:

```csv
kind,document_identifier,row_id,name,comparison_rule_name,target_group_name,source_value,compared_value,remaining,excess,status,matches_document_identifier,matches_row_id,matches_value,fulfillment_claim_status,fulfillment_allocated_amount,fulfillment_residual_amount,fulfillment_competing_document_set_ids
comparison,INV-500,23,Quantity check,Qty vs Purchase order,Purchase order,50,50,,,RECONCILED,,,,,,,
match,INV-500,23,Quantity check,Qty vs Purchase order,Purchase order,,,,,,PO-500,23,50,,,,
```

The JSON body follows `staple.reconciliation.document-set.export/v1` (`https://schemas.staple.ai/reconciliation/document-set-export/v1`). New fields are additive, so check `schema` before parsing. The example below is a one-card, one-target export; the schema is the full contract.

Requires reconciliation v2 on the organisation; other tenants receive `404`.

Reference: https://docs.staple.ai/api-reference/v2/reconciliation/export-document-set

## Authentication

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

## Request

### Path parameters

- `uuid` (string, required) — Linking set UUID, as returned by List Linking Sets.
- `id` (string, required) — Document set ID, as returned by List Document Sets.

### Query parameters

- `format` (enum, optional, default: json) — Export format. Defaults to `json`.
  - Allowed values: `json`, `csv`

## Response

### 200

The export file. `Content-Disposition` carries the filename.

## Examples

**Response**

```json
{
  "cards": [
    {
      "card_id": "card-qty",
      "exception_count": 0,
      "field_columns": [
        {
          "comparison_row_id": "row-qty",
          "rules": [
            {
              "comparison_rule_uuid": "cr-qty-po",
              "evaluation_mode": "AGGREGATE",
              "name": "Qty vs Purchase order",
              "row_association_rule_uuid": "align-inv-po",
              "target_field_name": "Qty",
              "target_group_name": "Purchase order"
            }
          ],
          "source_field_key": "qty",
          "source_field_name": "Qty",
          "source_table_key": "line_items"
        }
      ],
      "layout": "LINE_ITEMS",
      "name": "Quantity check",
      "rows": [
        {
          "associations": [
            {
              "cardinality": "1:1",
              "edge_id": "ae-inv-po-23",
              "evidence_summary": "Matched on line number 23.",
              "manual_reason": null,
              "origin": "COMPUTED",
              "override": null,
              "result": "EFFECTIVE",
              "rule_name": "Invoice line to PO line",
              "rule_uuid": "align-inv-po",
              "target_boundary": "ROW"
            }
          ],
          "comparisons": [
            {
              "association_result": "EFFECTIVE",
              "atomic_result_id": "ar-5001",
              "comparison_rule_name": "Qty vs Purchase order",
              "comparison_rule_uuid": "cr-qty-po",
              "item_summary": null,
              "matches": [
                {
                  "document": {
                    "doc_id": 501,
                    "file_name": "po-500.pdf",
                    "group_name": "Purchase order",
                    "group_uuid": "a1111111-0000-4000-8000-000000000002",
                    "identifier": "PO-500",
                    "qid": 12
                  },
                  "field_values": [],
                  "fulfillment": null,
                  "location": {
                    "field_key": "qty",
                    "locus": "TABLE",
                    "row_id": "23",
                    "table_key": "line_items"
                  },
                  "value": "50"
                }
              ],
              "note": null,
              "numeric": {
                "compared_value": "50",
                "delta": "0",
                "excess": null,
                "remaining": null,
                "source_value": "50"
              },
              "outcomes": [
                {
                  "message": null,
                  "name": "RECONCILED",
                  "namespace": "SYSTEM"
                }
              ],
              "override": null,
              "predicate_status": "PASSED",
              "target": {
                "boundary": "ROW",
                "field_key": "qty",
                "field_name": "Qty",
                "group_name": "Purchase order",
                "table_key": "line_items"
              }
            }
          ],
          "document": {
            "doc_id": 500,
            "file_name": "invoice-500.pdf",
            "group_name": "Invoice",
            "group_uuid": "a1111111-0000-4000-8000-000000000001",
            "identifier": "INV-500",
            "qid": 7
          },
          "field_values": [
            {
              "field_key": "line_no",
              "table_key": "line_items",
              "value": "23"
            },
            {
              "field_key": "qty",
              "table_key": "line_items",
              "value": "50"
            }
          ],
          "labels": [],
          "location": {
            "locus": "TABLE",
            "row_id": "23",
            "table_key": "line_items"
          },
          "override": null,
          "status": "RECONCILED"
        }
      ],
      "source_group_name": "Invoice",
      "source_group_uuid": "a1111111-0000-4000-8000-000000000001"
    }
  ],
  "document_set": {
    "document_set_id": "ds:7c2a1b90-4d3e-4f81-9a0c-11b2c3d4e5f6:500",
    "exception_count": 0,
    "labels": [],
    "last_reconciled_at": "2026-01-10T09:00:04Z",
    "overall_status": "RECONCILED",
    "override": null,
    "state": "OPEN",
    "status_explanation": {
      "note": null,
      "precedence_order": [
        "system.ERROR",
        "system.NOT_FOUND",
        "system.NOT_RECONCILED",
        "system.NOT_RECONCILED",
        "system.RECONCILED"
      ],
      "seen_outcomes": [
        "system.RECONCILED"
      ],
      "winning_outcome": "system.RECONCILED"
    }
  },
  "export": {
    "export_id": "exp_01SIMPLE0000000000000001",
    "generated_at": "2026-08-20T16:30:00Z",
    "generated_by": {
      "actor_type": "USER",
      "email": "ap.controller@example.com",
      "user_id": "usr_4821"
    },
    "locale": "en-US",
    "timezone": "UTC"
  },
  "fulfillment_buckets": [],
  "linking_set": {
    "name": "Invoice 3-way match",
    "uuid": "7c2a1b90-4d3e-4f81-9a0c-11b2c3d4e5f6",
    "version": "2026-01-14"
  },
  "members": {
    "anchor": {
      "document": {
        "doc_id": 500,
        "file_name": "invoice-500.pdf",
        "group_name": "Invoice",
        "group_uuid": "a1111111-0000-4000-8000-000000000001",
        "identifier": "INV-500",
        "qid": 7
      },
      "field_values": [
        {
          "field_key": "invoice_no",
          "table_key": "__header__",
          "value": "INV-500"
        }
      ],
      "kind": "ANCHOR",
      "link_depth": 0,
      "link_evidence": [],
      "manual_reason": null,
      "origin": "COMPUTED",
      "override": null
    },
    "groups": [
      {
        "group_name": "Purchase order",
        "group_uuid": "a1111111-0000-4000-8000-000000000002",
        "members": [
          {
            "document": {
              "doc_id": 501,
              "file_name": "po-500.pdf",
              "group_name": "Purchase order",
              "group_uuid": "a1111111-0000-4000-8000-000000000002",
              "identifier": "PO-500",
              "qid": 12
            },
            "field_values": [
              {
                "field_key": "po_number",
                "table_key": "__header__",
                "value": "PO-500"
              }
            ],
            "kind": "DIRECT",
            "link_depth": 1,
            "link_evidence": [
              {
                "critical": true,
                "pass_label": "exact",
                "rule_name": "Invoice number on PO",
                "rule_uuid": "lr-invoice-po-number",
                "source_doc_id": 500
              }
            ],
            "manual_reason": null,
            "origin": "COMPUTED",
            "override": null
          }
        ]
      }
    ]
  },
  "overrides": [],
  "run": {
    "completed_at": "2026-01-10T09:00:04Z",
    "error_message": null,
    "run_id": "run_simple_one_target",
    "started_at": "2026-01-10T09:00:00Z",
    "status": "SUCCEEDED"
  },
  "schema": "staple.reconciliation.document-set.export/v1",
  "tenant": {
    "tenant_id": 282
  }
}
```

**SDK Code**

```python Export Document Set (JSON)
import requests

url = "https://api.staple.io/reconciliation/v1/linking-sets/7c2a1b90-4d3e-4f81-9a0c-11b2c3d4e5f6/document-sets/ds%3A7c2a1b90-4d3e-4f81-9a0c-11b2c3d4e5f6%3A500/export"

querystring = {"format":"json"}

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

response = requests.get(url, headers=headers, params=querystring)

print(response.json())
```

```javascript Export Document Set (JSON)
const url = 'https://api.staple.io/reconciliation/v1/linking-sets/7c2a1b90-4d3e-4f81-9a0c-11b2c3d4e5f6/document-sets/ds%3A7c2a1b90-4d3e-4f81-9a0c-11b2c3d4e5f6%3A500/export?format=json';
const options = {method: 'GET', 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 Set (JSON)
package main

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

func main() {

	url := "https://api.staple.io/reconciliation/v1/linking-sets/7c2a1b90-4d3e-4f81-9a0c-11b2c3d4e5f6/document-sets/ds%3A7c2a1b90-4d3e-4f81-9a0c-11b2c3d4e5f6%3A500/export?format=json"

	req, _ := http.NewRequest("GET", 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 Set (JSON)
require 'uri'
require 'net/http'

url = URI("https://api.staple.io/reconciliation/v1/linking-sets/7c2a1b90-4d3e-4f81-9a0c-11b2c3d4e5f6/document-sets/ds%3A7c2a1b90-4d3e-4f81-9a0c-11b2c3d4e5f6%3A500/export?format=json")

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

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

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

```java Export Document Set (JSON)
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.staple.io/reconciliation/v1/linking-sets/7c2a1b90-4d3e-4f81-9a0c-11b2c3d4e5f6/document-sets/ds%3A7c2a1b90-4d3e-4f81-9a0c-11b2c3d4e5f6%3A500/export?format=json")
  .header("x-api-key", "<apiKey>")
  .asString();
```

```php Export Document Set (JSON)
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.staple.io/reconciliation/v1/linking-sets/7c2a1b90-4d3e-4f81-9a0c-11b2c3d4e5f6/document-sets/ds%3A7c2a1b90-4d3e-4f81-9a0c-11b2c3d4e5f6%3A500/export?format=json', [
  'headers' => [
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Export Document Set (JSON)
using RestSharp;

var client = new RestClient("https://api.staple.io/reconciliation/v1/linking-sets/7c2a1b90-4d3e-4f81-9a0c-11b2c3d4e5f6/document-sets/ds%3A7c2a1b90-4d3e-4f81-9a0c-11b2c3d4e5f6%3A500/export?format=json");
var request = new RestRequest(Method.GET);
request.AddHeader("x-api-key", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift Export Document Set (JSON)
import Foundation

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.staple.io/reconciliation/v1/linking-sets/7c2a1b90-4d3e-4f81-9a0c-11b2c3d4e5f6/document-sets/ds%3A7c2a1b90-4d3e-4f81-9a0c-11b2c3d4e5f6%3A500/export?format=json")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
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()
```