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

# Bulk upsert variant values

PUT https://api.rechain.co/public/v1/variant_values/bulk_upsert
Content-Type: application/json

Create or update 1 to 100 colorway field values in one request. Each row identifies a value by `variantId` (the colorway's numeric ID or UUID), `variantFieldId`, and `seasonId` for seasonal fields. Rechain creates missing values and updates existing values. Each combination may appear once per request. Resending a batch with the same values preserves their IDs. The value writes run synchronously in one transaction. If a write fails, the entire batch rolls back.

Reference: https://dev.rechain.co/api-reference/variant-value/bulk-upsert-variant-values

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Body (application/json)

This endpoint expects a variant_value_bulkUpsertVariantValues_Request.

- `variant_value_bulkUpsertVariantValues_Request`
  - VariantValueBulkUpsertBatch: list of VariantValueBulkUpsertEntry
  - VariantValueBulkUpsertVariantValuesRequest1

## Response

### 200

Saved variant values in request order, including their value IDs

- `list of VariantValueResponse`

## Errors

### 401 Unauthorized Error

Unauthorized

- `any`

### 403 Forbidden Error

The API key lacks product update permission

- `any`

### 404 Not Found Error

A colorway, field, or season was not found in the API key's company

- `any`

### 422 Unprocessable Entity Error

The batch size, row contents, season, or combination of colorway, field, and season is invalid

- `any`

## Types

### VariantValueBulkUpsertEntry

- `variantId` (VariantValueColorwayIdentifier, required) — Numeric ID or UUID of the colorway, as returned by `GET /variants`.
- `variantFieldId` (string, required) — ID of the colorway field from `GET /variant_fields`.
- `content` (string, required) — Value to save. Provide non-blank content.
- `seasonId` (string, optional, nullable) — ID from `GET /seasons`. Required for seasonal fields. Omit or pass null for shared fields.

### VariantValueBulkUpsertVariantValuesRequest1

- `variantValues` (list of VariantValueBulkUpsertEntry, required)

### VariantValueResponse

- `id` (string, optional)
- `content` (string, optional)
- `variantId` (integer, optional)
- `variantFieldId` (string, optional)
- `seasonId` (string, optional, nullable) — Season ID for this value, or null when the value has no season.
- `createdAt` (datetime, optional)
- `updatedAt` (datetime, optional)

### VariantValueColorwayIdentifier

Numeric ID or UUID of the colorway, as returned by `GET /variants`.

- integer
- string

## Examples

**Request**

```json
[
  {
    "content": "42.00",
    "seasonId": "c27ef40a-2d1f-4b05-9db9-86c8b1f22170",
    "variantFieldId": "d3c46e1b-2d92-4d5d-9e98-3e6b0d4b9791",
    "variantId": "9e1fb7c0-593e-4cba-a84e-49ae17e8bbcb"
  },
  {
    "content": "32.00",
    "seasonId": "c27ef40a-2d1f-4b05-9db9-86c8b1f22170",
    "variantFieldId": "d3c46e1b-2d92-4d5d-9e98-3e6b0d4b9791",
    "variantId": 124
  }
]
```

**Response**

```json
[
  {
    "id": "string",
    "content": "string",
    "variantId": 1,
    "variantFieldId": "string",
    "seasonId": "string",
    "createdAt": "2024-01-15T09:30:00Z",
    "updatedAt": "2024-01-15T09:30:00Z"
  }
]
```

**SDK Code**

```python variant_value_bulkUpsertVariantValues_example
import requests

url = "https://api.rechain.co/public/v1/variant_values/bulk_upsert"

payload = [
    {
        "content": "42.00",
        "seasonId": "c27ef40a-2d1f-4b05-9db9-86c8b1f22170",
        "variantFieldId": "d3c46e1b-2d92-4d5d-9e98-3e6b0d4b9791",
        "variantId": "9e1fb7c0-593e-4cba-a84e-49ae17e8bbcb"
    },
    {
        "content": "32.00",
        "seasonId": "c27ef40a-2d1f-4b05-9db9-86c8b1f22170",
        "variantFieldId": "d3c46e1b-2d92-4d5d-9e98-3e6b0d4b9791",
        "variantId": 124
    }
]
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript variant_value_bulkUpsertVariantValues_example
const url = 'https://api.rechain.co/public/v1/variant_values/bulk_upsert';
const options = {
  method: 'PUT',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '[{"content":"42.00","seasonId":"c27ef40a-2d1f-4b05-9db9-86c8b1f22170","variantFieldId":"d3c46e1b-2d92-4d5d-9e98-3e6b0d4b9791","variantId":"9e1fb7c0-593e-4cba-a84e-49ae17e8bbcb"},{"content":"32.00","seasonId":"c27ef40a-2d1f-4b05-9db9-86c8b1f22170","variantFieldId":"d3c46e1b-2d92-4d5d-9e98-3e6b0d4b9791","variantId":124}]'
};

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

```go variant_value_bulkUpsertVariantValues_example
package main

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

func main() {

	url := "https://api.rechain.co/public/v1/variant_values/bulk_upsert"

	payload := strings.NewReader("[\n  {\n    \"content\": \"42.00\",\n    \"seasonId\": \"c27ef40a-2d1f-4b05-9db9-86c8b1f22170\",\n    \"variantFieldId\": \"d3c46e1b-2d92-4d5d-9e98-3e6b0d4b9791\",\n    \"variantId\": \"9e1fb7c0-593e-4cba-a84e-49ae17e8bbcb\"\n  },\n  {\n    \"content\": \"32.00\",\n    \"seasonId\": \"c27ef40a-2d1f-4b05-9db9-86c8b1f22170\",\n    \"variantFieldId\": \"d3c46e1b-2d92-4d5d-9e98-3e6b0d4b9791\",\n    \"variantId\": 124\n  }\n]")

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

	req.Header.Add("Authorization", "Bearer <token>")
	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 variant_value_bulkUpsertVariantValues_example
require 'uri'
require 'net/http'

url = URI("https://api.rechain.co/public/v1/variant_values/bulk_upsert")

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

request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "[\n  {\n    \"content\": \"42.00\",\n    \"seasonId\": \"c27ef40a-2d1f-4b05-9db9-86c8b1f22170\",\n    \"variantFieldId\": \"d3c46e1b-2d92-4d5d-9e98-3e6b0d4b9791\",\n    \"variantId\": \"9e1fb7c0-593e-4cba-a84e-49ae17e8bbcb\"\n  },\n  {\n    \"content\": \"32.00\",\n    \"seasonId\": \"c27ef40a-2d1f-4b05-9db9-86c8b1f22170\",\n    \"variantFieldId\": \"d3c46e1b-2d92-4d5d-9e98-3e6b0d4b9791\",\n    \"variantId\": 124\n  }\n]"

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

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

HttpResponse<String> response = Unirest.put("https://api.rechain.co/public/v1/variant_values/bulk_upsert")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("[\n  {\n    \"content\": \"42.00\",\n    \"seasonId\": \"c27ef40a-2d1f-4b05-9db9-86c8b1f22170\",\n    \"variantFieldId\": \"d3c46e1b-2d92-4d5d-9e98-3e6b0d4b9791\",\n    \"variantId\": \"9e1fb7c0-593e-4cba-a84e-49ae17e8bbcb\"\n  },\n  {\n    \"content\": \"32.00\",\n    \"seasonId\": \"c27ef40a-2d1f-4b05-9db9-86c8b1f22170\",\n    \"variantFieldId\": \"d3c46e1b-2d92-4d5d-9e98-3e6b0d4b9791\",\n    \"variantId\": 124\n  }\n]")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://api.rechain.co/public/v1/variant_values/bulk_upsert', [
  'body' => '[
  {
    "content": "42.00",
    "seasonId": "c27ef40a-2d1f-4b05-9db9-86c8b1f22170",
    "variantFieldId": "d3c46e1b-2d92-4d5d-9e98-3e6b0d4b9791",
    "variantId": "9e1fb7c0-593e-4cba-a84e-49ae17e8bbcb"
  },
  {
    "content": "32.00",
    "seasonId": "c27ef40a-2d1f-4b05-9db9-86c8b1f22170",
    "variantFieldId": "d3c46e1b-2d92-4d5d-9e98-3e6b0d4b9791",
    "variantId": 124
  }
]',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp variant_value_bulkUpsertVariantValues_example
using RestSharp;

var client = new RestClient("https://api.rechain.co/public/v1/variant_values/bulk_upsert");
var request = new RestRequest(Method.PUT);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "[\n  {\n    \"content\": \"42.00\",\n    \"seasonId\": \"c27ef40a-2d1f-4b05-9db9-86c8b1f22170\",\n    \"variantFieldId\": \"d3c46e1b-2d92-4d5d-9e98-3e6b0d4b9791\",\n    \"variantId\": \"9e1fb7c0-593e-4cba-a84e-49ae17e8bbcb\"\n  },\n  {\n    \"content\": \"32.00\",\n    \"seasonId\": \"c27ef40a-2d1f-4b05-9db9-86c8b1f22170\",\n    \"variantFieldId\": \"d3c46e1b-2d92-4d5d-9e98-3e6b0d4b9791\",\n    \"variantId\": 124\n  }\n]", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift variant_value_bulkUpsertVariantValues_example
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  [
    "content": "42.00",
    "seasonId": "c27ef40a-2d1f-4b05-9db9-86c8b1f22170",
    "variantFieldId": "d3c46e1b-2d92-4d5d-9e98-3e6b0d4b9791",
    "variantId": "9e1fb7c0-593e-4cba-a84e-49ae17e8bbcb"
  ],
  [
    "content": "32.00",
    "seasonId": "c27ef40a-2d1f-4b05-9db9-86c8b1f22170",
    "variantFieldId": "d3c46e1b-2d92-4d5d-9e98-3e6b0d4b9791",
    "variantId": 124
  ]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.rechain.co/public/v1/variant_values/bulk_upsert")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
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()
```