Create a stock line item

How to create a stock line item via API

To create a new stock line item, send a POST request to the /api/stock_line_items endpoint, passing the resource arguments in the request body.

Request

POST https://yourdomain.commercelayer.io/api/stock_line_items

Arguments

Body Parameter
Type
Required

type

string

Required

attributes.sku_code

string

Optional

attributes.quantity

integer

Required

attributes.reference

string

Optional

attributes.reference_origin

string

Optional

attributes.metadata

object

Optional

relationships.shipment

object

Optional

relationships.line_item

object

Optional

relationships.stock_item

object

Optional

relationships.sku

object

Optional, default is stock item one

Example

The following request creates a new stock line item:

curl -g -X POST \
  'https://yourdomain.commercelayer.io/api/stock_line_items' \
  -H 'Accept: application/vnd.api+json' \
  -H 'Authorization: Bearer your-access-token' \
  -H 'Content-Type: application/vnd.api+json' \
  -d '{
  "data": {
    "type": "stock_line_items",
    "attributes": {
      "quantity": 4
    }
  }
}'

Last updated