Version: 2025-01
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation FileUpdate($input: [FileUpdateInput!]!) { fileUpdate(files: $input) { userErrors { code field message } files { alt } } }\",\n \"variables\": {\n \"input\": {\n \"id\": \"gid://shopify/GenericFile/1072273203\",\n \"alt\": \"new alt text\"\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation FileUpdate($input: [FileUpdateInput!]!) {\n fileUpdate(files: $input) {\n userErrors {\n code\n field\n message\n }\n files {\n alt\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"id\": \"gid://shopify/GenericFile/1072273203\",\n \"alt\": \"new alt text\"\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation FileUpdate($input: [FileUpdateInput!]!) {\n fileUpdate(files: $input) {\n userErrors {\n code\n field\n message\n }\n files {\n alt\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"id\": \"gid://shopify/GenericFile/1072273203\",\n \"alt\": \"new alt text\"\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation FileUpdate($input: [FileUpdateInput!]!) {\n fileUpdate(files: $input) {\n userErrors {\n code\n field\n message\n }\n files {\n alt\n }\n }\n }\nQUERY;\n\n$variables = [\n \"input\" => [\n \"id\" => \"gid://shopify/GenericFile/1072273203\",\n \"alt\" => \"new alt text\",\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation FileUpdate($input: [FileUpdateInput!]!) {\n fileUpdate(files: $input) {\n userErrors {\n code\n field\n message\n }\n files {\n alt\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"id\": \"gid://shopify/GenericFile/1072273203\",\n \"alt\": \"new alt text\"\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation FileUpdate($input: [FileUpdateInput!]!) {\n fileUpdate(files: $input) {\n userErrors {\n code\n field\n message\n }\n files {\n alt\n }\n }\n}"
input: { "input": { "id": "gid://shopify/GenericFile/1072273203", "alt": "new alt text" } }
response: { "data": { "fileUpdate": { "userErrors": [], "files": [ { "alt": "new alt text" } ] } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation fileUpdate($input: [FileUpdateInput!]!) { fileUpdate(files: $input) { files { ... on GenericFile { id url } } userErrors { message } } }\",\n \"variables\": {\n \"input\": {\n \"id\": \"gid://shopify/GenericFile/1072273204\",\n \"originalSource\": \"https://example.com/manual.pdf\"\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation fileUpdate($input: [FileUpdateInput!]!) {\n fileUpdate(files: $input) {\n files {\n ... on GenericFile {\n id\n url\n }\n }\n userErrors {\n message\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"id\": \"gid://shopify/GenericFile/1072273204\",\n \"originalSource\": \"https://example.com/manual.pdf\"\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation fileUpdate($input: [FileUpdateInput!]!) {\n fileUpdate(files: $input) {\n files {\n ... on GenericFile {\n id\n url\n }\n }\n userErrors {\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"id\": \"gid://shopify/GenericFile/1072273204\",\n \"originalSource\": \"https://example.com/manual.pdf\"\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation fileUpdate($input: [FileUpdateInput!]!) {\n fileUpdate(files: $input) {\n files {\n ... on GenericFile {\n id\n url\n }\n }\n userErrors {\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"input\" => [\n \"id\" => \"gid://shopify/GenericFile/1072273204\",\n \"originalSource\" => \"https://example.com/manual.pdf\",\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation fileUpdate($input: [FileUpdateInput!]!) {\n fileUpdate(files: $input) {\n files {\n ... on GenericFile {\n id\n url\n }\n }\n userErrors {\n message\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"id\": \"gid://shopify/GenericFile/1072273204\",\n \"originalSource\": \"https://example.com/manual.pdf\"\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation fileUpdate($input: [FileUpdateInput!]!) {\n fileUpdate(files: $input) {\n files {\n ... on GenericFile {\n id\n url\n }\n }\n userErrors {\n message\n }\n }\n}"
input: { "input": { "id": "gid://shopify/GenericFile/1072273204", "originalSource": "https://example.com/manual.pdf" } }
response: { "data": { "fileUpdate": { "files": [ { "id": "gid://shopify/GenericFile/1072273204", "url": "https://cdn.shopify.com/s/files/1/2637/1970/files/original_name.pdf?v=1726103340" } ], "userErrors": [] } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation fileUpdate($input: [FileUpdateInput!]!) { fileUpdate(files: $input) { files { ... on MediaImage { id image { url } } } userErrors { message } } }\",\n \"variables\": {\n \"input\": {\n \"id\": \"gid://shopify/MediaImage/1072273202\",\n \"originalSource\": \"https://example.com/image.jpg\"\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation fileUpdate($input: [FileUpdateInput!]!) {\n fileUpdate(files: $input) {\n files {\n ... on MediaImage {\n id\n image {\n url\n }\n }\n }\n userErrors {\n message\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"id\": \"gid://shopify/MediaImage/1072273202\",\n \"originalSource\": \"https://example.com/image.jpg\"\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation fileUpdate($input: [FileUpdateInput!]!) {\n fileUpdate(files: $input) {\n files {\n ... on MediaImage {\n id\n image {\n url\n }\n }\n }\n userErrors {\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"id\": \"gid://shopify/MediaImage/1072273202\",\n \"originalSource\": \"https://example.com/image.jpg\"\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation fileUpdate($input: [FileUpdateInput!]!) {\n fileUpdate(files: $input) {\n files {\n ... on MediaImage {\n id\n image {\n url\n }\n }\n }\n userErrors {\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"input\" => [\n \"id\" => \"gid://shopify/MediaImage/1072273202\",\n \"originalSource\" => \"https://example.com/image.jpg\",\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation fileUpdate($input: [FileUpdateInput!]!) {\n fileUpdate(files: $input) {\n files {\n ... on MediaImage {\n id\n image {\n url\n }\n }\n }\n userErrors {\n message\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"id\": \"gid://shopify/MediaImage/1072273202\",\n \"originalSource\": \"https://example.com/image.jpg\"\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation fileUpdate($input: [FileUpdateInput!]!) {\n fileUpdate(files: $input) {\n files {\n ... on MediaImage {\n id\n image {\n url\n }\n }\n }\n userErrors {\n message\n }\n }\n}"
input: { "input": { "id": "gid://shopify/MediaImage/1072273202", "originalSource": "https://example.com/image.jpg" } }
response: { "data": { "fileUpdate": { "files": [ { "id": "gid://shopify/MediaImage/1072273202", "image": null } ], "userErrors": [] } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation fileUpdate($input: [FileUpdateInput!]!) { fileUpdate(files: $input) { files { alt ... on GenericFile { id } } userErrors { message } } }\",\n \"variables\": {\n \"input\": {\n \"id\": \"gid://shopify/GenericFile/1\",\n \"alt\": \"new alt text\"\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation fileUpdate($input: [FileUpdateInput!]!) {\n fileUpdate(files: $input) {\n files {\n alt\n ... on GenericFile {\n id\n }\n }\n userErrors {\n message\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"id\": \"gid://shopify/GenericFile/1\",\n \"alt\": \"new alt text\"\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation fileUpdate($input: [FileUpdateInput!]!) {\n fileUpdate(files: $input) {\n files {\n alt\n ... on GenericFile {\n id\n }\n }\n userErrors {\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"id\": \"gid://shopify/GenericFile/1\",\n \"alt\": \"new alt text\"\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation fileUpdate($input: [FileUpdateInput!]!) {\n fileUpdate(files: $input) {\n files {\n alt\n ... on GenericFile {\n id\n }\n }\n userErrors {\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"input\" => [\n \"id\" => \"gid://shopify/GenericFile/1\",\n \"alt\" => \"new alt text\",\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation fileUpdate($input: [FileUpdateInput!]!) {\n fileUpdate(files: $input) {\n files {\n alt\n ... on GenericFile {\n id\n }\n }\n userErrors {\n message\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"id\": \"gid://shopify/GenericFile/1\",\n \"alt\": \"new alt text\"\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation fileUpdate($input: [FileUpdateInput!]!) {\n fileUpdate(files: $input) {\n files {\n alt\n ... on GenericFile {\n id\n }\n }\n userErrors {\n message\n }\n }\n}"
input: { "input": { "id": "gid://shopify/GenericFile/1", "alt": "new alt text" } }
response: { "data": { "fileUpdate": { "files": [], "userErrors": [ { "message": "File id [\"gid://shopify/GenericFile/1\"] does not exist." } ] } } }