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

# Update a product photo (PATCH)

PATCH https://api.rechain.co/public/v1/product_photos/{id}
Content-Type: application/json

Requires products:update. Replaces the image or edits its metadata; omitted fields are preserved and the parent cannot be changed. 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. Concurrent edits during upload return 409; retry against the current image. Failed uploads preserve the existing image. PUT and PATCH accept the same partial-update fields.

Reference: https://dev.rechain.co/api-reference/product-photo/patch-product-photo

## Authentication

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

## Request

### Path parameters

- `id` (string, required) — Image ID returned by an image endpoint or a completed batch result.

### Body (application/json)

This endpoint expects a ProductPhotoUpdate.

- `productPhoto` (ProductPhotoUpdateAttributes, required)

## Response

### 200

Image updated.

- `id` (string, optional)
- `productId` (string, optional) — ID of the product that owns the image.
- `fileUrl` (string, optional, nullable)
- `position` (integer, optional)
- `createdAt` (datetime, optional)
- `updatedAt` (datetime, optional)
- `description` (string, optional, nullable)

## 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`

### 409 Conflict Error

The image changed during upload, or this idempotency key was already used with a different batch payload.

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

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

### ProductPhotoUpdateAttributes

- `file` (string, optional) — Base64 image data URI, including the data:image/...;base64, prefix. Use multipart/form-data for a binary file. Maximum 25 MB decoded.
- `fileUrl` (string, optional) — Public HTTP(S) image URL. The server downloads and stores the image; private/local network destinations are blocked.
- `position` (integer, optional) — New non-negative position. Omit to keep the current position.
- `description` (string, optional) — Image caption.

## Examples

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

**Request**

```json
{
  "productPhoto": {
    "fileUrl": "https://example.com/images/product_photos-front.png"
  }
}
```

**Response**

```json
{
  "id": "123e4567-e89b-12d3-a456-426614174001",
  "productId": "123e4567-e89b-12d3-a456-426614174000",
  "fileUrl": "https://files.rechain.co/images/product_photos-front.jpg",
  "position": 0,
  "createdAt": "2026-10-28T12:00:00Z",
  "updatedAt": "2026-10-28T12:00:00Z",
  "description": "Front view"
}
```

**SDK Code**

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

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

payload = { "productPhoto": { "fileUrl": "https://example.com/images/product_photos-front.png" } }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Upload from an image URL (application/json)
const url = 'https://api.rechain.co/public/v1/product_photos/:id';
const options = {
  method: 'PATCH',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"productPhoto":{"fileUrl":"https://example.com/images/product_photos-front.png"}}'
};

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/product_photos/:id"

	payload := strings.NewReader("{\n  \"productPhoto\": {\n    \"fileUrl\": \"https://example.com/images/product_photos-front.png\"\n  }\n}")

	req, _ := http.NewRequest("PATCH", 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/product_photos/:id")

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

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"productPhoto\": {\n    \"fileUrl\": \"https://example.com/images/product_photos-front.png\"\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.patch("https://api.rechain.co/public/v1/product_photos/:id")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"productPhoto\": {\n    \"fileUrl\": \"https://example.com/images/product_photos-front.png\"\n  }\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.rechain.co/public/v1/product_photos/:id', [
  'body' => '{
  "productPhoto": {
    "fileUrl": "https://example.com/images/product_photos-front.png"
  }
}',
  '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/product_photos/:id");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"productPhoto\": {\n    \"fileUrl\": \"https://example.com/images/product_photos-front.png\"\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 = ["productPhoto": ["fileUrl": "https://example.com/images/product_photos-front.png"]] as [String : Any]

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

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

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

**Request**

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

**Response**

```json
{
  "id": "123e4567-e89b-12d3-a456-426614174001",
  "productId": "123e4567-e89b-12d3-a456-426614174000",
  "fileUrl": "https://files.rechain.co/images/product_photos-front.jpg",
  "position": 0,
  "createdAt": "2026-10-28T12:00:00Z",
  "updatedAt": "2026-10-28T12:00:00Z",
  "description": "Front view"
}
```

**SDK Code**

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

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

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

response = requests.patch(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/product_photos/:id';
const options = {
  method: 'PATCH',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"productPhoto":{"file":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC"}}'
};

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/product_photos/:id"

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

	req, _ := http.NewRequest("PATCH", 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/product_photos/:id")

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

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"productPhoto\": {\n    \"file\": \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC\"\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.patch("https://api.rechain.co/public/v1/product_photos/:id")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"productPhoto\": {\n    \"file\": \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC\"\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('PATCH', 'https://api.rechain.co/public/v1/product_photos/:id', [
  'body' => '{
  "productPhoto": {
    "file": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC"
  }
}',
  '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/product_photos/:id");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"productPhoto\": {\n    \"file\": \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC\"\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 = ["productPhoto": ["file": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC"]] as [String : Any]

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

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