For the complete documentation index, see llms.txt. This page is also available as Markdown.

Updating resources

How to update a resource via API

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

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

Authentication

Examples

Updating attributes

The following request updates the description of an existing SKU:

curl -g -X PATCH \
  'https://yourdomain.commercelayer.io/api/skus/xYZkjABcde' \
  -H 'Accept: application/vnd.api+json' \
  -H 'Authorization: Bearer your-access-token' \
  -H 'Content-Type: application/vnd.api+json' \
  -d '{
  "data": {
    "type": "skus",
    "id": "xYZkjABcde",
    "attributes": {
      "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
    }
  }
}'

On success, the API responds with a 200 OK status code, returning the updated resource object:

{
  "data": {
    "id": "xYZkjABcde",
    "type": "skus",
    "links": {
      "self": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde"
    },
      "attributes": {
        "code": "TSHIRTMM000000FFFFFFXLXX",
        "name": "Men's Black T-shirt with White Logo (XL)",
        "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
        "image_url": null,
        "tag_names": "",
        "pieces_per_pack": null,
        "weight": null,
        "unit_of_weight": null,
        "hs_tariff_number": null,
        "do_not_ship": false,
        "do_not_track": false,
        "created_at": "2018-01-01T12:00:00.000Z",
        "updated_at": "2018-01-01T12:00:00.000Z",
        "reference": null,
        "metadata": {}
      },
      "relationships": {
        "shipping_category": {
          "links": {...}
        },
        "prices": {
          "links": {...}
        },
        "stock_items": {
          "links": {...}
        },
        "delivery_lead_times": {
          "links": {...}
        },
        "sku_options": {
          "links": {...}
        }
    },
    "meta": {
      "mode": "test",
      "organization_id": "wBstRPzLrk",
      "trace_id": "7d4e1b8c2f5a9d3e6b0c8f1a5d2e9b4f7c3a6d0e8b1f5c2a7d4e1b8c3f6a9d2e"
    }  
  },
  "meta": {
    "mode": "test",
    "organization_id": "wBstRPzLrk",
    "trace_id": "7d4e1b8c2f5a9d3e6b0c8f1a5d2e9b4f7c3a6d0e8b1f5c2a7d4e1b8c3f6a9d2e"
  }
}

Updating relationships

The following request changes the shipping category of an existing SKU:

On success, the API responds with a 200 OK status code, returning the updated resource object:

Removing relationships

If a relationship is optional for the creation of a resource, it can be removed by sending PATCH request with the data object set as null.

The following request removes a customer from a customer group:

On success, the API responds with a 200 OK status code, returning the updated resource object:

Last updated