# CRM export file format

A CRM export is different from the plain [lead](https://heymysocial.com/docs/files/leads) and [sales](https://heymysocial.com/docs/files/sales) files: every row carries the CRM's own id, and the file is reconciled against what HeyMySocial already knows. Upload it as often as you like. It catches whatever a webhook missed, and for a CRM that can only export it is the whole connection.

Each row goes through the same reconciler as a record from the [inbound webhook](https://heymysocial.com/docs/webhooks/crm-inbound) or the API, so the rules below are the same on all three routes. The ready-made HubSpot and Pipedrive connector is built but switched off; the file and the webhook are what work today.

## Columns

<div class="table-scroll"><table><thead><tr><th>Column</th><th>File</th><th>Needed</th><th>What it is</th></tr></thead><tbody><tr><th scope="row"><code style="white-space:nowrap">external_id</code></th><td>Both</td><td>Yes</td><td>The CRM&#039;s own id of the record. The heading may also be id.</td></tr><tr><th scope="row"><code style="white-space:nowrap">updated_at</code></th><td>Both</td><td>Optional</td><td>When the record last changed in the CRM. Left empty, the moment of the import is used. An older record never overwrites a newer one.</td></tr><tr><th scope="row"><code style="white-space:nowrap">status</code></th><td>Leads</td><td>Optional</td><td>The lead&#039;s status in the CRM&#039;s own words. It is translated with the connection&#039;s status mapping; a status with no mapping is listed for review and the lead keeps its status here.</td></tr><tr><th scope="row"><code style="white-space:nowrap">reason</code></th><td>Leads</td><td>Optional</td><td>Why the lead was disqualified or lost.</td></tr><tr><th scope="row"><code style="white-space:nowrap">contact_external_id</code></th><td>Leads</td><td>Optional</td><td>The CRM&#039;s id of the contact behind the lead.</td></tr><tr><th scope="row"><code style="white-space:nowrap">lead_ref</code></th><td>Leads</td><td>Optional</td><td>The lead&#039;s id in HeyMySocial, when the CRM already holds it. The record is tied to exactly that lead.</td></tr><tr><th scope="row"><code style="white-space:nowrap">name</code></th><td>Leads</td><td>Optional</td><td>The person&#039;s name.</td></tr><tr><th scope="row"><code style="white-space:nowrap">email</code></th><td>Leads</td><td>Optional</td><td>Their email address. An open lead that is already here for the same address is linked, not doubled.</td></tr><tr><th scope="row"><code style="white-space:nowrap">phone</code></th><td>Leads</td><td>Optional</td><td>Their phone number.</td></tr><tr><th scope="row"><code style="white-space:nowrap">company</code></th><td>Leads</td><td>Optional</td><td>The company they belong to.</td></tr><tr><th scope="row"><code style="white-space:nowrap">captured_at</code></th><td>Leads</td><td>Optional</td><td>When the lead arrived. Left empty: updated_at.</td></tr><tr><th scope="row"><code style="white-space:nowrap">first_contacted_at</code></th><td>Leads</td><td>Optional</td><td>When the lead was first contacted.</td></tr><tr><th scope="row"><code style="white-space:nowrap">lead_external_id</code></th><td>Sales</td><td>This or lead_ref</td><td>The CRM&#039;s id of the lead the sale belongs to. The lead must have been imported first.</td></tr><tr><th scope="row"><code style="white-space:nowrap">lead_ref</code></th><td>Sales</td><td>This or lead_external_id</td><td>The lead&#039;s id in HeyMySocial.</td></tr><tr><th scope="row"><code style="white-space:nowrap">opportunity_external_id</code></th><td>Sales</td><td>Optional</td><td>The CRM&#039;s id of the opportunity the sale closes.</td></tr><tr><th scope="row"><code style="white-space:nowrap">amount</code></th><td>Sales</td><td>This or amount_minor</td><td>The amount in the currency&#039;s main unit, written with a dot or a comma. A negative amount is a refund.</td></tr><tr><th scope="row"><code style="white-space:nowrap">amount_minor</code></th><td>Sales</td><td>This or amount</td><td>The amount as a whole number of the currency&#039;s smallest unit.</td></tr><tr><th scope="row"><code style="white-space:nowrap">currency</code></th><td>Sales</td><td>Yes</td><td>A three-letter currency code.</td></tr><tr><th scope="row"><code style="white-space:nowrap">occurred_at</code></th><td>Sales</td><td>Optional</td><td>When the sale happened. Left empty: updated_at.</td></tr><tr><th scope="row"><code style="white-space:nowrap">kind</code></th><td>Sales</td><td>Optional</td><td>sale or refund. Left empty, the sign of the amount decides.</td></tr><tr><th scope="row"><code style="white-space:nowrap">revenue_basis</code></th><td>Sales</td><td>Optional</td><td>booked, invoiced or collected.</td></tr><tr><th scope="row"><code style="white-space:nowrap">note</code></th><td>Sales</td><td>Optional</td><td>A note kept on the sale.</td></tr></tbody></table></div>

A file holds either leads or sales, never both. Unlike the other imports there is no column step on the screen. Columns are matched by name: capital letters do not matter, and spaces and dashes count as underscores, so `Lead Status` and `lead_status` are the same. A column with another name is brought in through the connection's field mapping (see below), and a column that is neither known nor mapped is ignored.

- Every file needs `external_id`, the CRM's own id for the row. A column called `id` is accepted instead.
- `updated_at` is optional: when the row last changed in the CRM. Without it every row counts as changed at the moment of the upload.

## Rules for a lead row

- **A lead the connection has not seen** is matched before it is created. `lead_ref` may hold HeyMySocial's own id of the lead and links the row straight to it. Otherwise the contact is looked up by `contact_external_id` or by the exact email address. If that contact has one open lead here that the CRM is not linked to yet, the row is linked to it, because the same person usually reached you through the website first. Linking to an existing lead this way can be switched off under **Mapping**.
- **A new lead** needs a known contact or contact details of its own (name, email, phone or company). It is created with the row's status, or as new, and with `captured_at` as the day it arrived.
- **Status** is translated through the connection's status mapping, then through a list of common CRM words that are understood without one. A status found in neither is not guessed: the rest of the row is applied, the lead keeps its status here, and the row is listed so you can add the mapping.
- **Newest wins.** When the CRM's status is newer than the one here, it is applied, with `reason` if the row has one. When it is older, the status here stays and the CRM's value is kept in the lead's timeline.
- **First contact.** `first_contacted_at` only fills an empty first-contact time. For a lead that already exists here, the time it arrived and the campaign it came from are never changed by a CRM.

## Rules for a sale row

- **Its lead** must be known: `lead_external_id` is the CRM id of a lead this connection has already linked, or `lead_ref` is HeyMySocial's id of the lead. A sale whose lead is not known is listed as an error and applied when you upload it again after the lead.
- **Amount and currency** are both needed. `amount` is in major units and may be written `48500.00`, `48.500,00` or `48,500.00`; `amount_minor` is a whole number of minor units instead. The currency is a three-letter code.
- **Refunds.** A negative amount is stored as a refund unless `kind` says otherwise.
- **Date.** `occurred_at` is the day of the sale; without it the row's `updated_at` is used.
- **The CRM owns sales.** When a sale with the same id comes again with other numbers, the CRM's numbers replace the ones here.

Write dates in the form `2026-04-22` or `2026-04-22T10:00:00Z`. They are read as UTC when they carry no offset.

## Mapping your CRM's words

On the connection's page, the card **Mapping** has two lists. **Statuses** pairs a status in the CRM with a status here; the card also shows the statuses that are understood without a mapping. **Fields** pairs a field in the CRM with a field here, per kind of record, so an export with a column called `Stage` can feed `status` without editing the file. Press **Save the mapping** before you upload.

The seven statuses a CRM status can map to are described under [lead statuses](https://heymysocial.com/docs/reference/lead-statuses).

## Uploading the same file again

A sale row with the same content as last time changes nothing, and a row that is older than what the connection already has is not applied. A lead row without `updated_at` counts as changed at the moment of the upload, so it puts the CRM's status back on a lead whose status was changed here in the meantime. With `updated_at` in the file, the same export twice, or an older export after a newer one, does no harm.

For a lead file you can tick **This is a full export**. Leads the connection has linked that are missing from the file are then reported, because they may have been deleted or merged in the CRM. Nothing is deleted here.

## Sample

The rows are made up. A lead file, where `In progress` is one of the words understood as contacted:

```csv
external_id,status,name,email,company,updated_at
C-501,Qualified,Anna Example,anna@example.com,Example Roofing ApS,2026-04-20T10:00:00Z
C-502,In progress,Bo Sample,bo@example.org,Sample Carpentry,2026-04-21T08:30:00Z
```

A sales file, naming the lead by its CRM id:

```csv
external_id,lead_external_id,amount,currency,occurred_at
S-9001,C-501,48500.00,DKK,2026-04-22
```

A sample lead export with every column and two fictional rows is at https://heymysocial.com/docs/files/samples/crm.csv and a sample sales export, whose rows point at a lead of the first file, at https://heymysocial.com/docs/files/samples/crm-sales.csv

## In the app

1. Open **Settings**, then **Connections**. If there is no CRM connection yet, press **Connect** next to **CRM by file** (or **CRM by webhook**, which takes files as well), name it and press **Connect the CRM**. You need a role that may manage integrations.
2. On the connection, press **Mapping and reconciliation**.
3. In the card **Reconcile from a file**, choose under **What the file contains** between **Leads with their status** and **Sales**, choose the CSV file and press **Reconcile the file**.
4. A notice says how many of the rows were applied. Rows that could not be applied are listed under **Reconciliation errors** on the same page, each with the CRM's id and what was wrong. Resolve one when you have fixed it, or ignore one that should stay out.

The size and row limits are on the [overview of files](https://heymysocial.com/docs/files). A file with more rows than the limit is refused; split it and upload the parts.

## Through the API

A system can send the same records without a file through [send-crm-records](https://heymysocial.com/docs/api/operations/send-crm-records) and read what failed with [list-crm-reconciliation-errors](https://heymysocial.com/docs/api/operations/list-crm-reconciliation-errors). To have the CRM send changes as they happen, see the [inbound webhook](https://heymysocial.com/docs/webhooks/crm-inbound) and the guide to [connecting a CRM by webhook](https://heymysocial.com/guides/connect-your-crm-by-webhook).
