Batch Upsert Endpoint
POST
/api/v1/snapshots/batch-upsert
const url = 'https://example.com/api/v1/snapshots/batch-upsert';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"snapshots":[{"account_id":1,"date":"2026-04-15","balance":1,"currency":"example","source":"manual","note":"example"}]}'};
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://example.com/api/v1/snapshots/batch-upsert \ --header 'Content-Type: application/json' \ --data '{ "snapshots": [ { "account_id": 1, "date": "2026-04-15", "balance": 1, "currency": "example", "source": "manual", "note": "example" } ] }'Create or update multiple snapshots in a single transaction.
All items are processed within one database session — only one write lock
is acquired, preventing database is locked errors on SQLite.
Returns per-account results (created/updated/unchanged/not_found).
Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/json
BatchSnapshotCreate
Schema for batch snapshot upsert — all items in a single transaction.
object
snapshots
required
Snapshots
Array<object>
SnapshotCreateSchema for snapshot creation — enforces non-negative balance (SNAP-04).
source defaults to ‘manual’, accepts ‘manual’, ‘import’, or ‘recurring’. note is optional, max 500 chars.
Responses
Section titled “Responses”Successful Response
Media typeapplication/json
BatchSnapshotResponse
Response for POST /api/v1/snapshots/batch-upsert.
object
results
required
Results
Array<object>
BatchSnapshotItemResultPer-account result in a batch upsert response.
object
account_id
required
Account Id
integer
action
required
Action
string
snapshot
Any of:
SnapshotOut
Schema for snapshot response — ORM serialization via from_attributes.
object
id
required
Id
integer
account_id
required
Account Id
integer
date
required
Date
string format: date
balance
required
Balance
string
currency
required
Currency
string
source
required
Source
string
created_at
required
Created At
string format: date-time
updated_at
required
Updated At
string format: date-time
null
created_count
required
Created Count
integer
updated_count
required
Updated Count
integer
unchanged_count
required
Unchanged Count
integer
not_found_count
required
Not Found Count
integer
Example generated
{ "results": [ { "account_id": 1, "action": "example", "snapshot": { "id": 1, "account_id": 1, "date": "2026-04-15", "balance": "example", "currency": "example", "source": "example", "note": "example", "deleted_at": "2026-04-15T12:00:00Z", "created_at": "2026-04-15T12:00:00Z", "updated_at": "2026-04-15T12:00:00Z" } } ], "created_count": 1, "updated_count": 1, "unchanged_count": 1, "not_found_count": 1}Validation Error
Media typeapplication/json
HTTPValidationError
object
detail
Detail
Array<object>
ValidationErrorobject
loc
required
Location
Array
msg
required
Message
string
type
required
Error Type
string
input
Input
ctx
Context
object
Example generated
{ "detail": [ { "loc": [ "example" ], "msg": "example", "type": "example", "input": "example", "ctx": {} } ]}