> 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  Reconciliation Snapshot

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

Exports a full reconciliation snapshot for a primary doc across all configured secondary doc types under the given view.

##### Key nuances

1.  Header is represented as table\_name `header` with line\_id 0.
    
2.  Amount aggregation sums numeric values in when policy type includes “amount”; otherwise values are comma-joined; status is aggregated using worst-case.

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

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: v2
  version: 1.0.0
paths:
  /reconciliation/export:
    post:
      operationId: exportReconciliationSnapshot
      summary: Export  Reconciliation Snapshot
      description: >-
        Exports a full reconciliation snapshot for a primary doc across all
        configured secondary doc types under the given view.


        ##### Key nuances


        1.  Header is represented as table\_name `header` with line\_id 0.
            
        2.  Amount aggregation sums numeric values in when policy type includes
        “amount”; otherwise values are comma-joined; status is aggregated using
        worst-case.
      tags:
        - reconciliation
      parameters:
        - 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/Reconciliation_exportReconciliationSnapshot_Response_200
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                matching_collection_id:
                  type: integer
                doc_id:
                  type: string
                view_id:
                  type: string
                version:
                  type: integer
servers:
  - url: https://api.staple.io
    description: https://api.staple.io
components:
  schemas:
    Reconciliation_exportReconciliationSnapshot_Response_200:
      type: object
      properties: {}
      description: Empty response body
      title: Reconciliation_exportReconciliationSnapshot_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

### Export  Reconciliation Snapshot



**Request**

```json
undefined
```

**Response**

```json
{
  "collection_name": "Payables vs POs",
  "created_at": "2025-05-01T12:00:00Z",
  "last_execution_time": "2025-05-02T09:30:00Z",
  "secondary_docs": [
    {
      "match_rules": [
        {
          "id": "rule-1",
          "reconcile_rules": [
            {
              "id": "rr-1",
              "matches": [
                {
                  "source": {
                    "line_id": 1,
                    "table_name": "invoice_lines"
                  },
                  "target": {
                    "is_aggregated": false,
                    "is_force_reconciled": false,
                    "matched_rows": [
                      {
                        "doc_name": "po-1001.pdf",
                        "is_modified": false,
                        "line_id": 1,
                        "reconcile_status": "fully_reconciled",
                        "table_id": "po_lines",
                        "values": {
                          "POAmount": {
                            "value": "100.50"
                          },
                          "POLineNumber": {
                            "value": "10"
                          }
                        }
                      }
                    ],
                    "reconcile_status": "fully_reconciled",
                    "target_value": "100.50"
                  }
                },
                {
                  "source": {
                    "line_id": 2,
                    "table_name": "invoice_lines"
                  },
                  "target": {
                    "is_aggregated": true,
                    "is_force_reconciled": false,
                    "matched_rows": [
                      {
                        "doc_name": "po-1001.pdf",
                        "is_modified": false,
                        "line_id": 21,
                        "reconcile_status": "fully_reconciled",
                        "table_id": "po_lines",
                        "values": {
                          "POAmount": {
                            "value": "100.50"
                          },
                          "POLineNumber": {
                            "value": "20"
                          }
                        }
                      },
                      {
                        "doc_name": "po-1001.pdf",
                        "is_modified": false,
                        "line_id": 22,
                        "reconcile_status": "not_reconciled",
                        "table_id": "po_lines",
                        "values": {
                          "POAmount": {
                            "value": "50.25"
                          },
                          "POLineNumber": {
                            "value": "21"
                          }
                        }
                      }
                    ],
                    "reconcile_status": "partially_reconciled",
                    "target_value": "150.75"
                  }
                }
              ],
              "metadata": {
                "error": 0,
                "fully_reconciled": 1,
                "not_found": 0,
                "not_reconciled": 0,
                "partially_reconciled": 1,
                "total_count": 2
              },
              "reconcile_policy": {
                "options": {
                  "allow_negative": false,
                  "max_amount_diff": 0
                },
                "type": "match_amount_sum"
              },
              "source_field": "Amount",
              "target_field": "POAmount"
            }
          ]
        }
      ],
      "secondary_doc_type": "PO"
    }
  ],
  "source_document": {
    "data": [
      {
        "rows": [
          {
            "line_id": 0,
            "target_value": {
              "InvoiceDate": {
                "value": "2025-04-25"
              },
              "InvoiceNumber": {
                "value": "INV-20301"
              }
            }
          }
        ],
        "table_name": "header"
      },
      {
        "rows": [
          {
            "line_id": 1,
            "target_value": {
              "Amount": {
                "value": "100.50"
              },
              "LineID": {
                "value": "1"
              }
            }
          }
        ],
        "table_name": "Table 1"
      }
    ],
    "doc_id": "INV-20301",
    "doc_name": "inv-20301.pdf"
  }
}
```

**SDK Code**

```python Export  Reconciliation Snapshot
import requests

url = "https://api.staple.io/reconciliation/export"

headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Export  Reconciliation Snapshot
const url = 'https://api.staple.io/reconciliation/export';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: undefined
};

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

```go Export  Reconciliation Snapshot
package main

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

func main() {

	url := "https://api.staple.io/reconciliation/export"

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

	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 Export  Reconciliation Snapshot
require 'uri'
require 'net/http'

url = URI("https://api.staple.io/reconciliation/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'

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

```java Export  Reconciliation Snapshot
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

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

```php Export  Reconciliation Snapshot
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

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

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

```csharp Export  Reconciliation Snapshot
using RestSharp;

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

```swift Export  Reconciliation Snapshot
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]

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

### Reconciliation_exportReconciliationSnapshot_example



**Request**

```json
{
  "matching_collection_id": 123,
  "doc_id": "INV-20301",
  "view_id": "INVOICE_VIEW",
  "version": 1
}
```

**Response**

```json
{
  "collection_name": "Payables vs POs",
  "created_at": "2025-05-01T12:00:00Z",
  "last_execution_time": "2025-05-02T09:30:00Z",
  "secondary_docs": [
    {
      "match_rules": [
        {
          "id": "rule-1",
          "reconcile_rules": [
            {
              "id": "rr-1",
              "matches": [
                {
                  "source": {
                    "line_id": 1,
                    "table_name": "invoice_lines"
                  },
                  "target": {
                    "is_aggregated": false,
                    "is_force_reconciled": false,
                    "matched_rows": [
                      {
                        "doc_name": "po-1001.pdf",
                        "is_modified": false,
                        "line_id": 1,
                        "reconcile_status": "fully_reconciled",
                        "table_id": "po_lines",
                        "values": {
                          "POAmount": {
                            "value": "100.50"
                          },
                          "POLineNumber": {
                            "value": "10"
                          }
                        }
                      }
                    ],
                    "reconcile_status": "fully_reconciled",
                    "target_value": "100.50"
                  }
                },
                {
                  "source": {
                    "line_id": 2,
                    "table_name": "invoice_lines"
                  },
                  "target": {
                    "is_aggregated": true,
                    "is_force_reconciled": false,
                    "matched_rows": [
                      {
                        "doc_name": "po-1001.pdf",
                        "is_modified": false,
                        "line_id": 21,
                        "reconcile_status": "fully_reconciled",
                        "table_id": "po_lines",
                        "values": {
                          "POAmount": {
                            "value": "100.50"
                          },
                          "POLineNumber": {
                            "value": "20"
                          }
                        }
                      },
                      {
                        "doc_name": "po-1001.pdf",
                        "is_modified": false,
                        "line_id": 22,
                        "reconcile_status": "not_reconciled",
                        "table_id": "po_lines",
                        "values": {
                          "POAmount": {
                            "value": "50.25"
                          },
                          "POLineNumber": {
                            "value": "21"
                          }
                        }
                      }
                    ],
                    "reconcile_status": "partially_reconciled",
                    "target_value": "150.75"
                  }
                }
              ],
              "metadata": {
                "error": 0,
                "fully_reconciled": 1,
                "not_found": 0,
                "not_reconciled": 0,
                "partially_reconciled": 1,
                "total_count": 2
              },
              "reconcile_policy": {
                "options": {
                  "allow_negative": false,
                  "max_amount_diff": 0
                },
                "type": "match_amount_sum"
              },
              "source_field": "Amount",
              "target_field": "POAmount"
            }
          ]
        }
      ],
      "secondary_doc_type": "PO"
    }
  ],
  "source_document": {
    "data": [
      {
        "rows": [
          {
            "line_id": 0,
            "target_value": {
              "InvoiceDate": {
                "value": "2025-04-25"
              },
              "InvoiceNumber": {
                "value": "INV-20301"
              }
            }
          }
        ],
        "table_name": "header"
      },
      {
        "rows": [
          {
            "line_id": 1,
            "target_value": {
              "Amount": {
                "value": "100.50"
              },
              "LineID": {
                "value": "1"
              }
            }
          }
        ],
        "table_name": "Table 1"
      }
    ],
    "doc_id": "INV-20301",
    "doc_name": "inv-20301.pdf"
  }
}
```

**SDK Code**

```python Reconciliation_exportReconciliationSnapshot_example
import requests

url = "https://api.staple.io/reconciliation/export"

payload = {
    "matching_collection_id": 123,
    "doc_id": "INV-20301",
    "view_id": "INVOICE_VIEW",
    "version": 1
}
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Reconciliation_exportReconciliationSnapshot_example
const url = 'https://api.staple.io/reconciliation/export';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"matching_collection_id":123,"doc_id":"INV-20301","view_id":"INVOICE_VIEW","version":1}'
};

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

```go Reconciliation_exportReconciliationSnapshot_example
package main

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

func main() {

	url := "https://api.staple.io/reconciliation/export"

	payload := strings.NewReader("{\n  \"matching_collection_id\": 123,\n  \"doc_id\": \"INV-20301\",\n  \"view_id\": \"INVOICE_VIEW\",\n  \"version\": 1\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 Reconciliation_exportReconciliationSnapshot_example
require 'uri'
require 'net/http'

url = URI("https://api.staple.io/reconciliation/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  \"matching_collection_id\": 123,\n  \"doc_id\": \"INV-20301\",\n  \"view_id\": \"INVOICE_VIEW\",\n  \"version\": 1\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.staple.io/reconciliation/export")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"matching_collection_id\": 123,\n  \"doc_id\": \"INV-20301\",\n  \"view_id\": \"INVOICE_VIEW\",\n  \"version\": 1\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.staple.io/reconciliation/export', [
  'body' => '{
  "matching_collection_id": 123,
  "doc_id": "INV-20301",
  "view_id": "INVOICE_VIEW",
  "version": 1
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Reconciliation_exportReconciliationSnapshot_example
using RestSharp;

var client = new RestClient("https://api.staple.io/reconciliation/export");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"matching_collection_id\": 123,\n  \"doc_id\": \"INV-20301\",\n  \"view_id\": \"INVOICE_VIEW\",\n  \"version\": 1\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Reconciliation_exportReconciliationSnapshot_example
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "matching_collection_id": 123,
  "doc_id": "INV-20301",
  "view_id": "INVOICE_VIEW",
  "version": 1
] as [String : Any]

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

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