> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lendpathway.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Exports

> Download underwriting CSVs and generate files from the spreadsheet gallery.

Pathway exposes a stable bank-underwriting CSV and a gallery of generated Excel and PDF templates. Gallery availability can vary by organization, so integrations should discover templates before requesting one by ID.

## List available templates

```http theme={null}
GET /parse/spreadsheet-templates
```

```python theme={null}
import requests

API_BASE = "https://api.lendpathway.com/api"
TOKEN = "pat_your_token_here"
headers = {"Authorization": f"Bearer {TOKEN}"}

response = requests.get(
    f"{API_BASE}/parse/spreadsheet-templates",
    headers=headers,
    timeout=30,
)
response.raise_for_status()

for template in response.json()["templates"]:
    print(template["id"], template["type"], template["format"])
```

```python theme={null}
from typing import Literal

from pydantic import BaseModel, Field


class SpreadsheetTemplate(BaseModel):
    id: str
    name: str
    type: Literal["mca", "credit_report", "tax"]
    format: Literal["excel", "pdf"]
    description: str


class SpreadsheetTemplatesConfig(BaseModel):
    templates: list[SpreadsheetTemplate] = Field(default_factory=list)
```

The response excludes private templates that do not belong to the token's organization.

### Public gallery

| ID                                 | Name                         | Data                                                              | Format |
| ---------------------------------- | ---------------------------- | ----------------------------------------------------------------- | ------ |
| `mca_stack_view`                   | MCA Stack View               | Bank statements and detected debt positions                       | Excel  |
| `mca_monthly_columns`              | MCA Monthly Columns          | Monthly deposits, true revenue, DTI, and payment analysis         | Excel  |
| `mca_stacking_pro`                 | Debt Stacking Drilldown      | Advances, schedules, remittance burden, misses, and modifications | Excel  |
| `mca_sample_bank_statement_report` | Sample Bank Statement Report | Rendered bank statement analysis                                  | PDF    |
| `vlad_full`                        | Credit Report Full           | Bureau tabs, FICO scores, accounts, utilization, and inquiries    | Excel  |
| `vlad_summary`                     | Credit Report Summary        | Compact score and account summary                                 | Excel  |
| `vlad_loc_scrub`                   | Credit Report LOC Scrub      | Revolving utilization, unsecured loans, and derogatory history    | Excel  |
| `tax_qualifying_income`            | Tax Qualifying Income        | Wages, Schedule C, pass-through entities, and qualifying income   | Excel  |

The discovery endpoint is authoritative. New public templates can appear without a client release.

## Download bank analytics as CSV

```http theme={null}
GET /books/{book_id}/csv-export
```

<ParamField query="table_format" type="string" default="month_as_row">
  `month_as_row` writes one row per statement period and account. `month_as_col` writes metrics as rows and statement periods as columns.
</ParamField>

<CodeGroup>
  ```python Python theme={null}
  from pathlib import Path
  import requests

  url = f"{API_BASE}/books/{BOOK_ID}/csv-export"
  response = requests.get(
      url,
      headers=headers,
      params={"table_format": "month_as_row"},
      timeout=60,
  )
  response.raise_for_status()

  Path("underwriting.csv").write_bytes(response.content)
  ```

  ```javascript JavaScript theme={null}
  import { writeFile } from "node:fs/promises";

  const url = new URL(`${API_BASE}/books/${BOOK_ID}/csv-export`);
  url.searchParams.set("table_format", "month_as_row");

  const response = await fetch(url, {
    headers: { Authorization: `Bearer ${TOKEN}` },
  });

  if (!response.ok) {
    throw new Error(`${response.status}: ${await response.text()}`);
  }

  await writeFile("underwriting.csv", Buffer.from(await response.arrayBuffer()));
  ```

  ```bash cURL theme={null}
  curl --fail-with-body \
    "https://api.lendpathway.com/api/books/{book_id}/csv-export?table_format=month_as_row" \
    -H "Authorization: Bearer pat_your_token_here" \
    --output underwriting.csv
  ```
</CodeGroup>

### `month_as_row`

The file contains individual account rows followed by `NET` and `Average` summary rows.

```text theme={null}
Period,Document,Account,Starting Balance,Deposits,Deposit Count,Withdrawals,Withdrawal Count,Ending Balance,Loan In,Loan Out,Avg Daily Balance,Days Negative,True Revenue,DTI %
Jan 2026,january.pdf,Business Checking,8149.06,101019.45,83,94510.22,106,14658.29,20000.00,12440.00,11281.33,0,81587.45,15.2%
NET,,1 Account,8149.06,101019.45,83,94510.22,106,14658.29,20000.00,12440.00,11281.33,0,81587.45,15.2%
Average,,1 Account,8149.06,101019.45,83,94510.22,106,14658.29,20000.00,12440.00,11281.33,0,81587.45,15.2%
```

### `month_as_col`

The file uses the combined cash row for each statement period.

```text theme={null}
Metric,Jan 2026,Feb 2026,Mar 2026
Starting Balance,8149.06,14658.29,12211.08
Deposits,101019.45,97004.12,108440.90
True Revenue,81587.45,79220.83,90118.70
DTI %,15.2%,13.8%,17.1%
```

Both formats use the same exclusions and analytics configuration as `GET /books/{book_id}/analytics`.

## Generate a gallery export

```http theme={null}
GET /books/{book_id}/spreadsheet-export
```

<ParamField query="sheet_type" type="string" required>
  `mca` for bank statement templates, `vlad` for credit report templates, or `tax` for tax templates.
</ParamField>

<ParamField query="template_id" type="string">
  A template returned by `GET /parse/spreadsheet-templates`. When omitted, Pathway uses the organization's default for that sheet type.
</ParamField>

```python theme={null}
from pathlib import Path
import requests

response = requests.get(
    f"{API_BASE}/books/{BOOK_ID}/spreadsheet-export",
    headers=headers,
    params={
        "sheet_type": "mca",
        "template_id": "mca_stacking_pro",
    },
    timeout=120,
)
response.raise_for_status()

content_type = response.headers.get("content-type", "")
suffix = ".pdf" if "pdf" in content_type else ".xlsx"
Path(f"deal{suffix}").write_bytes(response.content)
```

The chosen template must match `sheet_type` and must be visible to the token's organization.

<Tip>
  Omit `template_id` when you want the file to follow the default selected in Pathway settings. Pass an explicit ID when another system depends on a fixed layout.
</Tip>

## Get a browser-ready export

```http theme={null}
GET /books/{book_id}/spreadsheet-embed
```

This endpoint accepts the same `sheet_type` and `template_id` parameters. It generates the file, uploads a temporary copy, and returns URLs suitable for an embedded preview or download.

```python theme={null}
class SpreadsheetEmbedResponse(BaseModel):
    embed_url: str
    download_url: str
    drive_file_url: str | None = None
    drive_embed_url: str | None = None
    drive_synced_at: str | None = None
```

```python theme={null}
response = requests.get(
    f"{API_BASE}/books/{BOOK_ID}/spreadsheet-embed",
    headers=headers,
    params={"sheet_type": "vlad", "template_id": "vlad_full"},
    timeout=120,
)
response.raise_for_status()

print(response.json()["embed_url"])
```

`download_url` is temporary. Generate a new response when the old URL expires or when the Book changes.

## Response conditions

| Status | Meaning                                                                                            |
| ------ | -------------------------------------------------------------------------------------------------- |
| `400`  | The Book lacks the required parsed data, the sheet type is invalid, or the template does not match |
| `401`  | Missing or invalid PAT                                                                             |
| `403`  | The token cannot access the Book or the requested template                                         |
| `404`  | The Book or template does not exist                                                                |
| `500`  | The selected template could not be rendered                                                        |

For multi-file packaging and filename handling, see [Export data](/cookbook/export-data).
