# stagedUploadsCreate - admin-graphql - MUTATION Version: 2024-10 ## Description Creates staged upload targets for each input. This is the first step in the upload process. The returned staged upload targets' URL and parameter fields can be used to send a request to upload the file described in the corresponding input. For more information on the upload process, refer to [Upload media to Shopify](https://shopify.dev/apps/online-store/media/products#step-1-upload-media-to-shopify). ### Access Scopes ## Arguments * [input](/docs/api/admin-graphql/2024-10/input-objects/StagedUploadInput): StagedUploadInput! - The information required to generate staged upload targets. ## Returns * [stagedTargets](/docs/api/admin-graphql/2024-10/objects/StagedMediaUploadTarget): StagedMediaUploadTarget The staged upload targets that were generated. * [userErrors](/docs/api/admin-graphql/2024-10/objects/UserError): UserError! The list of errors that occurred from executing the mutation. ## Examples ### Create staged upload targets Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/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" 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}" #### Graphql 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" } ] } #### Graphql 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" } ] } ] } } }