import_ec_sales
Import e-commerce sales data from CSV or JSON, mapping columns to required fields and upserting rows by channel, product, and sale date.
Instructions
Imports EC sales data into the tenant. Choose one of two payload types via payload_type:
payload_type=csv (default)
Sync a source CSV (e.g. a sales export downloaded from Amazon, Rakuten, or your own EC).
Download the sales CSV from the EC mall to a local file.
Base64-encode the file's bytes and send it as
csv_payload.Map each CSV column header to the five required normalized fields via
mapping:product_id,product_name,sold_on,sales_amount,sales_quantity.
payload_type=json
Send the rows directly as records — an array of objects keyed by the canonical field names.
No mapping or csv_payload is needed.
For both modes set source_channel (e.g. amazon, rakuten, owned) — it is normalized (lowercased, spaces → dashes).
Notes
Rows are upserted on the business key (
source_channel×product_id×sold_on). Re-sending the same rows updates them in place — the sync is idempotent.sold_onmust be a complete date (year, month, and day). Accepted formats:YYYY-MM-DD,YYYY/MM/DD,YYYY.MM.DD.sales_amountandsales_quantitymust be zero or greater. Currency symbols/commas in amounts are stripped.On any row or mapping error nothing is written and a 422 is returned with the per-row messages in
error.details.errors.After syncing, confirm with
read_ec_sync_status. Individual sales rows are never readable back through the API.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mapping | No | Maps each required normalized field to the matching CSV column header. Required (all five keys) when payload_type=csv. | |
| records | No | Sales rows keyed by the canonical field names. Required when payload_type=json. | |
| filename | No | Optional original filename, for display only (csv mode). | |
| csv_payload | No | Base64-encoded CSV file contents (headers + rows). Required when payload_type=csv. | |
| payload_type | No | `csv` (default): send base64 `csv_payload` + `mapping`. `json`: send `records`. | csv |
| source_channel | No | EC channel the rows belong to. Normalized before storage. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | Yes | Outcome of an EC sales CSV sync (import_ec_sales). Rows are upserted on the business key (source_channel × product_id × sold_on), so re-sending the same rows updates in place rather than duplicating. |