# Update a price variant

> For the complete machine-readable documentation index, see [llms.txt](https://apidocs.chargebee.com/llms.txt).


[Idempotency Supported](/docs/api/idempotency)

This endpoint modifies the details of an existing price variant.

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/price_variants/germany-munich \
     -u {site_api_key}:\
     -d name="Germany Munich - Web Sales" \
     -d "attributes[name][0]"="country" \
     -d "attributes[value][0]"="germany" \
     -d "attributes[name][1]"="city" \
     -d "attributes[value][1]"="munich" \
     -d "attributes[name][2]"="channel" \
     -d "attributes[value][2]"="web"
```

#### .NET

```dotnet
using ChargeBee.Api;
using ChargeBee.Models;

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = PriceVariant.Update("germany-munich")
		.Name("Germany Munich - Web Sales")
		.AttributeName(0, "country")
		.AttributeValue(0, "germany")
		.AttributeName(1, "city")
		.AttributeValue(1, "munich")
		.AttributeName(2, "channel")
		.AttributeValue(2, "web")
		.Request();

PriceVariant priceVariant = result.PriceVariant;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    pricevariantAction "github.com/chargebee/chargebee-go/v3/actions/pricevariant"
    "github.com/chargebee/chargebee-go/v3/models/pricevariant"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := pricevariantAction.Update("germany-munich", &pricevariant.UpdateRequestParams{
        Attributes : []*pricevariant.UpdateAttributeParams{
            {
                Name : "country",
                Value : "germany",
            },
            {
                Name : "city",
                Value : "munich",
            },
            {
                Name : "channel",
                Value : "web",
            },
        },
        Name : "Germany Munich - Web Sales",
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        PriceVariant := res.PriceVariant
    }
}
```

#### Go

```go
package main

import (
  "fmt"
  "github.com/chargebee/chargebee-go/v4"
)

func main() {
  config := &chargebee.ClientConfig{
    SiteName: "{site}",
    ApiKey: "{site_api_key}",
  }    
  client := chargebee.NewClient(config)
  req := &chargebee.PriceVariantUpdateRequest{
    Attributes : []*chargebee.PriceVariantUpdateAttribute{
        {
            Name : "country",
            Value : "germany",
        },
        {
            Name : "city",
            Value : "munich",
        },
        {
            Name : "channel",
            Value : "web",
        },
    },
    Name : "Germany Munich - Web Sales",
}
  res, err := client.PriceVariant.Update("germany-munich", req)
      if err != nil {
        fmt.Println(err)
    } else {
        PriceVariant := res.PriceVariant
    }
}
```

#### Java

```java
import com.chargebee.*;
import com.chargebee.ListResult;
import com.chargebee.models.*;
import com.chargebee.models.enums.*;
import java.io.IOException;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = PriceVariant.update("germany-munich")
            .name("Germany Munich - Web Sales")
            .attributeName(0, "country")
            .attributeValue(0, "germany")
            .attributeName(1, "city")
            .attributeValue(1, "munich")
            .attributeName(2, "channel")
            .attributeValue(2, "web")
            .request();

        PriceVariant priceVariant = result.priceVariant();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.priceVariant.PriceVariant;
import com.chargebee.v4.models.priceVariant.params.PriceVariantUpdateParams;
import com.chargebee.v4.models.priceVariant.responses.PriceVariantUpdateResponse;
import java.util.List;

public class PriceVariantUpdate {

    public static void main(String[] args) {
        ChargebeeClient client = ChargebeeClient.builder()
            .apiKey("{site_api_key}")
            .siteName("{site}")
            .build();

        PriceVariantUpdateParams.AttributesParams attribute0 =
            PriceVariantUpdateParams.AttributesParams.builder()
                .name("country")
                .value("germany")
                .build();

        PriceVariantUpdateParams.AttributesParams attribute1 =
            PriceVariantUpdateParams.AttributesParams.builder()
                .name("city")
                .value("munich")
                .build();

        PriceVariantUpdateParams.AttributesParams attribute2 =
            PriceVariantUpdateParams.AttributesParams.builder()
                .name("channel")
                .value("web")
                .build();

        List<PriceVariantUpdateParams.AttributesParams> attributesList =
            List.of(attribute0, attribute1, attribute2);

        PriceVariantUpdateParams params = PriceVariantUpdateParams.builder()
            .name("Germany Munich - Web Sales")
            .attributes(attributesList)
            .build();

        PriceVariantUpdateResponse response = client
            .priceVariants()
            .update("germany-munich", params);

        PriceVariant priceVariant = response.getPriceVariant();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

const chargebee = new Chargebee({
    site: "{site}",
    apiKey: "{site_api_key}",
});

try {
    const result = await chargebee.priceVariant.update("germany-munich", {
        attributes: [
            {
                name: "country",
                value: "germany"
            },
            {
                name: "city",
                value: "munich"
            },
            {
                name: "channel",
                value: "web"
            }
        ],
        name: "Germany Munich - Web Sales"
    });

    console.log(result);
    const priceVariant = result.price_variant;
} catch (err) {
    console.log(err);
}
```

#### PHP

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use Chargebee\ChargebeeClient;

$chargebee = new ChargebeeClient(options: [
    "site" => "{site}",
    "apiKey" => "{site_api_key}",
]);
$result = $chargebee->priceVariant()->update("germany-munich", [
    "attributes" => [
        [
            "name" => "country",
            "value" => "germany"
        ],
        [
            "name" => "city",
            "value" => "munich"
        ],
        [
            "name" => "channel",
            "value" => "web"
        ]
    ],
    "name" => "Germany Munich - Web Sales"
]);
$priceVariant = $result->price_variant;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.PriceVariant.update("germany-munich",
    cb_client.PriceVariant.UpdateParams(
        attributes=[
            cb_client.PriceVariant.UpdateAttributeParams(
              name="country",
              value="germany"
            ),
            cb_client.PriceVariant.UpdateAttributeParams(
              name="city",
              value="munich"
            ),
            cb_client.PriceVariant.UpdateAttributeParams(
              name="channel",
              value="web"
            )
        ],
        name="Germany Munich - Web Sales"
    )
)
price_variant = response.price_variant
```

#### Ruby

```ruby
require 'chargebee'

ChargeBee.configure(:site => "{site}",
  :api_key => "{site_api_key}")

result = ChargeBee::PriceVariant.update("germany-munich",{
  :name => "Germany Munich - Web Sales",
  :attributes => [
    {
      :name => "country",
      :value => "germany"
    },
    {
      :name => "city",
      :value => "munich"
    },
    {
      :name => "channel",
      :value => "web"
    }
  ]
})

price_variant = result.price_variant
```

## Sample Response

```json
{
  "price_variant": {
    "updated_at": 1709200387,
    "name": "Germany Munich - Web Sales",
    "created_at": 1709200386,
    "attributes": [
      {
        "name": "country",
        "value": "germany"
      },
      {..}
    ],
    "id": "germany-munich",
    "external_name": "Germany",
    "resource_version": 1709200387080,
    "status": "active",
    "object": "price_variant"
  }
}
```

## URL Format

**POST** https://[site].chargebee.com/api/v2/price_variants/{price-variant-id}

## Input Parameters

- `name` (optional, string, max chars=100)
  A unique name of the price variant.

- `external_name` (optional, string, max chars=100)
  A unique display name for the price variant.

- `description` (optional, string, max chars=500)
  Description of the price variant.

- `variant_group` (optional, string, max chars=100)
  The `variant_group` organizes similar `[price_variants](/docs/api/price_variants)` to optimize strategies such as bundling, geo-based pricing experiments, and campaign-specific pricing like `cb-atomic-pricing-` for effective grouping. The `variant_group` provides greater flexibility and precision in your pricing models.

- `status` (optional, enumerated string)
  Status of a price variant.
  Possible enum values:
    - `active`
      Active price variant. This price variant can be attached to [item prices](/docs/api/item_prices) .
    - `archived`
      Archived price variant. This price variant is no longer `active` and cannot be attached to new [item prices](/docs/api/item_prices). Existing item prices that already have this price variant attached will continue to remain as is.

- `attributes` (optional, array)
  The list of price variant attribute values. Attributes can be used to store additional information about the price variant. For example, for a price variant called 'Germany', the attributes can be 'Country':'Germany', 'City':'Berlin' and so on.
  - `name` (required, string, max chars=100)
    Attribute name
  - `value` (required, string, max chars=100)
    Attribute value

## Returns

- `price_variant` (Price variant object)
  Resource object representing price\_variant
