Creating resources

How to create a resource via API

You can create a resource by sending a POST request to the resources endpoint, with a JSON payload.

The Content-Type header must be application/vnd.api+json.

You can get the list of arguments, with type and examples from the documentation of each resource.

Authentication

Example

The following request creates a new SKU:

curl -g -X POST \
  'https://yourdomain.commercelayer.io/api/skus' \
  -H 'Accept: application/vnd.api+json' \
  -H 'Authorization: Bearer your-access-token' \
  -H 'Content-Type: application/vnd.api+json' \
  -d '{
    "data": {
      "type": "skus",
      "attributes": {
        "code": "TSHIRTMM000000FFFFFFXLXX",
        "name": "Men's Black T-shirt with White Logo (XL)"
      },
      "relationships": {
        "shipping_category": {
          "data": {
            "type": "shipping_categories",
            "id": "zxcVBnMASd"
          }
        }
      }
    }
  }'

Last updated