Skip to content

Import stock quantities from CSV

POST
/stores/{storeRef}/inventory/import
curl --request POST \
--url https://apibase.ecomweb.app/api/v1/stores/example/inventory/import \
--header 'Content-Type: multipart/form-data' \
--header 'x-api-key: <x-api-key>' \
--form file=@file

Sets on_hand for the variants in a CSV file, as one adjustment with the reason count. Upload a file from the export as the file field (at most 5 MB, 5000 rows) with the On hand (new) column filled in. A row is written only if the variant’s stock still matches On hand (current). Rows that cannot be applied, such as an unknown variant, a repeated variant or stock that changed since the export, are listed in skipped and do not stop the other rows.

Required scopes: write:inventory

storeRef
required
string

The store’s ref, as returned by GET /stores.

Media typemultipart/form-data
object
file
required

The CSV file, at most 5 MB. Use a file produced by the export, with the On hand (new) column filled in.

string format: binary
Media typeapplication/json
object
applied
required

Rows whose on hand quantity was written.

number
unchanged
required

Rows whose new quantity already matched the current one.

number
skipped
required

Rows that were not applied, with the reason for each.

Array<object>
object
reason
required

Why the row was skipped.

string
Allowed values: stale not_found invalid_quantity missing_variant_id duplicate_variant_id
row
required

The data row number, starting at 1 and not counting the header.

number
variant_id
required

The variant ID as written in the file, or null when the cell was empty.

string
nullable
current_on_hand
required

The variant’s current on hand quantity, when it is known.

number
nullable

Example

{
"skipped": [
{
"reason": "stale"
}
]
}

The request is malformed or failed validation.

Media typeapplication/json
One of:
object
statusCode
required

The HTTP status code.

number
message
required

What went wrong; validation failures list one message per problem.

One of:
string
error

The HTTP status text, such as Bad Request.

string

Example generated

{
"statusCode": 1,
"message": [
"example"
],
"error": "example"
}

The key is missing, invalid, revoked or expired.

Media typeapplication/json
One of:
object
statusCode
required

The HTTP status code.

number
message
required

What went wrong; validation failures list one message per problem.

One of:
string
error

The HTTP status text, such as Bad Request.

string

Example generated

{
"statusCode": 1,
"message": [
"example"
],
"error": "example"
}

The key may not do this: a missing scope, a readonly key, a publishable key on a Store API route, or a disallowed origin.

Media typeapplication/json
One of:
object
statusCode
required

The HTTP status code.

number
message
required

What went wrong; validation failures list one message per problem.

One of:
string
error

The HTTP status text, such as Bad Request.

string

Example generated

{
"statusCode": 1,
"message": [
"example"
],
"error": "example"
}