# Sales file format

A sales file ties revenue to leads you already have. Each row is one sale: an amount, a date and something that says which lead it belongs to. When the row is accepted the sale is recorded and the lead moves to won.

## Columns

<div class="table-scroll"><table><thead><tr><th>Column</th><th>Headings recognised</th><th>Needed</th><th>What it is</th></tr></thead><tbody><tr><th scope="row"><code style="white-space:nowrap">lead_external_id</code></th><td>lead_external_id, lead id, lead, customer id, kundenummer</td><td>This or email</td><td>The id you gave the lead, its external_id. Exactly one lead must have it.</td></tr><tr><th scope="row"><code style="white-space:nowrap">email</code></th><td>email, e-mail, mail, email address, e-mailadresse</td><td>This or lead_external_id</td><td>The lead&#039;s email address. The newest lead with that address that arrived no later than the day of the sale is used. A name is never used.</td></tr><tr><th scope="row"><code style="white-space:nowrap">amount</code></th><td>amount, beløb, belob, total, revenue, omsætning, value, værdi</td><td>Yes</td><td>The amount, above zero, as a number in the currency&#039;s main unit.</td></tr><tr><th scope="row"><code style="white-space:nowrap">currency</code></th><td>currency, valuta</td><td>Optional</td><td>A three-letter currency code. Left empty, the workspace&#039;s currency is used.</td></tr><tr><th scope="row"><code style="white-space:nowrap">occurred_at</code></th><td>occurred_at, date, dato, sale date, salgsdato, invoice date, fakturadato</td><td>Optional</td><td>The date of the sale. Left empty, the moment of the import is used. It cannot be more than a day in the future.</td></tr><tr><th scope="row"><code style="white-space:nowrap">external_id</code></th><td>external_id, id, lead id, sale id, invoice, faktura, fakturanummer, order id, ordrenummer</td><td>Optional</td><td>Your own id for the sale, such as an invoice number. Without it, the lead, the amount and the date identify the sale.</td></tr><tr><th scope="row"><code style="white-space:nowrap">revenue_basis</code></th><td>revenue_basis, basis</td><td>Optional</td><td>booked, invoiced or collected. Left empty: booked.</td></tr><tr><th scope="row"><code style="white-space:nowrap">verification_source</code></th><td>verification_source, verification, source, kilde</td><td>Optional</td><td>manual, crm or invoice. Left empty: manual.</td></tr></tbody></table></div>

As with leads, the import screen proposes a column for each field from the header row, and you can change every choice. Capital letters do not matter, and underscores and dashes count as spaces.

## How a sale finds its lead

You must map the amount, and either `lead_external_id` or `email`.

- **By the lead's id.** `lead_external_id` is the id the lead has in your system, the one imported as `external_id` with the [lead file](https://heymysocial.com/docs/files/leads) or sent with the lead through the API. Exactly one lead must have it. If no lead has the id, or more than one does, the row is left out and the reason says which.
- **By email address.** Used when the row has no lead id. The address must match a contact exactly. Among that contact's leads the newest one that arrived on or before the day of the sale is chosen, and leads marked as duplicates are skipped. If no lead with that address arrived before the sale, the row is left out.

A sale is never matched on a name.

## Rules for a row

- **Amount.** A number above zero. `48500`, `48500.00`, `48.500,00` and `48,500.00` are all read as the same amount: when both a comma and a full stop appear, the last one is the decimal mark, and a single mark followed by exactly three digits is read as a thousands separator. A refund cannot be imported with this file.
- **Currency.** A three-letter code such as `DKK`. Without a currency the row gets the workspace's currency.
- **Date.** `occurred_at` is the day of the sale, in the same forms as the date of a lead, read in the workspace's time zone. Without a date the sale gets the moment of the import; a date more than a day in the future is refused.
- **The sale's own id.** `external_id` is the invoice or order number. Give it whenever you can: it is how the sale is recognized next time.
- **Revenue basis.** `booked`, `invoiced` or `collected`. Empty means `booked`.
- **Verification source.** `manual`, `crm` or `invoice`, saying where the number was checked. Empty means `manual`.

A row with an unknown revenue basis, verification source or currency is left out; nothing is corrected by guessing.

## Importing the same file again

A sale with an `external_id` is recognized by it. A sale without one is recognized by its lead, amount, currency and date. Either way a second import leaves the sale as it is and counts the row under **Already there**.

<div class="callout callout-tip"><p class="callout-title">Give each sale its number</p>

Two real sales to the same lead, for the same amount on the same day, look like one sale when neither has an id. With an invoice or order number in `external_id` they stay two.

</div>


## Sample

The rows are made up. The first sale names its lead by id; the second has only the email address and writes the amount and date the Danish way, with the amount in quotes because it contains a comma.

```csv
lead_external_id,email,amount,currency,occurred_at,external_id,revenue_basis,verification_source
L-1001,,48500.00,DKK,2026-04-22,INV-2041,invoiced,invoice
,bo@example.org,"12.500,00",DKK,28-04-2026,INV-2042,booked,manual
```

A file with every column and two fictional rows is at https://heymysocial.com/docs/files/samples/sales.csv and its rows point at the leads of the sample lead file, so import that one first.

## In the app

1. Open **Leads** and press **Import**. You need a role that may manage leads, and you must be on the agency's own team.
2. Under **What is in the file?** choose **Sales**, choose the CSV file and press **Read the file**.
3. On **Map the columns**, check the proposal against the first rows of the file, then press the import button, which says how many rows it will import. If the amount or both ways of finding the lead are unmapped, the screen says so and nothing is imported.
4. **Result** shows **Imported**, **Already there** and **Not imported**, and lists each row that was left out with its line number and the reason.

Import the leads before their sales. A sale whose lead is not in the workspace yet is left out, and importing the same sales file again after the leads are in picks it up. The size and row limits are on the [overview of files](https://heymysocial.com/docs/files).

## Other ways to record a sale

- In the app, **Record a sale** on the lead's own page records one sale.
- An assistant records one sale with [record_sale](https://heymysocial.com/docs/assistant/tools/record-sale).
- A system sends a `sale_won` event through the API or the signed webhook; see [server events](https://heymysocial.com/docs/tracking/server-events).
- A CRM connection takes sales by webhook, API or its own [export file](https://heymysocial.com/docs/files/crm), under the CRM's ids.

How sales count toward a campaign is described under [attribution](https://heymysocial.com/docs/reference/attribution).
