Skip to main content
PATCH
/
v1
/
product_medias
/
{id}
Update
curl --request PATCH \
  --url https://{defaultHost}/v1/product_medias/{id} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "product_media": {
    "position": 1
  }
}
'
import requests

url = "https://{defaultHost}/v1/product_medias/{id}"

payload = { "product_media": { "position": 1 } }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

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

print(response.text)
const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({product_media: {position: 1}})
};

fetch('https://{defaultHost}/v1/product_medias/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://{defaultHost}/v1/product_medias/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'product_media' => [
'position' => 1
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

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

func main() {

url := "https://{defaultHost}/v1/product_medias/{id}"

payload := strings.NewReader("{\n \"product_media\": {\n \"position\": 1\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(string(body))

}
HttpResponse<String> response = Unirest.patch("https://{defaultHost}/v1/product_medias/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"product_media\": {\n \"position\": 1\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://{defaultHost}/v1/product_medias/{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 \"product_media\": {\n \"position\": 1\n }\n}"

response = http.request(request)
puts response.read_body
{
  "id": "0d740ba8-752b-4c23-9091-d0cddcbd0fe0",
  "object": "product_media",
  "alt": null,
  "position": 1,
  "title": null,
  "url": null,
  "media": "af4c345f-35c0-4d6e-bfda-55001e4a7224",
  "product": "bb8f2756-e87b-48e2-9b2b-08aa9c12e876",
  "created_at": 1782485867,
  "updated_at": 1782485867
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

id
string
required

Body

application/json
product_media
object

Response

200 - application/json

Success

id
string | null

The UUID of the specific object.

object
string

A string describing the object type returned.

alt
string | null

The HTML alt attribute for the product media.

position
integer | null

The ordering position of this product media when displayed to customers.

title
string | null

The HTML title attribute for the product media.

url
string | null

Instead of attaching a Media record, a public URL can be set. If set, this URL will be used to serve the product media asset.

media

Expandable – The associated media ID.

product

Expandable – The associated product ID.

created_at
integer | null

Time at which the object was created. Measured in seconds since the Unix epoch.

updated_at
integer | null

Time at which the object was last updated. Measured in seconds since the Unix epoch.