Version: 2024-04
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation stagedUploadsCreate($input: [StagedUploadInput!]!) { stagedUploadsCreate(input: $input) { stagedTargets { url resourceUrl parameters { name value } } } }\",\n \"variables\": {\n \"input\": [\n {\n \"filename\": \"image1.png\",\n \"mimeType\": \"image/png\",\n \"httpMethod\": \"POST\",\n \"resource\": \"IMAGE\"\n },\n {\n \"filename\": \"video.mp4\",\n \"mimeType\": \"video/mp4\",\n \"fileSize\": \"1234\",\n \"resource\": \"VIDEO\"\n },\n {\n \"filename\": \"3d_model.glb\",\n \"mimeType\": \"model/gltf-binary\",\n \"resource\": \"MODEL_3D\",\n \"fileSize\": \"456\"\n }\n ]\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation stagedUploadsCreate($input: [StagedUploadInput!]!) {\n stagedUploadsCreate(input: $input) {\n stagedTargets {\n url\n resourceUrl\n parameters {\n name\n value\n }\n }\n }\n }`,\n \"variables\": {\n \"input\": [\n {\n \"filename\": \"image1.png\",\n \"mimeType\": \"image/png\",\n \"httpMethod\": \"POST\",\n \"resource\": \"IMAGE\"\n },\n {\n \"filename\": \"video.mp4\",\n \"mimeType\": \"video/mp4\",\n \"fileSize\": \"1234\",\n \"resource\": \"VIDEO\"\n },\n {\n \"filename\": \"3d_model.glb\",\n \"mimeType\": \"model/gltf-binary\",\n \"resource\": \"MODEL_3D\",\n \"fileSize\": \"456\"\n }\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 stagedUploadsCreate($input: [StagedUploadInput!]!) {\n stagedUploadsCreate(input: $input) {\n stagedTargets {\n url\n resourceUrl\n parameters {\n name\n value\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": [{\"filename\"=>\"image1.png\", \"mimeType\"=>\"image/png\", \"httpMethod\"=>\"POST\", \"resource\"=>\"IMAGE\"}, {\"filename\"=>\"video.mp4\", \"mimeType\"=>\"video/mp4\", \"fileSize\"=>\"1234\", \"resource\"=>\"VIDEO\"}, {\"filename\"=>\"3d_model.glb\", \"mimeType\"=>\"model/gltf-binary\", \"resource\"=>\"MODEL_3D\", \"fileSize\"=>\"456\"}]\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 stagedUploadsCreate($input: [StagedUploadInput!]!) {\n stagedUploadsCreate(input: $input) {\n stagedTargets {\n url\n resourceUrl\n parameters {\n name\n value\n }\n }\n }\n }\nQUERY;\n\n$variables = [\n \"input\" => [{\"filename\"=>\"image1.png\", \"mimeType\"=>\"image/png\", \"httpMethod\"=>\"POST\", \"resource\"=>\"IMAGE\"}, {\"filename\"=>\"video.mp4\", \"mimeType\"=>\"video/mp4\", \"fileSize\"=>\"1234\", \"resource\"=>\"VIDEO\"}, {\"filename\"=>\"3d_model.glb\", \"mimeType\"=>\"model/gltf-binary\", \"resource\"=>\"MODEL_3D\", \"fileSize\"=>\"456\"}],\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 stagedUploadsCreate($input: [StagedUploadInput!]!) {\n stagedUploadsCreate(input: $input) {\n stagedTargets {\n url\n resourceUrl\n parameters {\n name\n value\n }\n }\n }\n }`,\n {\n variables: {\n \"input\": [\n {\n \"filename\": \"image1.png\",\n \"mimeType\": \"image/png\",\n \"httpMethod\": \"POST\",\n \"resource\": \"IMAGE\"\n },\n {\n \"filename\": \"video.mp4\",\n \"mimeType\": \"video/mp4\",\n \"fileSize\": \"1234\",\n \"resource\": \"VIDEO\"\n },\n {\n \"filename\": \"3d_model.glb\",\n \"mimeType\": \"model/gltf-binary\",\n \"resource\": \"MODEL_3D\",\n \"fileSize\": \"456\"\n }\n ]\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation stagedUploadsCreate($input: [StagedUploadInput!]!) {\n stagedUploadsCreate(input: $input) {\n stagedTargets {\n url\n resourceUrl\n parameters {\n name\n value\n }\n }\n }\n}"
input: { "input": [ { "filename": "image1.png", "mimeType": "image/png", "httpMethod": "POST", "resource": "IMAGE" }, { "filename": "video.mp4", "mimeType": "video/mp4", "fileSize": "1234", "resource": "VIDEO" }, { "filename": "3d_model.glb", "mimeType": "model/gltf-binary", "resource": "MODEL_3D", "fileSize": "456" } ] }
response: { "data": { "stagedUploadsCreate": { "stagedTargets": [ { "url": "https://snowdevil.myshopify.com/admin/tmp/files", "resourceUrl": "https://snowdevil.myshopify.com/tmp/26371970/products/a743377e-dca3-4d44-94a0-45ab3b06d592/image1.png", "parameters": [ { "name": "filename", "value": "image1.png" }, { "name": "mime_type", "value": "image/png" }, { "name": "key", "value": "tmp/26371970/products/a743377e-dca3-4d44-94a0-45ab3b06d592/image1.png" } ] }, { "url": "http://upload.example.com/target", "resourceUrl": "http://upload.example.com/target?external_video_id=25", "parameters": [ { "name": "GoogleAccessId", "value": "video-development@video-production123.iam.gserviceaccount.com" }, { "name": "key", "value": "dev/o/v/video.mp4" }, { "name": "policy", "value": "abc123" }, { "name": "signature", "value": "abc123" } ] }, { "url": "http://upload.example.com/target/dev/o/v/3d_model.glb?external_model3d_id=25", "resourceUrl": "http://upload.example.com/target/dev/o/v/3d_model.glb?external_model3d_id=25", "parameters": [ { "name": "GoogleAccessId", "value": "video-development@video-production123.iam.gserviceaccount.com" }, { "name": "key", "value": "dev/o/v/3d_model.glb" }, { "name": "policy", "value": "abc123" }, { "name": "signature", "value": "abc123" } ] } ] } } }