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

# Import product photos in a batch

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

Requires products:update. Accepts 1-25 images, up to 25 MB each and 100 MB total for files included in the request. Returns 202 after validating the submission and staging uploaded originals. Downloads, conversion, and final storage run in the background. Poll the returned statusUrl with the same API credential. Each image commits independently; individual failures do not undo successful images. Entries append in submission order unless positions are supplied. Use a batch with one entry for an asynchronous single upload. Supply Idempotency-Key when retrying submissions: the same credential, key, and payload reuse the import; a different payload returns 409. Use a new key to resubmit failed entries. Unfinished imports expire after seven days.

Reference: https://dev.rechain.co/api-reference/product-photo/bulk-create-product-photos

## Authentication

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

## Request

### Headers

- `Idempotency-Key` (string, optional) — Optional key, at most 200 bytes, scoped to the API credential. Reuse only with the same payload.

### Body (application/json)

This endpoint expects a ProductPhotoBatch.

- `productPhotos` (list of ProductPhotoCreateAttributes, required)

## Response

### 202

Batch accepted for background processing. Follow Location or statusUrl; this does not mean the images have finished importing.

- `id` (string, required)
- `state` (enum, required) — completed means every entry succeeded. failed may contain successful entries alongside failures.
  - Allowed values: `queued`, `processing`, `completed`, `failed`
- `total` (integer, required)
- `completed` (integer, required)
- `failed` (integer, required)
- `results` (list of ImageImportResultsItems, required) — Finished entries only; pending entries have no result yet.
- `statusUrl` (string, required) — Relative URL to poll with the same API credential that submitted the batch.

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

### ProductPhotoCreateAttributes

Provide exactly one base64 image data URI or image URL.

- ProductPhotoCreateFromFile: ProductPhotoCreateFromFile
- ProductPhotoCreateFromUrl: ProductPhotoCreateFromUrl

### ImageImportResultsItems

- CompletedImageImportResult: CompletedImageImportResult
- FailedImageImportResult: FailedImageImportResult

### ProductPhotoCreateFromFile

- `productId` (string, required) — ID of the product that owns the image.
- `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.
- `description` (string, optional) — Image caption.

### ProductPhotoCreateFromUrl

- `productId` (string, required) — ID of the product that owns the image.
- `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.
- `description` (string, optional) — Image caption.

### CompletedImageImportResult

- `index` (integer, required) — Zero-based index in the submitted array.
- `state` (enum, required)
  - Allowed values: `completed`
- `id` (string, required) — Created image ID. Fetch using the corresponding product_photos, variant_photos, or product_sketches endpoint.

### FailedImageImportResult

- `index` (integer, required) — Zero-based index in the submitted array.
- `state` (enum, required)
  - Allowed values: `failed`
- `error` (string, required)

## Examples

**Request**

```json
{
  "productPhotos": [
    {
      "file": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC",
      "fileUrl": "https://example.com/images/product_photos-front.png",
      "productId": "123e4567-e89b-12d3-a456-426614174000"
    },
    {
      "file": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC",
      "productId": "123e4567-e89b-12d3-a456-426614174000"
    }
  ]
}
```

**Response**

```json
{
  "id": "123e4567-e89b-12d3-a456-426614174005",
  "state": "queued",
  "total": 2,
  "completed": 0,
  "failed": 0,
  "results": [],
  "statusUrl": "/public/v1/image_imports/123e4567-e89b-12d3-a456-426614174005"
}
```

**SDK Code**

```python product_photo_bulkCreateProductPhotos_example (application/json)
import requests

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

payload = { "productPhotos": [
        {
            "file": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC",
            "fileUrl": "https://example.com/images/product_photos-front.png",
            "productId": "123e4567-e89b-12d3-a456-426614174000"
        },
        {
            "file": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC",
            "productId": "123e4567-e89b-12d3-a456-426614174000"
        }
    ] }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript product_photo_bulkCreateProductPhotos_example (application/json)
const url = 'https://api.rechain.co/public/v1/product_photos/bulk_create';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"productPhotos":[{"file":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC","fileUrl":"https://example.com/images/product_photos-front.png","productId":"123e4567-e89b-12d3-a456-426614174000"},{"file":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC","productId":"123e4567-e89b-12d3-a456-426614174000"}]}'
};

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

```go product_photo_bulkCreateProductPhotos_example (application/json)
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"productPhotos\": [\n    {\n      \"file\": \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC\",\n      \"fileUrl\": \"https://example.com/images/product_photos-front.png\",\n      \"productId\": \"123e4567-e89b-12d3-a456-426614174000\"\n    },\n    {\n      \"file\": \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC\",\n      \"productId\": \"123e4567-e89b-12d3-a456-426614174000\"\n    }\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 product_photo_bulkCreateProductPhotos_example (application/json)
require 'uri'
require 'net/http'

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

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  \"productPhotos\": [\n    {\n      \"file\": \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC\",\n      \"fileUrl\": \"https://example.com/images/product_photos-front.png\",\n      \"productId\": \"123e4567-e89b-12d3-a456-426614174000\"\n    },\n    {\n      \"file\": \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC\",\n      \"productId\": \"123e4567-e89b-12d3-a456-426614174000\"\n    }\n  ]\n}"

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

```java product_photo_bulkCreateProductPhotos_example (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/product_photos/bulk_create")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"productPhotos\": [\n    {\n      \"file\": \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC\",\n      \"fileUrl\": \"https://example.com/images/product_photos-front.png\",\n      \"productId\": \"123e4567-e89b-12d3-a456-426614174000\"\n    },\n    {\n      \"file\": \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC\",\n      \"productId\": \"123e4567-e89b-12d3-a456-426614174000\"\n    }\n  ]\n}")
  .asString();
```

```php product_photo_bulkCreateProductPhotos_example (application/json)
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.rechain.co/public/v1/product_photos/bulk_create', [
  'body' => '{
  "productPhotos": [
    {
      "file": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC",
      "fileUrl": "https://example.com/images/product_photos-front.png",
      "productId": "123e4567-e89b-12d3-a456-426614174000"
    },
    {
      "file": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC",
      "productId": "123e4567-e89b-12d3-a456-426614174000"
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp product_photo_bulkCreateProductPhotos_example (application/json)
using RestSharp;

var client = new RestClient("https://api.rechain.co/public/v1/product_photos/bulk_create");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"productPhotos\": [\n    {\n      \"file\": \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC\",\n      \"fileUrl\": \"https://example.com/images/product_photos-front.png\",\n      \"productId\": \"123e4567-e89b-12d3-a456-426614174000\"\n    },\n    {\n      \"file\": \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC\",\n      \"productId\": \"123e4567-e89b-12d3-a456-426614174000\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift product_photo_bulkCreateProductPhotos_example (application/json)
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["productPhotos": [
    [
      "file": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC",
      "fileUrl": "https://example.com/images/product_photos-front.png",
      "productId": "123e4567-e89b-12d3-a456-426614174000"
    ],
    [
      "file": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC",
      "productId": "123e4567-e89b-12d3-a456-426614174000"
    ]
  ]] as [String : Any]

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

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