Preview a CSV trade import (mints a single-use commit token).
const url = 'https://api.tradr.cloud/api/csv-import/preview';const form = new FormData();form.append('file', 'file');form.append('request', 'example');
const options = {method: 'POST'};
options.body = form;
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.tradr.cloud/api/csv-import/preview \ --header 'Content-Type: multipart/form-data' \ --form file=@file \ --form request=exampleFirst 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).
Request Bodyrequired
Section titled “Request Bodyrequired”object
The raw CSV file (UTF-8).
A JSON string (CsvPreviewRequest): { accountId, rowShape, mapping, presetId?, timezone, dateFormat, numberFormat }.
Responses
Section titled “Responses”{ 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).