feat(api): accept Sure NDJSON imports (#1601)

* feat(api): accept Sure NDJSON imports

* fix(api): preserve uploaded Sure imports on publish errors

* fix(api): reset preserved Sure imports after enqueue failure

* fix(api): tighten Sure import upload handling

* test(api): align import API key fixtures

* docs(api): document import publish failure IDs
This commit is contained in:
ghost
2026-05-01 14:56:18 -06:00
committed by GitHub
parent c429f20a77
commit da42423475
5 changed files with 669 additions and 35 deletions

View File

@@ -61,6 +61,22 @@ components:
nullable: true
description: Validation error messages (alternative to details used by trades,
valuations, etc.)
ErrorResponseWithImportId:
type: object
required:
- error
- import_id
properties:
error:
type: string
message:
type: string
nullable: true
import_id:
type: string
format: uuid
description: Import ID preserved for retry or inspection after upload succeeds
but publish fails
MfaRequiredResponse:
type: object
required:
@@ -888,6 +904,7 @@ components:
- MintImport
- CategoryImport
- RuleImport
- SureImport
status:
type: string
enum:
@@ -934,6 +951,7 @@ components:
- MintImport
- CategoryImport
- RuleImport
- SureImport
status:
type: string
enum:
@@ -2273,6 +2291,7 @@ paths:
- MintImport
- CategoryImport
- RuleImport
- SureImport
responses:
'200':
description: imports filtered by type
@@ -2282,7 +2301,8 @@ paths:
"$ref": "#/components/schemas/ImportCollection"
post:
summary: Create import
description: Create a new import from raw CSV content.
description: Create a new import from raw CSV content, inline Sure NDJSON content,
or an uploaded Sure NDJSON file.
tags:
- Imports
security:
@@ -2300,7 +2320,15 @@ paths:
content:
application/json:
schema:
"$ref": "#/components/schemas/ErrorResponse"
oneOf:
- "$ref": "#/components/schemas/ErrorResponse"
- "$ref": "#/components/schemas/ErrorResponseWithImportId"
'500':
description: import uploaded but publish enqueue failed
content:
application/json:
schema:
"$ref": "#/components/schemas/ErrorResponseWithImportId"
requestBody:
content:
application/json:
@@ -2309,7 +2337,8 @@ paths:
properties:
raw_file_content:
type: string
description: The raw CSV content as a string
description: Raw CSV or Sure NDJSON content as a string. Required
for SureImport unless a multipart file is uploaded.
type:
type: string
enum:
@@ -2319,6 +2348,7 @@ paths:
- MintImport
- CategoryImport
- RuleImport
- SureImport
description: Import type (defaults to TransactionImport)
account_id:
type: string
@@ -2330,25 +2360,51 @@ paths:
if configuration is valid
date_col_label:
type: string
description: Header name for the date column
description: CSV imports only. Header name for the date column
amount_col_label:
type: string
description: Header name for the amount column
description: CSV imports only. Header name for the amount column
name_col_label:
type: string
description: Header name for the transaction name column
description: CSV imports only. Header name for the transaction name
column
category_col_label:
type: string
description: Header name for the category column
description: CSV imports only. Header name for the category column
tags_col_label:
type: string
description: Header name for the tags column
description: CSV imports only. Header name for the tags column
notes_col_label:
type: string
description: Header name for the notes column
description: CSV imports only. Header name for the notes column
account_col_label:
type: string
description: CSV imports only. Header name for the account column
when importing rows across multiple accounts
qty_col_label:
type: string
description: CSV trade imports only. Header name for the quantity
column
ticker_col_label:
type: string
description: CSV trade imports only. Header name for the ticker
column
price_col_label:
type: string
description: CSV trade imports only. Header name for the price column
entity_type_col_label:
type: string
description: CSV imports only. Header name for the entity type column
currency_col_label:
type: string
description: CSV imports only. Header name for the currency column
exchange_operating_mic_col_label:
type: string
description: CSV trade imports only. Header name for the exchange
operating MIC column
date_format:
type: string
description: Date format pattern (e.g., "%m/%d/%Y")
description: CSV imports only. Date format pattern (e.g., "%m/%d/%Y")
number_format:
type: string
enum:
@@ -2356,20 +2412,135 @@ paths:
- 1.234,56
- 1 234,56
- '1,234'
description: Number format for parsing amounts
description: CSV imports only. Number format for parsing amounts
signage_convention:
type: string
enum:
- inflows_positive
- inflows_negative
description: How to interpret positive/negative amounts
description: CSV imports only. How to interpret positive/negative
amounts
col_sep:
type: string
enum:
- ","
- ";"
description: Column separator
required: true
description: CSV imports only. Column separator
amount_type_strategy:
type: string
enum:
- signed_amount
- custom_column
description: CSV imports only. Amount parsing strategy
amount_type_inflow_value:
type: string
description: CSV imports only. Column value that marks an amount
as an inflow when using custom_column strategy
multipart/form-data:
schema:
type: object
properties:
raw_file_content:
type: string
description: Raw CSV or Sure NDJSON content as a string. Required
for SureImport unless a multipart file is uploaded.
type:
type: string
enum:
- TransactionImport
- TradeImport
- AccountImport
- MintImport
- CategoryImport
- RuleImport
- SureImport
description: Import type (defaults to TransactionImport)
account_id:
type: string
format: uuid
description: Account ID to import into
publish:
type: string
description: Set to "true" to automatically queue for processing
if configuration is valid
date_col_label:
type: string
description: CSV imports only. Header name for the date column
amount_col_label:
type: string
description: CSV imports only. Header name for the amount column
name_col_label:
type: string
description: CSV imports only. Header name for the transaction name
column
category_col_label:
type: string
description: CSV imports only. Header name for the category column
tags_col_label:
type: string
description: CSV imports only. Header name for the tags column
notes_col_label:
type: string
description: CSV imports only. Header name for the notes column
account_col_label:
type: string
description: CSV imports only. Header name for the account column
when importing rows across multiple accounts
qty_col_label:
type: string
description: CSV trade imports only. Header name for the quantity
column
ticker_col_label:
type: string
description: CSV trade imports only. Header name for the ticker
column
price_col_label:
type: string
description: CSV trade imports only. Header name for the price column
entity_type_col_label:
type: string
description: CSV imports only. Header name for the entity type column
currency_col_label:
type: string
description: CSV imports only. Header name for the currency column
exchange_operating_mic_col_label:
type: string
description: CSV trade imports only. Header name for the exchange
operating MIC column
date_format:
type: string
description: CSV imports only. Date format pattern (e.g., "%m/%d/%Y")
number_format:
type: string
enum:
- '1,234.56'
- 1.234,56
- 1 234,56
- '1,234'
description: CSV imports only. Number format for parsing amounts
signage_convention:
type: string
enum:
- inflows_positive
- inflows_negative
description: CSV imports only. How to interpret positive/negative
amounts
col_sep:
type: string
enum:
- ","
- ";"
description: CSV imports only. Column separator
amount_type_strategy:
type: string
enum:
- signed_amount
- custom_column
description: CSV imports only. Amount parsing strategy
amount_type_inflow_value:
type: string
description: CSV imports only. Column value that marks an amount
as an inflow when using custom_column strategy
"/api/v1/imports/{id}":
parameters:
- name: id