> 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.

# Upload a colorway photo

POST https://api.rechain.co/public/v1/variant_photos
Content-Type: application/json

Requires products:update. Creates a new image and appends it by default. Provide exactly one image file or image URL when uploading. Binary files use multipart/form-data; HTTP(S) URLs or base64 image data URIs use application/json. Single uploads complete processing before returning. Maximum 25 MB per image. Image writes update the parent product updatedAt. Position 0 must be a static image. GIFs are allowed at later positions. Use the numeric variant id, not its uuid. Replacements refresh contentType before validating this rule.

Reference: https://dev.rechain.co/api-reference/variant-photo/create-variant-photo

## 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 VariantPhotoCreate.

- `variantPhoto` (VariantPhotoCreateAttributes, required) — Provide exactly one base64 image data URI or image URL.

## Response

### 201

Image created.

- `id` (string, optional)
- `variantId` (long, optional) — Numeric colorway id, not its separate uuid field.
- `fileUrl` (string, optional, nullable)
- `position` (integer, optional)
- `createdAt` (datetime, optional)
- `updatedAt` (datetime, optional)
- `contentType` (string, optional, nullable) — Media type of the stored file; refreshed when the file is replaced.
- `seasonIds` (list of string, optional)

## Errors

### 401 Unauthorized Error

Missing, invalid, or revoked API credential.

- `any`

### 403 Forbidden Error

The credential does not allow this product operation.

- `any`

### 404 Not Found Error

The record does not exist or is outside the credential's company/product scope.

- `any`

### 422 Unprocessable Entity Error

Invalid parameters, conflicting image sources, size limits, failed download, or invalid image content.

- `errors` (list of string, optional)
- `error` (string, optional)

## Types

### VariantPhotoCreateAttributes

Provide exactly one base64 image data URI or image URL.

- VariantPhotoCreateFromFile: VariantPhotoCreateFromFile
- VariantPhotoCreateFromUrl: VariantPhotoCreateFromUrl

### VariantPhotoCreateFromFile

- `variantId` (long, required) — Numeric colorway id, not its separate uuid field.
- `file` (string, required) — Base64 image data URI, including the data:image/...;base64, prefix. Use multipart/form-data for a binary file. Maximum 25 MB decoded.
- `position` (integer, optional) — Omit to append after the highest existing position. Explicit positions do not automatically shift other images.

### VariantPhotoCreateFromUrl

- `variantId` (long, required) — Numeric colorway id, not its separate uuid field.
- `fileUrl` (string, required) — Public HTTP(S) image URL. The server downloads and stores the image; private/local network destinations are blocked.
- `position` (integer, optional) — Omit to append after the highest existing position. Explicit positions do not automatically shift other images.

## Examples

### Upload from an image URL (application/json)

**Request**

```json
{
  "variantPhoto": {
    "file": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC",
    "fileUrl": "https://example.com/images/variant_photos-front.png",
    "variantId": 201
  }
}
```

**Response**

```json
{
  "id": "123e4567-e89b-12d3-a456-426614174001",
  "variantId": 201,
  "fileUrl": "https://files.rechain.co/images/variant_photos-front.jpg",
  "position": 0,
  "createdAt": "2026-10-28T12:00:00Z",
  "updatedAt": "2026-10-28T12:00:00Z",
  "contentType": "image/jpeg",
  "seasonIds": []
}
```

**SDK Code**

```python Upload from an image URL (application/json)
import requests

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

payload = { "variantPhoto": {
        "file": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC",
        "fileUrl": "https://example.com/images/variant_photos-front.png",
        "variantId": 201
    } }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Upload from an image URL (application/json)
const url = 'https://api.rechain.co/public/v1/variant_photos';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"variantPhoto":{"file":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC","fileUrl":"https://example.com/images/variant_photos-front.png","variantId":201}}'
};

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

```go Upload from an image URL (application/json)
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"variantPhoto\": {\n    \"file\": \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC\",\n    \"fileUrl\": \"https://example.com/images/variant_photos-front.png\",\n    \"variantId\": 201\n  }\n}")

	req, _ := http.NewRequest("POST", 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 Upload from an image URL (application/json)
require 'uri'
require 'net/http'

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

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"variantPhoto\": {\n    \"file\": \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC\",\n    \"fileUrl\": \"https://example.com/images/variant_photos-front.png\",\n    \"variantId\": 201\n  }\n}"

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

```java Upload from an image URL (application/json)
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.rechain.co/public/v1/variant_photos")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"variantPhoto\": {\n    \"file\": \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC\",\n    \"fileUrl\": \"https://example.com/images/variant_photos-front.png\",\n    \"variantId\": 201\n  }\n}")
  .asString();
```

```php Upload from an image URL (application/json)
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.rechain.co/public/v1/variant_photos', [
  'body' => '{
  "variantPhoto": {
    "file": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC",
    "fileUrl": "https://example.com/images/variant_photos-front.png",
    "variantId": 201
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Upload from an image URL (application/json)
using RestSharp;

var client = new RestClient("https://api.rechain.co/public/v1/variant_photos");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"variantPhoto\": {\n    \"file\": \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC\",\n    \"fileUrl\": \"https://example.com/images/variant_photos-front.png\",\n    \"variantId\": 201\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Upload from an image URL (application/json)
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["variantPhoto": [
    "file": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC",
    "fileUrl": "https://example.com/images/variant_photos-front.png",
    "variantId": 201
  ]] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.rechain.co/public/v1/variant_photos")! 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()
```

### Upload a base64 image data URI (application/json)

**Request**

```json
{
  "variantPhoto": {
    "file": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC",
    "variantId": 201
  }
}
```

**Response**

```json
{
  "id": "123e4567-e89b-12d3-a456-426614174001",
  "variantId": 201,
  "fileUrl": "https://files.rechain.co/images/variant_photos-front.jpg",
  "position": 0,
  "createdAt": "2026-10-28T12:00:00Z",
  "updatedAt": "2026-10-28T12:00:00Z",
  "contentType": "image/jpeg",
  "seasonIds": []
}
```

**SDK Code**

```python Upload a base64 image data URI (application/json)
import requests

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

payload = { "variantPhoto": {
        "file": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC",
        "variantId": 201
    } }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Upload a base64 image data URI (application/json)
const url = 'https://api.rechain.co/public/v1/variant_photos';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"variantPhoto":{"file":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC","variantId":201}}'
};

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

```go Upload a base64 image data URI (application/json)
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"variantPhoto\": {\n    \"file\": \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC\",\n    \"variantId\": 201\n  }\n}")

	req, _ := http.NewRequest("POST", 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 Upload a base64 image data URI (application/json)
require 'uri'
require 'net/http'

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

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"variantPhoto\": {\n    \"file\": \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC\",\n    \"variantId\": 201\n  }\n}"

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

```java Upload a base64 image data URI (application/json)
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.rechain.co/public/v1/variant_photos")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"variantPhoto\": {\n    \"file\": \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC\",\n    \"variantId\": 201\n  }\n}")
  .asString();
```

```php Upload a base64 image data URI (application/json)
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.rechain.co/public/v1/variant_photos', [
  'body' => '{
  "variantPhoto": {
    "file": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC",
    "variantId": 201
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Upload a base64 image data URI (application/json)
using RestSharp;

var client = new RestClient("https://api.rechain.co/public/v1/variant_photos");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"variantPhoto\": {\n    \"file\": \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC\",\n    \"variantId\": 201\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Upload a base64 image data URI (application/json)
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["variantPhoto": [
    "file": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC",
    "variantId": 201
  ]] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.rechain.co/public/v1/variant_photos")! 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()
```