Create a stock location

How to create a stock location via API

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

Request

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

Arguments

Body ParameterTypeRequired

type

string

Required

attributes.name

string

Required

attributes.code

string

Optional

attributes.label_format

string

Optional, default is 'pdf'

attributes.suppress_etd

boolean

Optional

attributes.reference

string

Optional

attributes.reference_origin

string

Optional

attributes.metadata

object

Optional

relationships.address

object

Required

Example

The following request creates a new stock location:

curl -g -X POST \
  'https://yourdomain.commercelayer.io/api/stock_locations' \
  -H 'Accept: application/vnd.api+json' \
  -H 'Authorization: Bearer your-access-token' \
  -H 'Content-Type: application/vnd.api+json' \
  -d '{
  "data": {
    "type": "stock_locations",
    "attributes": {
      "name": "Primary warehouse"
    },
    "relationships": {
      "address": {
        "data": {
          "type": "addresses",
          "id": "ABCRtyUpBa"
        }
      }
    }
  }
}'

Last updated