# Export Report — Expensify

> Export Expensify reports to a file (csv, xls, xlsx, txt, pdf, json, xml). See the documentation

- Key: `expensify-export-report`
- Type: Action (Write)
- Version: 0.0.4
- App: Expensify (`expensify`) — https://pipedream.com/apps/expensify.md
- This page (HTML): https://pipedream.com/apps/expensify/actions/export-report
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/expensify/actions/export-report/export-report.ts

## Description

Export Expensify reports to a file (csv, xls, xlsx, txt, pdf, json, xml). [See the documentation](https://integrations.expensify.com/Integration-Server/doc/#report-exporter)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `reportIds` | `string[]` | No | The IDs of the reports to be exported. Required if startDate or approvedAfter are not specified. |
| `startDate` | `string` | No | The start date of the report. Format: YYYY-MM-DD. Required if reportIds or approvedAfter are not specified. |
| `endDate` | `string` | No | The end date of the report. Format: YYYY-MM-DD. Conditionally required, if either startDate or approvedAfter is more than one year ago. |
| `approvedAfter` | `string` | No | Filters out all reports approved before the given date, whichever occurred last (inclusive). Required if reportIds or startDate are not specified |
| `fileExtension` | `string` | Yes | The format of the generated file. xlsx, xls, and pdf work on their own. csv, txt, json, and xml require a Template Path (a Freemarker template file in /tmp) — if you don't have one, choose xlsx. |
| `markedAsExported` | `string` | No | Filters out reports that have already been exported with that label |
| `reportStates` | `string[]` | No | Only the reports matching the specified status(es) will be exported |
| `employeeEmail` | `string` | No | Export reports for the specified employee email |
| `policyIds` | `string[]` | No | The IDs of the policies to filter by. Run List Policies first to obtain valid IDs. Options are loaded from the connected account. |
| `fileBaseName` | `string` | No | The base name of the file to be exported |
| `includeFullPageReceiptsPdf` | `boolean` | No | Specifies whether generated PDFs should include full page receipts. This parameter is used only if fileExtension contains pdf. |
| `emailRecipients` | `string[]` | No | People to email at the end of the export |
| `markAsExported` | `string` | No | Mark the reports as exported with the given label |
| `templatePath` | `string` | No | The path in the /tmp directory to the template to use for the export. Required if fileExtension is csv, txt, json, or xml. |
| `limit` | `string` | No | Maximum number of reports to export |
| `test` | `boolean` | No | If set to true, actions defined in onFinish (i.e. email, markAsExported) will not be executed |
| `syncDir` | `dir` | Yes | SyncDir |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "expensify",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "expensify-export-report",
  arguments: {
    reportIds: ["Report IDs"],
    startDate: "Start Date",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "expensify-export-report",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    expensify: { authProvisionId: "apn_xxxxxxx" },
    reportIds: ["Report IDs"],
    startDate: "Start Date",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "expensify-export-report",
    "configured_props": {
      "expensify": { "authProvisionId": "apn_xxxxxxx" },
      "reportIds": ["Report IDs"],
      "startDate": "Start Date"
    }
  }'
```

---

- App: https://pipedream.com/apps/expensify.md · All apps: https://pipedream.com/apps
