Record a stock movement on a (sku, location) line
const url = 'https://quikstik-core.fly.dev/stock/movements';const options = { method: 'POST', headers: { 'x-tenant-id': '2489E9AD-2EE2-8E00-8EC9-32D5F69181C0', 'Idempotency-Key': 'example', Authorization: 'Bearer <token>', 'Content-Type': 'application/json' }, body: '{"sku":"example","location":"example","magnitude":1,"reason":{"reason":"received"},"down":false}'};
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://quikstik-core.fly.dev/stock/movements \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --header 'Idempotency-Key: example' \ --header 'x-tenant-id: 2489E9AD-2EE2-8E00-8EC9-32D5F69181C0' \ --data '{ "sku": "example", "location": "example", "magnitude": 1, "reason": { "reason": "received" }, "down": false }'Appends one movement (receive / sell / consume / promote-to-resource / transfer-out /
adjust) to the append-only stock ledger for a tenant-defined sku at a location. The server loads the line’s fold, runs the gate (non-negative on-hand,
currency, and amount checks — violations return 422), and persists the movement
idempotently. magnitude is positive; the reason resolves the sign. For a downward
adjustment (shrinkage/damage) set down: true with an adjusted reason. Units are
dimensionless counts whose meaning the tenant owns.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”Tenant identifier (UUID).
Authn/authz semantics are intentionally TBD for this contract slice; this header exists to keep the contract explicitly multi-tenant from day 0.
Idempotency key for the command envelope. A retry with the same key is a no-op.
Request Bodyrequired
Section titled “Request Bodyrequired”object
Tenant-defined SKU — opaque to core.
Tenant-defined location — opaque to core.
Positive count; the reason (and down) resolve the sign.
A tagged stock reason. The reason discriminator selects the variant (received,
sold, consumed, promoted_to_resource, transferred_out, adjusted); remaining
fields are the variant’s payload (e.g. received carries unit_cost_minor +
currency). The server-side domain type is authoritative for payload shape.
object
For adjusted only — when true the adjustment decreases on-hand.
Responses
Section titled “Responses”Movement recorded; the assigned stream sequence is returned
object
The append-only sequence assigned to this movement in the line’s stream.
Example generated
{ "seq": 1}Malformed body
object
Example generated
{ "reason": "example"}Missing or invalid session bearer token
object
Stable, machine-readable reason code (e.g. “sold_out”, “processor_not_configured”, “rail_refused”).
Example
{ "reason": "sold_out"}The session’s effect authority does not cover this operation
object
Stable, machine-readable reason code (e.g. “sold_out”, “processor_not_configured”, “rail_refused”).
Example
{ "reason": "sold_out"}The command is rejected by a domain lifecycle gate (illegal state transition)
object
Stable machine-readable error code
Human-readable explanation (never leaks SQL, URLs, or secrets)
Example generated
{ "code": "example", "message": "example"}No durable backend is wired for this operation (fail-closed)
object
Stable, machine-readable reason code (e.g. “sold_out”, “processor_not_configured”, “rail_refused”).
Example
{ "reason": "sold_out"}