Commit a previewed CSV import (consumes the preview token).
const url = 'https://api.tradr.cloud/api/csv-import/commit';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"confirmDuplicates":false,"token":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0"}'};
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/commit \ --header 'Content-Type: application/json' \ --data '{ "confirmDuplicates": false, "token": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0" }'Second call of the preview→commit handshake. Consumes the single-use token minted by /api/csv-import/preview and atomically replays the staged positions/fills (firing the close-hook ledger entries inside one bulk transaction). Idempotent: re-committing an already-committed token returns the original summary, never a second import. A stale token (replaced by a newer preview), an expired token, a blocked preview, an in-flight commit, or unconfirmed near-total duplicates each return a specific 409 with a stable code; an unknown token returns 404. Set confirmDuplicates: true to import past a near-total-overlap (≥90%) duplicate block. Tier enforcement (plan-tiers, gated non-admin free users): the commit refuses 403 when the lifetime CSV-import allowance is exhausted, when the target account is not the writable designation while over the account cap, or when the batch would exceed the position cap (atomic whole-batch refusal — the message names the cap and the batch size). A tier refusal leaves the staged preview INTACT: the same token is re-committable after re-designation/upgrade, no re-upload. Only successful commits consume the lifetime allowance — previews, refusals, and failed commits never do.
Request Bodyrequired
Section titled “Request Bodyrequired”object
Responses
Section titled “Responses”{ positionsCreated, fillsCreated, positionIds, accountId } — the import summary (REQ-8.7).
Malformed body (invalid token / confirmDuplicates).
Tier refusal (never 429, no Retry-After) with a stable code: TIER_LIMIT_CSV_IMPORTS (lifetime import allowance exhausted), TIER_ACCOUNT_NOT_WRITABLE (target account not writable while over the account cap), or TIER_LIMIT_POSITIONS (batch would exceed the position cap; message names cap and batch size). The staged preview stays intact and re-committable.
No staged preview matches this token (or not owned).
Refusal with a stable code: CSV_IMPORT_SUPERSEDED, CSV_IMPORT_EXPIRED, CSV_IMPORT_BLOCKED, CSV_IMPORT_IN_PROGRESS, or CSV_IMPORT_DUPLICATES_UNCONFIRMED.