Skip to main content

Update a variation

PUT 

https://euwest.api.elasticpath.com/pcm/variations/:variationID

Specify whichever attributes you want to change. The values of the other attributes remain the same. If the attributes section is empty, the variation is not updated.

Request

Path Parameters

    variationID stringrequired

    A unique identifier for the variation.

Body

    data objectrequired
    typestringrequired

    This represents the type of resource object being returned. Always product-variation.

    Possible values: [product-variation]

    attributes objectrequired
    namestring

    The variation name.

    sort_orderinteger

    The sort order value is visible when you add the variations and variation options to your catalogs. You can then use the sort_order value to program your storefront to display the variation options in the order that you want.

    The variation with the highest value of sort_order is displayed first. For example, a variation with a sort_order value of 3 appears before a variation with a sort_order value of 2.

    You can specify any numbers that you want. You can use 1, 2, 3, or 100, 90, 80, including, zero or negative numbers. You can set sort_order to either null or omit it entirely from the request if you wish to remove an existing sort_order attribute.

    You must rebuild your products for the sort order changes to take effect.

    idstringrequired

    The unique identifier of the variation. Must match the variation ID specified in the request path.

    Example: 00000000-0000-0000-0000-000000000000

Responses

Returns an updated variation with the following attributes.

Schema
    data objectrequired
    idstringrequired

    A unique identifier for a variation.

    typestringrequired

    This represents the type of resource object being returned. Always product-variation.

    Possible values: [product-variation]

    attributes objectrequired
    namestring

    The name for a variation.

    sort_orderinteger

    The sort order value is visible when you add the variations and variation options to your catalogs. You can then use the sort_order value to program your storefront to display the variation options in the order that you want. The variation with the highest value of sort_order is displayed first. For example, a variation with a sort_order value of 3 appears before a variation with a sort_order value of 2. You can specify any numbers that you want. You can use 1, 2, 3, or 100, 90, 80, including, zero or negative numbers. You can set sort_order to either null or omit it entirely from the request if you wish to remove an existing sort_order attribute.

    meta objectrequired
    options object[]

    A variation option represents an option for selection for a single product-variation. For example, if your variation is color, you might have three possible options; red, green, and blue.

  • Array [
  • idstring

    A unique ID that is generated an option is created.

    namestring

    A human-recognizable identifier for the option, also used in the SLUG for child products. Option names can only contain A to Z, a to z, 0 to 9, hyphen, underscore, and period. Spaces or other special characters like ^, [], *, and $ are not allowed.

    descriptionstring

    A description for an option.

    created_atdate-time

    The date and time an option is created.

    Example: 2020-09-22T09:00:00
    updated_atdate-time

    The date and time an option is updated.

    Example: 2020-09-22T09:00:00
    sort_orderinteger

    The sort order value is visible when you add the variations and variation options to your catalogs. You can then use the sort_order value to program your storefront to display the variation options in the order that you want. The variation with the highest value of sort_order is displayed first. For example, a variation with a sort_order value of 3 appears before a variation with a sort_order value of 2. You can specify any numbers that you want. You can use 1, 2, 3, or 100, 90, 80, including, zero or negative numbers. You can set sort_order to either null or omit it entirely from the request if you wish to remove an existing sort_order attribute.

  • ]
  • ownerstring

    The owner of the resource, either organization or store.

    Possible values: [organization, store]

    created_atstring

    The date and time a variation is created.

    updated_atstring

    The date and time a variation is updated.

Authorization: http

name: bearerAuthtype: httpscheme: bearer
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Put, "https://euwest.api.elasticpath.com/pcm/variations/:variationID");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer <token>");
var content = new StringContent("{\n \"data\": {\n \"type\": \"product-variation\",\n \"attributes\": {\n \"name\": \"string\",\n \"sort_order\": 0\n },\n \"id\": \"00000000-0000-0000-0000-000000000000\"\n }\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
Request Collapse all
Base URL
https://euwest.api.elasticpath.com
Auth
Parameters
— pathrequired
Body
{
  "data": {
    "type": "product-variation",
    "attributes": {
      "name": "string",
      "sort_order": 0
    },
    "id": "00000000-0000-0000-0000-000000000000"
  }
}
ResponseClear

Click the Send API Request button above and see the response here!

We use cookies to enhance your experience. By continuing to visit this site you agree to our use of cookies.