Your buyers can go out as a file and come back in as one: CSV, Excel (.xlsx) or JSON. Use it to move a buyer
list from another system, to edit many buyers in a spreadsheet, or to keep a copy.
An import always shows what it would do first. Nothing is saved until you confirm.
Download the buyers or the sample
In the console, open Buyers, then Import and export. Under Download, choose CSV, Excel or JSON. The example file is on the Data files page, which the same menu links to. Through the API, any key may download:
curl -s -o buyers.csv -H "Authorization: Bearer cvo_live_sk_..." "https://<api-host>/v1/data-files/customers?format=csv"
curl -s -o buyers-sample.xlsx -H "Authorization: Bearer cvo_live_sk_..." "https://<api-host>/v1/data-files/customers/sample?format=xlsx"format is csv, xlsx or json. Without it, you get CSV. With no buyers saved, the file has only its header row.
The sample holds a few buyers, in the same columns. They are the buyers of invoices the validator accepted. Nobody typed them.
The columns
- One row per buyer.
- Each column is the API’s field name. A nested field is dotted:
address.city,contact.email,delivery.to. - Each fact a country’s rules ask of a buyer has its own column,
facts.<name>. A yes-or-no fact istrueorfalse. filesis one cell, its ids separated by commas, such ascii,zugferd-pdf.- What VIES and the Peppol registry answered about a buyer has no column. The API asks them each time a buyer is saved.
- The CSV is separated by semicolons, in UTF-8 with a byte order mark, so Excel opens it with its umlauts.
- A cell starting with
=,+,-or@is written with a leading', so a spreadsheet never runs it as a formula. An import takes the'off again. A plain number, such as-50.00, is written as it is. - The Excel sheet writes every cell as text and formats every column as text, so a postcode like
01067keeps its leading zero, and so does one you type in later. - The JSON is a list of buyers, as
GET /v1/customersholds them. An import also takes{"customers": [...]}.
Import a file
- On Buyers, open Import and export, choose Import a file and pick the file.
- The import page counts the rows as new, changed, the same and not imported. It names each new and changed buyer, and each row it will not import, with its row number, its column and why.
- Choose Import. All new and changed buyers are saved as one new version of the list.
- If someone changed the buyers meanwhile, the page reads the file again against the new list. Check it and import.
How a row finds its buyer:
- A row with an
idis that buyer. - A row with no
idis the one buyer with thatname. If none has it, the row is a new buyer, and its id is made from its name. If several have it, give the row an id.
What a row changes:
- A column the file has sets that field. An empty cell clears it.
- A column the file lacks keeps what is saved. A file with only
idandvatIdchanges VAT IDs and nothing else. - A buyer the file leaves out is kept. An import never removes a buyer. Remove one on its own page.
A file with a column no buyer has, such as iban, is refused whole, naming the column. A file with neither an id
nor a name column is refused too.
Import through the API
Preview first. Any key may preview:
curl -s -X POST -H "Authorization: Bearer cvo_live_sk_..." -H "Content-Type: application/json" \
-d "{\"data\": \"$(base64 < buyers.csv)\"}" "https://<api-host>/v1/data-files/customers/previews"The answer has counts, one entry per row in rows, and basedOn, the version of the list it was made against.
Only a signed-in person may import, as only a person may change the buyers. Send the same file with basedOn to
POST /v1/data-files/customers/imports. A key is refused with 401 session_required.
| Status | Code | What happened |
|---|---|---|
| 400 | invalid_data_file |
The file is no buyers file: not a CSV, Excel sheet or JSON list, or it has a column no buyer has. The message names it. Nothing was read. |
| 400 | invalid_format |
format is not csv, xlsx or json. |
| 409 | list_changed |
The buyers changed since the preview. Preview the file again. Nothing was saved. |
| 409 | request_in_progress |
Another import of the same list is being saved at this moment. Preview the file again once it is done. Nothing was saved. |
A file that changes nothing saves nothing. The answer’s version is then the current one.