Import and export formats
Tienda loads some data from CSV files and exports other data as CSV. Both are used by the back office (Settings, Import data; the export buttons on lists) and can be called over the API by a signed-in shop administrator. The screens are in the manual: Integrations, Import data.
CSV import
GET /api/v1/imports/models
POST /api/v1/imports (multipart form: model=<key>, file=<csv>)Only shop administrators may import. GET .../models lists what can be
imported in this shop, with the columns and an example file for each. A data
type shows only if its module is on.
What can be imported
model | Module | Columns | Required |
|---|---|---|---|
contacts | CRM | first_name, last_name, name, email, phone, notes | none |
companies | CRM | name, vat_id, coc_id, notes | name |
products | Catalog | name, description, sku, barcode, sellable, rentable, product_type, price, purchase_price | name, product_type |
categories | Catalog | name, description, show_in_shop, show_in_pos, pos_position | name |
stalls | Events | name, code, address, city, address_description, is_private | name, code |
Orders cannot be imported from a file: an order needs a customer, lines, a
status and payments. The answer says so (unsupported_model). Enter orders at
the register, or use the POS mirror.
Rules
- A file with an unknown column is refused as a whole. The answer is
422withreason: "unknown_columns"and the names of the unknown and the allowed columns. Nothing is imported and nothing is silently dropped. - A file without a required column is refused the same way
(
reason: "missing_columns"). - The first line holds the column names. The separator is a comma or a semicolon, whichever the first line has more of. The file is read as UTF-8; when it is not valid UTF-8 it is read as ISO-8859-1. An empty file is refused.
- Empty rows are skipped. Empty cells are left unset.
- Yes/no columns (
sellable,rentable,show_in_shop,show_in_pos,is_private) are read as no when the cell holdsfalse,0,foroff(any case), and as yes for any other text. Writetrueorfalse. An empty cell is left unset. - A product's
product_typeis looked up by name in this shop, ignoring case. A name that does not exist fails that row.priceandpurchase_priceare numbers; a comma works as the decimal mark. When one of them is given, the product also gets a price row, made at that moment. - Texts are written in the shop's base language, not in the language the administrator happens to use.
- One bad row does not stop the others. Every good row is saved.
The answer
{
"success_count": 2,
"failure_count": 1,
"total": 3,
"errors": {"4": ["Product type \"Plants\" does not exist"]}
}The keys of errors are line numbers in the file (the first line is line 1, the
first data row line 2).
A file is saved row by row, not as one transaction: sending the corrected rows again is safe for rows that failed, but rows that were saved are saved twice if you send them again. The importer does not look for duplicates.
Events: attendees
Registrations for an event can be loaded from a CSV file or from pasted lines:
POST /api/v1/events/events/:event_id/attendee_import, with columns name,
email, phone and ticket_type. The file may be 2 MB at most. The answer
holds the number created and the rows skipped with a reason. Needs the Events
module.
Exports
Exports are plain GET requests that answer text/csv as an attachment named
<name>-<date>.csv, using the same sign-in as the rest of the API.
| Request | Content |
|---|---|
GET /api/v1/pos/orders/export | Orders: number, date, customer, status, payment method, channel and more. |
GET /api/v1/crm/contacts/export | Contacts: name, first name, last name, e-mail, phone, company, notes. |
GET /api/v1/pos/coupons/export | Coupons: code, type, amount, minimum order, status, uses, limit, start and end date, batch. |
GET /api/v1/statistics/export?report=<name> | One CSV for each statistics page. report is one of sales, products, margin, customers, events, subscriptions, growth. |
Export columns follow the list shown here; the exact headers can change between releases. There is no export for products or stock yet. Not available yet.