> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.ordergroove.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.ordergroove.com/_mcp/server.

# Create or update price codes

PATCH https://restapi.ordergroove.com/products/{product_id}/price_codes/
Content-Type: application/json

Creates or updates price codes for a product and returns the product's complete set of price codes afterwards, ordered by `price_code`.

Each entry is matched on `price_code`: an existing price code has its `price` replaced, and an unknown one is created. Price codes that are not sent are left unchanged, so this endpoint never removes a price code. Use `DELETE /products/{product_id}/price_codes/{price_code}/` to remove one.

A request carries at most 100 price codes. Each `price_code` is trimmed of surrounding whitespace and compared case-insensitively, so sending both `Cust_1` and `cust_1` in the same request returns `400`. The request is applied in a single transaction: if any entry is rejected, nothing is written. A successful call also updates the product's `last_update` timestamp so the change is picked up by catalog syncs ordered on it. Changing a price code does not trigger a product webhook.

Writing price codes requires Application API Scope. A Storefront API Scope request returns `403`.

Reference: https://docs.ordergroove.com/reference/rest-rpc-api/products/product-price-codes-upsert

## Authentication

- `x-api-key` header (required)

## Request

### Path parameters

- `product_id` (string, required) — Merchant product ID

### Body (application/json)

- `price_codes` (list of object, required) — Price codes to create or update. At least one entry, and at most 100.
  - `price_code` (string, required) — Price code to map the price to. Up to 100 characters after surrounding whitespace is trimmed, and cannot be empty. Cannot contain `/` or control characters. Any other string is accepted: Ordergroove matches the code exactly, so the `Cust_` prefix for customer-driven codes and the `Ship_` prefix for shipping-address-driven codes are a convention rather than a requirement.
  - `price` (string, required) — Price to charge for the product when this price code applies. A decimal with at most two decimal places and at most 10 digits in total, and cannot be negative or `null`. A price is never rounded on your behalf, so `24.905` is rejected. To stop charging a price code, delete it rather than sending an empty price.

## Response

### 200

200

- `price_codes` (list of object, required) — Price codes configured for the product, ordered by `price_code`.
  - `price_code` (string, required) — Price code the price is mapped to. Up to 100 characters. Matching is case-insensitive, so `Cust_1` and `cust_1` are the same price code.
  - `price` (string, required, nullable) — Price charged for the product when this price code applies, as a decimal string with two decimal places. `null` on price codes created by a product feed without a price; a price code written through this API always has a price.

## Examples

**Request**

```json
{
  "price_codes": [
    {
      "price_code": "Cust_1",
      "price": "24.90"
    },
    {
      "price_code": "Ship_US",
      "price": "26.00"
    }
  ]
}
```

**Response**

```json
{
  "price_codes": [
    {
      "price_code": "Cust_1",
      "price": "24.90"
    },
    {
      "price_code": "Ship_US",
      "price": "26.00"
    }
  ]
}
```

**SDK Code**

```python Result
import requests

url = "https://restapi.ordergroove.com/products/product_id/price_codes/"

payload = { "price_codes": [
        {
            "price_code": "Cust_1",
            "price": "24.90"
        },
        {
            "price_code": "Ship_US",
            "price": "26.00"
        }
    ] }
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.json())
```

```javascript Result
const url = 'https://restapi.ordergroove.com/products/product_id/price_codes/';
const options = {
  method: 'PATCH',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"price_codes":[{"price_code":"Cust_1","price":"24.90"},{"price_code":"Ship_US","price":"26.00"}]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Result
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://restapi.ordergroove.com/products/product_id/price_codes/"

	payload := strings.NewReader("{\n  \"price_codes\": [\n    {\n      \"price_code\": \"Cust_1\",\n      \"price\": \"24.90\"\n    },\n    {\n      \"price_code\": \"Ship_US\",\n      \"price\": \"26.00\"\n    }\n  ]\n}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Result
require 'uri'
require 'net/http'

url = URI("https://restapi.ordergroove.com/products/product_id/price_codes/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"price_codes\": [\n    {\n      \"price_code\": \"Cust_1\",\n      \"price\": \"24.90\"\n    },\n    {\n      \"price_code\": \"Ship_US\",\n      \"price\": \"26.00\"\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java Result
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://restapi.ordergroove.com/products/product_id/price_codes/")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"price_codes\": [\n    {\n      \"price_code\": \"Cust_1\",\n      \"price\": \"24.90\"\n    },\n    {\n      \"price_code\": \"Ship_US\",\n      \"price\": \"26.00\"\n    }\n  ]\n}")
  .asString();
```

```php Result
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://restapi.ordergroove.com/products/product_id/price_codes/', [
  'body' => '{
  "price_codes": [
    {
      "price_code": "Cust_1",
      "price": "24.90"
    },
    {
      "price_code": "Ship_US",
      "price": "26.00"
    }
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Result
using RestSharp;

var client = new RestClient("https://restapi.ordergroove.com/products/product_id/price_codes/");
var request = new RestRequest(Method.PATCH);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"price_codes\": [\n    {\n      \"price_code\": \"Cust_1\",\n      \"price\": \"24.90\"\n    },\n    {\n      \"price_code\": \"Ship_US\",\n      \"price\": \"26.00\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Result
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["price_codes": [
    [
      "price_code": "Cust_1",
      "price": "24.90"
    ],
    [
      "price_code": "Ship_US",
      "price": "26.00"
    ]
  ]] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://restapi.ordergroove.com/products/product_id/price_codes/")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```