# GET /crm/export

**Resource:** [CRM Export](./crm-export.md)  
**Scopes:** `contacts:read`, `companies:read`, `opportunities:read`, `work-orders:read`  
**Write operation:** no

Export CRM data as a downloadable file. Returns the file as an attachment (XLSX or CSV). Custom fields from company_settings are appended as dynamic columns. Work-order dynamic fields come from crm_work_order_fields. Response headers include X-Row-Count (actual rows returned) and X-Truncated (1 if the 50,000-row cap was hit).

## Parameters

| Name | In | Type | Required | Description |
|------|----|------|----------|-------------|
| `type` | query | string | yes | Entity type to export. One of: contacts, customers, deals, work-orders. The caller must hold the matching read scope for the chosen type. |
| `format` | query | string | no | File format. One of: xlsx (default), csv. |
| `search` | query | string | no | Text search. Contacts: first_name, last_name, email, phone, landline. Customers: name, email, phone, landline. Deals: name only. Not available for work-orders. |
| `created_after` | query | string | no | ISO 8601 datetime. Return records created on or after this timestamp. |
| `created_before` | query | string | no | ISO 8601 datetime. Return records created on or before this timestamp. |
| `source` | query | string | no | (contacts only) Filter by lead source string. |
| `customer_id` | query | uuid | no | (contacts, deals) Filter contacts linked to this customer, or deals belonging to this customer. |
| `email_unsubscribed` | query | string | no | (contacts only) true = opted-out contacts only, false = opted-in contacts only. |
| `sms_unsubscribed` | query | string | no | (contacts only) true = opted-out contacts only, false = opted-in contacts only. |
| `is_customer` | query | string | no | (customers only) true = is a customer, false = is not. |
| `is_supplier` | query | string | no | (customers only) true = is a supplier, false = is not. |
| `industry` | query | string | no | (customers only) Exact industry match. |
| `status` | query | string | no | (deals only) Filter by deal status. Valid values: open, won, lost. |
| `pipeline_id` | query | uuid | no | (deals only) Filter deals that are placed in this pipeline. |
| `stage_id` | query | uuid | no | (deals only) Filter deals that are placed in this specific stage. |
| `contact_id` | query | uuid | no | (deals only) Filter deals linked to this contact. |
| `assigned_to` | query | uuid | no | (deals, work-orders) Filter by assigned user UUID. |
| `status_id` | query | uuid | no | (work-orders only) Filter by work order status UUID. |
| `deal_product_id` | query | uuid | no | (work-orders only) Filter by deal product UUID. |
| `schedule_date` | query | string | no | (work-orders only) Exact date match (YYYY-MM-DD). |

## Response example

```json
{
  "request": "curl -H \"Authorization: Bearer tp_live_...\" \\\n  \"https://api.trustpager.com/functions/v1/api/v1/crm/export?type=contacts&format=xlsx\" \\\n  --output contacts.xlsx",
  "response": "# Binary XLSX file download.\n# Response headers:\n# Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\n# Content-Disposition: attachment; filename=\"contacts-2026-04-27T10-30-00.xlsx\"\n# X-Row-Count: 294\n# X-Truncated: 0"
}
```

---
Base URL: `https://api.trustpager.com/functions/v1/api/v1` — Auth: `Authorization: Bearer YOUR_API_KEY`