Append historical stock ledger rows (stock_logs) in a batch; no counter moves, no event

Up to 500 entries, ONE insert in one transaction. Each entry is a movement that already happened in the source system: a ledger row is written with the entry's occurredAt as its timestamp, its externalId as hid and publicId (the idempotency key within the tenant: an entry whose publicId exists answers unchanged and is not touched), the product (by id or sku), the sides (a warehouseId addresses its floor location) and the balances as the counter snapshots. No stock counter, product embed or stock level is changed, no hid counter is allocated, and no event, legacy message or outbox row is written. Requires X-Import-Mode: historical (422 validation_failed, headers.x-import-mode, import_mode_required otherwise). Links (order, shipment, vendor) are best effort: an unresolved one is a warning (entries[i].links.<name>, not_found) and the row is written without it. 201 when any entry was created, 200 when every entry was unchanged; 400 validation_failed (shape, sign and side rules, a repeated externalId); 422 unresolved_reference (a product, warehouse or location that does not resolve).

Scope: products:write, channel:write or admin.

Idempotency: send Idempotency-Key; a retry with the same key replays the first answer.

Rate limit: write class, 1,200 requests per minute per tenant by default (read class 6,000). Every response carries X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset; a refusal is 429 rate_limited with Retry-After.

Body Params
entries
array of objects
required
length between 1 and 500
entries*
string
required
length between 1 and 100

The source entry id, unique within the tenant: the idempotency key (becomes hid and publicId).

product
object
required

One of the tenant's products: by id or by sku.

enum
required

receive, fulfill, adjust, move, build-use or build-produce (the stock ledger action).

integer
required
-1000000000 to 1000000000

Signed, never 0: receive and build-produce > 0, fulfill and build-use < 0, move > 0, adjust any.

date-time
required

ISO-8601, UTC.

from
object

Exactly one of warehouseId (addresses the warehouse's floor location) and locationId.

to
object

Exactly one of warehouseId (addresses the warehouse's floor location) and locationId.

fromBalance
object

Stored as the counter snapshot of that side (available before and after; the other buckets 0).

toBalance
object

Stored as the counter snapshot of that side (available before and after; the other buckets 0).

string
length between 1 and 255

adjustment_reason.

string
length between 1 and 1000
reference
object

The source document (stored in meta_data.reference).

cost
object

The signed cost of the entry (stored in meta_data.cost).

links
object
metadata
object

Keys 1 to 100 characters, values up to 1000.

Headers
string
length between 7 and 50

Any string of 7 to 50 characters that identifies this request (an order number, a webhook id). A retry with the same key and the same body answers the first result with Idempotent-Replayed: true; the same key with a different body is 422 idempotency_key_reused; a concurrent request with the same key is 409 in_progress with Retry-After. Recommended on every write.

Responses

Language
Credentials
URL
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json