Skip to content

Batch Upsert Endpoint

POST
/api/v1/snapshots/batch-upsert
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).

Media typeapplication/json
BatchSnapshotCreate

Schema for batch snapshot upsert — all items in a single transaction.

object
snapshots
required
Snapshots
Array<object>
<= 200 items
SnapshotCreate

Schema for snapshot creation — enforces non-negative balance (SNAP-04).

source defaults to ‘manual’, accepts ‘manual’, ‘import’, or ‘recurring’. note is optional, max 500 chars.

object
account_id
required
Account Id
integer
date
required
Date
string format: date
balance
required
Any of:
number
currency
Any of:
string
/^[A-Z]{3}$/
source
Source
string
default: manual /^(manual|import|recurring)$/
note
Any of:
string
<= 500 characters

Successful Response

Media typeapplication/json
BatchSnapshotResponse

Response for POST /api/v1/snapshots/batch-upsert.

object
results
required
Results
Array<object>
BatchSnapshotItemResult

Per-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
note
required
Any of:
string
deleted_at
required
Any of:
string format: date-time
created_at
required
Created At
string format: date-time
updated_at
required
Updated At
string format: date-time
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>
ValidationError
object
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": {}
}
]
}