> This page is for Developer.

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

# Create Product Variant Image

POST https://api.bigcommerce.com/stores/{store_hash}/v3/catalog/products/{product_id}/variants/{variant_id}/image
Content-Type: application/json

Creates a *Variant Image*.

Only one image can be explicitly associated with a Variant. If the Variant already has an associated image, overwrites the existing Variant Image.

The image displays on the storefront when the Variant is selected.

 **Required Fields**
- image_file: Form posts. Files larger than 1 MB are not accepted
- image_url: Any publicly available URL

Reference: https://docs.bigcommerce.com/developer/api-reference/rest/admin/catalog/product-variants/images/create-product-variant-image

## Authentication

- `X-Auth-Token` header (required) — ### OAuth scopes | UI Name | Permission | Parameter | |:--------|:-----------|:----------| | Products | modify | `store_v2_products` | | Products | read-only | `store_v2_products_read_only` | ### Authentication header | Header | Argument | Description | |:-------|:---------|:------------| | `X-Auth-Token` | `access_token` | For more about API accounts that generate `access_token`s, see our [Guide to API Accounts](/developer/docs/overview/api-fundamentals/api-accounts#api-accounts). | ### Further reading For example requests and more information about authenticating BigCommerce APIs, see [Authentication and Example Requests](/developer/docs/overview/api-fundamentals/api-accounts#x-auth-token-header-example-requests). For more about BigCommerce OAuth scopes, see our [Guide to API Accounts](/developer/docs/overview/api-fundamentals/api-accounts#oauth-scopes). For a list of API status codes, see [API Status Codes](/developer/api-reference/rest/overview#rest-http-status-codes).

## Request

### Path parameters

- `product_id` (integer, required) — The ID of the `Product` to which the resource belongs. Product variant metafield endpoints that have the `product_id` in the request path are successful as long as the parameter is not empty. The `product_id` segment is there only for path consistency.
- `variant_id` (integer, required) — ID of the variant on a product, or on an associated Price List Record.
- `store_hash` (string, required) — Permanent ID of the BigCommerce store.

### Headers

- `Accept` (string, required, default: application/json) — The [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) of the response body.

### Body (application/json)

This endpoint expects an object.

- `image_url` (string, optional) — A public URL for a GIF, JPEG, or PNG image. Limit of 8MB per file.

## Response

### 200

`image_url` is returned for both `image_file` and `image_url`.

- `data` (CatalogProductsProductIdVariantsVariantIdImagePostResponsesContentApplicationJsonSchemaData, optional) — An object containing a publicly accessible image URL, or a form post that contains an image file.
- `meta` (metaEmpty_Full, optional) — Response metadata.

## Errors

### 400 Bad Request Error

Bad Request. The requested resource could not be downloaded and may be invalid. Possible reasons include malformed request syntax or the file host blocking requests.

### 404 Not Found Error

The resource was not found.

- `status` (integer, optional) — 404 HTTP status code.
- `title` (string, optional) — The error title describing the particular error.
- `type` (string, optional)
- `instance` (string, optional)

### 422 Unprocessable Entity Error

Image was not valid. This is the result of a missing `image_file` field or of an incorrect file type. See the response for more details.

- `errors` (CatalogProductsProductIdVariantsVariantIdImagePostResponsesContentApplicationJsonSchemaErrors, optional)
- `instance` (string, optional)
- `status` (integer, optional) — The HTTP status code.
- `title` (string, optional) — The error title describing the particular error.
- `type` (string, optional)

### 500 Internal Server Error

Returns for an `image_file` larger than 1 MB.

- `errors` (CatalogProductsProductIdVariantsVariantIdImagePostResponsesContentApplicationJsonSchemaErrors, optional)
- `instance` (string, optional)
- `status` (integer, optional) — The HTTP status code.
- `title` (string, optional) — The error title describing the particular error.
- `type` (string, optional)

## Types

### CatalogProductsProductIdVariantsVariantIdImagePostResponsesContentApplicationJsonSchemaData

An object containing a publicly accessible image URL, or a form post that contains an image file.

- `image_url` (string, optional) — A public URL for a GIF, JPEG, or PNG image. Limit of 8MB per file.

### metaEmpty_Full

Response metadata.

### CatalogProductsProductIdVariantsVariantIdImagePostResponsesContentApplicationJsonSchemaErrors

## Examples

**Request**

```json
{
  "image_url": "https://example.com/path/to/variant-image.png"
}
```

**Response**

```json
{
  "data": {
    "image_url": "https://cdn8.bigcommerce.com/s-id30h7ohwf/product_images/attribute_rule_images/85_source_1536863430.png"
  },
  "meta": {}
}
```

**SDK Code**

```python Create a variant image (application/json)
import requests

url = "https://api.bigcommerce.com/stores/:store_hash/v3/catalog/products/:product_id/variants/:variant_id/image"

payload = { "image_url": "https://example.com/path/to/variant-image.png" }
headers = {
    "X-Auth-Token": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Create a variant image (application/json)
const url = 'https://api.bigcommerce.com/stores/:store_hash/v3/catalog/products/:product_id/variants/:variant_id/image';
const options = {
  method: 'POST',
  headers: {'X-Auth-Token': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"image_url":"https://example.com/path/to/variant-image.png"}'
};

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

```go Create a variant image (application/json)
package main

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

func main() {

	url := "https://api.bigcommerce.com/stores/:store_hash/v3/catalog/products/:product_id/variants/:variant_id/image"

	payload := strings.NewReader("{\n  \"image_url\": \"https://example.com/path/to/variant-image.png\"\n}")

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

	req.Header.Add("X-Auth-Token", "<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 Create a variant image (application/json)
require 'uri'
require 'net/http'

url = URI("https://api.bigcommerce.com/stores/:store_hash/v3/catalog/products/:product_id/variants/:variant_id/image")

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

request = Net::HTTP::Post.new(url)
request["X-Auth-Token"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"image_url\": \"https://example.com/path/to/variant-image.png\"\n}"

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

```java Create a variant image (application/json)
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.bigcommerce.com/stores/:store_hash/v3/catalog/products/:product_id/variants/:variant_id/image")
  .header("X-Auth-Token", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"image_url\": \"https://example.com/path/to/variant-image.png\"\n}")
  .asString();
```

```php Create a variant image (application/json)
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.bigcommerce.com/stores/:store_hash/v3/catalog/products/:product_id/variants/:variant_id/image', [
  'body' => '{
  "image_url": "https://example.com/path/to/variant-image.png"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-Auth-Token' => '<apiKey>',
  ],
]);

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

```csharp Create a variant image (application/json)
using RestSharp;

var client = new RestClient("https://api.bigcommerce.com/stores/:store_hash/v3/catalog/products/:product_id/variants/:variant_id/image");
var request = new RestRequest(Method.POST);
request.AddHeader("X-Auth-Token", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"image_url\": \"https://example.com/path/to/variant-image.png\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Create a variant image (application/json)
import Foundation

let headers = [
  "X-Auth-Token": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["image_url": "https://example.com/path/to/variant-image.png"] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.bigcommerce.com/stores/:store_hash/v3/catalog/products/:product_id/variants/:variant_id/image")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
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()
```