Version: unstable
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/unstable/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation themeFilesUpsert($files: [OnlineStoreThemeFilesUpsertFileInput!]!, $themeId: ID!) { themeFilesUpsert(files: $files, themeId: $themeId) { upsertedThemeFiles { filename } userErrors { field message } } }\",\n \"variables\": {\n \"themeId\": \"gid://shopify/OnlineStoreTheme/529529152\",\n \"files\": [\n {\n \"filename\": \"templates/index.json\",\n \"body\": {\n \"type\": \"TEXT\",\n \"value\": \"{ \\\"sections\\\": {}, \\\"order\\\": [] }\"\n }\n }\n ]\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation themeFilesUpsert($files: [OnlineStoreThemeFilesUpsertFileInput!]!, $themeId: ID!) {\n themeFilesUpsert(files: $files, themeId: $themeId) {\n upsertedThemeFiles {\n filename\n }\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"themeId\": \"gid://shopify/OnlineStoreTheme/529529152\",\n \"files\": [\n {\n \"filename\": \"templates/index.json\",\n \"body\": {\n \"type\": \"TEXT\",\n \"value\": \"{ \\\"sections\\\": {}, \\\"order\\\": [] }\"\n }\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 themeFilesUpsert($files: [OnlineStoreThemeFilesUpsertFileInput!]!, $themeId: ID!) {\n themeFilesUpsert(files: $files, themeId: $themeId) {\n upsertedThemeFiles {\n filename\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"themeId\": \"gid://shopify/OnlineStoreTheme/529529152\",\n \"files\": [{\"filename\"=>\"templates/index.json\", \"body\"=>{\"type\"=>\"TEXT\", \"value\"=>\"{ \\\"sections\\\": {}, \\\"order\\\": [] }\"}}]\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 = <<\"gid://shopify/OnlineStoreTheme/529529152\",\n \"files\" => [{\"filename\"=>\"templates/index.json\", \"body\"=>{\"type\"=>\"TEXT\", \"value\"=>\"{ \\\"sections\\\": {}, \\\"order\\\": [] }\"}}],\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 themeFilesUpsert($files: [OnlineStoreThemeFilesUpsertFileInput!]!, $themeId: ID!) {\n themeFilesUpsert(files: $files, themeId: $themeId) {\n upsertedThemeFiles {\n filename\n }\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"themeId\": \"gid://shopify/OnlineStoreTheme/529529152\",\n \"files\": [\n {\n \"filename\": \"templates/index.json\",\n \"body\": {\n \"type\": \"TEXT\",\n \"value\": \"{ \\\"sections\\\": {}, \\\"order\\\": [] }\"\n }\n }\n ]\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation themeFilesUpsert($files: [OnlineStoreThemeFilesUpsertFileInput!]!, $themeId: ID!) {\n themeFilesUpsert(files: $files, themeId: $themeId) {\n upsertedThemeFiles {\n filename\n }\n userErrors {\n field\n message\n }\n }\n}"
input: { "themeId": "gid://shopify/OnlineStoreTheme/529529152", "files": [ { "filename": "templates/index.json", "body": { "type": "TEXT", "value": "{ \"sections\": {}, \"order\": [] }" } } ] }
response: { "data": { "themeFilesUpsert": { "upsertedThemeFiles": [ { "filename": "templates/index.json" } ], "userErrors": [] } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/unstable/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation themeFilesUpsert($files: [OnlineStoreThemeFilesUpsertFileInput!]!, $themeId: ID!) { themeFilesUpsert(files: $files, themeId: $themeId) { upsertedThemeFiles { filename } job { id } userErrors { field message } } }\",\n \"variables\": {\n \"themeId\": \"gid://shopify/OnlineStoreTheme/529529152\",\n \"files\": [\n {\n \"filename\": \"templates/index.json\",\n \"body\": {\n \"type\": \"TEXT\",\n \"value\": \"{ \\\"sections\\\": {}, \\\"order\\\": [] }\"\n }\n },\n {\n \"filename\": \"assets/custom-content.txt\",\n \"body\": {\n \"type\": \"BASE64\",\n \"value\": \"Y3VzdG9tIGNvbnRlbnQ=\"\n }\n },\n {\n \"filename\": \"assets/large-dog-image.jpg\",\n \"body\": {\n \"type\": \"URL\",\n \"value\": \"https://www.example.com/large-dog-image.jpg\"\n }\n }\n ]\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation themeFilesUpsert($files: [OnlineStoreThemeFilesUpsertFileInput!]!, $themeId: ID!) {\n themeFilesUpsert(files: $files, themeId: $themeId) {\n upsertedThemeFiles {\n filename\n }\n job {\n id\n }\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"themeId\": \"gid://shopify/OnlineStoreTheme/529529152\",\n \"files\": [\n {\n \"filename\": \"templates/index.json\",\n \"body\": {\n \"type\": \"TEXT\",\n \"value\": \"{ \\\"sections\\\": {}, \\\"order\\\": [] }\"\n }\n },\n {\n \"filename\": \"assets/custom-content.txt\",\n \"body\": {\n \"type\": \"BASE64\",\n \"value\": \"Y3VzdG9tIGNvbnRlbnQ=\"\n }\n },\n {\n \"filename\": \"assets/large-dog-image.jpg\",\n \"body\": {\n \"type\": \"URL\",\n \"value\": \"https://www.example.com/large-dog-image.jpg\"\n }\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 themeFilesUpsert($files: [OnlineStoreThemeFilesUpsertFileInput!]!, $themeId: ID!) {\n themeFilesUpsert(files: $files, themeId: $themeId) {\n upsertedThemeFiles {\n filename\n }\n job {\n id\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"themeId\": \"gid://shopify/OnlineStoreTheme/529529152\",\n \"files\": [{\"filename\"=>\"templates/index.json\", \"body\"=>{\"type\"=>\"TEXT\", \"value\"=>\"{ \\\"sections\\\": {}, \\\"order\\\": [] }\"}}, {\"filename\"=>\"assets/custom-content.txt\", \"body\"=>{\"type\"=>\"BASE64\", \"value\"=>\"Y3VzdG9tIGNvbnRlbnQ=\"}}, {\"filename\"=>\"assets/large-dog-image.jpg\", \"body\"=>{\"type\"=>\"URL\", \"value\"=>\"https://www.example.com/large-dog-image.jpg\"}}]\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 = <<\"gid://shopify/OnlineStoreTheme/529529152\",\n \"files\" => [{\"filename\"=>\"templates/index.json\", \"body\"=>{\"type\"=>\"TEXT\", \"value\"=>\"{ \\\"sections\\\": {}, \\\"order\\\": [] }\"}}, {\"filename\"=>\"assets/custom-content.txt\", \"body\"=>{\"type\"=>\"BASE64\", \"value\"=>\"Y3VzdG9tIGNvbnRlbnQ=\"}}, {\"filename\"=>\"assets/large-dog-image.jpg\", \"body\"=>{\"type\"=>\"URL\", \"value\"=>\"https://www.example.com/large-dog-image.jpg\"}}],\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 themeFilesUpsert($files: [OnlineStoreThemeFilesUpsertFileInput!]!, $themeId: ID!) {\n themeFilesUpsert(files: $files, themeId: $themeId) {\n upsertedThemeFiles {\n filename\n }\n job {\n id\n }\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"themeId\": \"gid://shopify/OnlineStoreTheme/529529152\",\n \"files\": [\n {\n \"filename\": \"templates/index.json\",\n \"body\": {\n \"type\": \"TEXT\",\n \"value\": \"{ \\\"sections\\\": {}, \\\"order\\\": [] }\"\n }\n },\n {\n \"filename\": \"assets/custom-content.txt\",\n \"body\": {\n \"type\": \"BASE64\",\n \"value\": \"Y3VzdG9tIGNvbnRlbnQ=\"\n }\n },\n {\n \"filename\": \"assets/large-dog-image.jpg\",\n \"body\": {\n \"type\": \"URL\",\n \"value\": \"https://www.example.com/large-dog-image.jpg\"\n }\n }\n ]\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation themeFilesUpsert($files: [OnlineStoreThemeFilesUpsertFileInput!]!, $themeId: ID!) {\n themeFilesUpsert(files: $files, themeId: $themeId) {\n upsertedThemeFiles {\n filename\n }\n job {\n id\n }\n userErrors {\n field\n message\n }\n }\n}"
input: { "themeId": "gid://shopify/OnlineStoreTheme/529529152", "files": [ { "filename": "templates/index.json", "body": { "type": "TEXT", "value": "{ \"sections\": {}, \"order\": [] }" } }, { "filename": "assets/custom-content.txt", "body": { "type": "BASE64", "value": "Y3VzdG9tIGNvbnRlbnQ=" } }, { "filename": "assets/large-dog-image.jpg", "body": { "type": "URL", "value": "https://www.example.com/large-dog-image.jpg" } } ] }
response: { "data": { "themeFilesUpsert": { "upsertedThemeFiles": [ { "filename": "templates/index.json" }, { "filename": "assets/custom-content.txt" } ], "job": { "id": "gid://shopify/Job/ae8d210d-90e0-4912-96d0-96d45c5e8fbb" }, "userErrors": [] } } }