> 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 Audit Trail

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

Downloads the full audit trail of one document set as CSV, with the same filters as List Document Set Audit Trail and no paging. An entry with several targets repeats its `Entry ID` on each line. Text is never truncated.

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

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

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

- `id` (string, required) — Document set ID (`document_set_id` from List Document Sets), URL-encoded.

### Query parameters

- `action` (list of string, optional) — Filter by action, for example `force_accept.accepted`. Repeat the parameter or pass a comma-separated list. Combined with `category` by OR.
- `category` (list of string, optional) — Filter by action category (the part before the dot), for example `force_accept`.
- `from` (datetime, optional) — Only entries at or after this time (ISO 8601 date-time).
- `to` (datetime, optional) — Only entries at or before this time (ISO 8601 date-time).
- `user_id` (integer, optional) — Only entries performed by this user ID.
- `tz` (string, optional) — IANA time zone for the local date-time column. Defaults to UTC.

## Response

### 200

CSV file, one line per target. `Content-Disposition` carries the filename.

## Examples

**Response**

```json
{}
```

**SDK Code**

```python
import requests

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

querystring = {"action":"[\"force_accept.accepted\"]","category":"[\"force_accept\"]","from":"2026-01-01T00:00:00Z","to":"2026-01-31T23:59:59Z","tz":"Asia/Kolkata","user_id":"4821"}

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

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

print(response.json())
```

```javascript
const url = 'https://api.staple.io/reconciliation/v1/document-sets/ds%3A7c2a1b90-4d3e-4f81-9a0c-11b2c3d4e5f6%3A500/audit/export?action=%5B%22force_accept.accepted%22%5D&category=%5B%22force_accept%22%5D&from=2026-01-01T00%3A00%3A00Z&to=2026-01-31T23%3A59%3A59Z&tz=Asia%2FKolkata&user_id=4821';
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
package main

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

func main() {

	url := "https://api.staple.io/reconciliation/v1/document-sets/ds%3A7c2a1b90-4d3e-4f81-9a0c-11b2c3d4e5f6%3A500/audit/export?action=%5B%22force_accept.accepted%22%5D&category=%5B%22force_accept%22%5D&from=2026-01-01T00%3A00%3A00Z&to=2026-01-31T23%3A59%3A59Z&tz=Asia%2FKolkata&user_id=4821"

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

url = URI("https://api.staple.io/reconciliation/v1/document-sets/ds%3A7c2a1b90-4d3e-4f81-9a0c-11b2c3d4e5f6%3A500/audit/export?action=%5B%22force_accept.accepted%22%5D&category=%5B%22force_accept%22%5D&from=2026-01-01T00%3A00%3A00Z&to=2026-01-31T23%3A59%3A59Z&tz=Asia%2FKolkata&user_id=4821")

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
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.staple.io/reconciliation/v1/document-sets/ds%3A7c2a1b90-4d3e-4f81-9a0c-11b2c3d4e5f6%3A500/audit/export?action=%5B%22force_accept.accepted%22%5D&category=%5B%22force_accept%22%5D&from=2026-01-01T00%3A00%3A00Z&to=2026-01-31T23%3A59%3A59Z&tz=Asia%2FKolkata&user_id=4821")
  .header("x-api-key", "<apiKey>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.staple.io/reconciliation/v1/document-sets/ds%3A7c2a1b90-4d3e-4f81-9a0c-11b2c3d4e5f6%3A500/audit/export?action=%5B%22force_accept.accepted%22%5D&category=%5B%22force_accept%22%5D&from=2026-01-01T00%3A00%3A00Z&to=2026-01-31T23%3A59%3A59Z&tz=Asia%2FKolkata&user_id=4821', [
  'headers' => [
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.staple.io/reconciliation/v1/document-sets/ds%3A7c2a1b90-4d3e-4f81-9a0c-11b2c3d4e5f6%3A500/audit/export?action=%5B%22force_accept.accepted%22%5D&category=%5B%22force_accept%22%5D&from=2026-01-01T00%3A00%3A00Z&to=2026-01-31T23%3A59%3A59Z&tz=Asia%2FKolkata&user_id=4821");
var request = new RestRequest(Method.GET);
request.AddHeader("x-api-key", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.staple.io/reconciliation/v1/document-sets/ds%3A7c2a1b90-4d3e-4f81-9a0c-11b2c3d4e5f6%3A500/audit/export?action=%5B%22force_accept.accepted%22%5D&category=%5B%22force_accept%22%5D&from=2026-01-01T00%3A00%3A00Z&to=2026-01-31T23%3A59%3A59Z&tz=Asia%2FKolkata&user_id=4821")! 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()
```