staged Uploads Createmutation
mutation
2024-10latest
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.
Arguments
The information required to generate staged upload targets.
Was this section helpful?
StagedUploadsCreatePayload returns
The staged upload targets that were generated.
The list of errors that occurred from executing the mutation.
Was this section helpful?
Code examples for MUTATION: stagedUploadsCreate
Query Reference for MUTATION: stagedUploadsCreate
"mutation stagedUploadsCreate($input: [StagedUploadInput!]!) {\n stagedUploadsCreate(input: $input) {\n stagedTargets {\n # StagedMediaUploadTarget fields\n }\n userErrors {\n field\n message\n }\n }\n}"
Input Reference for MUTATION: stagedUploadsCreate
"{\n \"input\": [\n {\n \"fileSize\": \"50\",\n \"filename\": \"<your-filename>\",\n \"httpMethod\": \"POST\",\n \"mimeType\": \"<your-mimeType>\",\n \"resource\": \"BULK_MUTATION_VARIABLES\"\n }\n ]\n}"
Schema Reference for MUTATION: stagedUploadsCreate
"input StagedUploadInput {\n fileSize: UnsignedInt64\n filename: String!\n httpMethod: StagedUploadHttpMethodType\n mimeType: String!\n resource: StagedUploadTargetGenerateUploadResource!\n}\n"
Display Examples for MUTATION: stagedUploadsCreate
[ { "example": { "type_name": "stageduploadscreate", "title": "Create staged upload targets", "description": "Create staged upload targets based on the given file metadata and return URL endpoints for uploading the files", "query_string": "mutation stagedUploadsCreate($input: [StagedUploadInput!]!) {\n stagedUploadsCreate(input: $input) {\n stagedTargets {\n url\n resourceUrl\n parameters {\n name\n value\n }\n }\n }\n}", "variables": { "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" } ] } ] } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/platform/admin/test/unit/graph_api/admin/mutations/staged_uploads_create_test.rb", "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", "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", "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", "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", "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" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "input", "description": "The information required to generate staged upload targets.", "type": { "kind": "INPUT_OBJECT", "name": "StagedUploadInput", "list": true, "non_null": true }, "defaultValue": null, "typeSignature": "[StagedUploadInput!]!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "input", "argValue": " [{\"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\"}]", "typeKind": "MUTATION" } ] } ]