Skip to content

Preview a CSV trade import (mints a single-use commit token).

POST
/api/csv-import/preview
curl --request POST \
--url https://api.tradr.cloud/api/csv-import/preview \
--header 'Content-Type: multipart/form-data' \
--form file=@file \
--form request=example

First call of the preview→commit handshake. Parses, maps, normalizes, segments, and dry-runs the uploaded CSV against the target account, returning the proposed positions/fills plus per-row/per-cell errors and warnings — and a single-use token the client passes to /api/csv-import/commit. No trade data is written; the only side effect is staging one preview row per user (a newer preview supersedes the prior one). The body is read with an actual-bytes byte cap (CSV_IMPORT_MAX_FILE_BYTES, default 10 MiB) — a deceptive Content-Length below the cap does not bypass it — so an oversized upload is rejected with 413. The multipart request part is itself capped (CSV_IMPORT_MAX_REQUEST_BYTES, default 64 KiB).

Media typemultipart/form-data
object
file
required

The raw CSV file (UTF-8).

string format: binary
request
required

A JSON string (CsvPreviewRequest): { accountId, rowShape, mapping, presetId?, timezone, dateFormat, numberFormat }.

string

{ token, summary, positions, errors, warnings, timezone, committable, requiresDuplicateAffirmation }. token is consumed by the commit endpoint.

Malformed upload, request part, or CSV (e.g. CSV_NOT_UTF8, CSV_IMPORT_REQUEST_TOO_LARGE, CSV_NO_ROWS).

An import is already in progress for this user (CSV_IMPORT_IN_PROGRESS).

File over CSV_IMPORT_MAX_FILE_BYTES (PAYLOAD_TOO_LARGE), too many rows (CSV_IMPORT_TOO_MANY_ROWS), or staged result too large (CSV_IMPORT_RESULT_TOO_LARGE).