Version: 2024-10
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 CreateArticle($article: ArticleCreateInput!) { articleCreate(article: $article) { article { id title author { name } handle body summary tags image { altText originalSrc } } userErrors { code field message } } }\",\n \"variables\": {\n \"article\": {\n \"blogId\": \"gid://shopify/Blog/389767568\",\n \"title\": \"New Article Title\",\n \"author\": {\n \"name\": \"Test User\"\n },\n \"handle\": \"new-article-title\",\n \"body\": \"This is the content of the article.\",\n \"summary\": \"This is a summary of the article.\",\n \"isPublished\": true,\n \"publishDate\": \"2023-01-01T12:00:00Z\",\n \"tags\": [\n \"Tag1\",\n \"Tag2\"\n ],\n \"image\": {\n \"altText\": \"Alt text for the image\",\n \"url\": \"http://example.com/fake_image.jpg\"\n }\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation CreateArticle($article: ArticleCreateInput!) {\n articleCreate(article: $article) {\n article {\n id\n title\n author {\n name\n }\n handle\n body\n summary\n tags\n image {\n altText\n originalSrc\n }\n }\n userErrors {\n code\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"article\": {\n \"blogId\": \"gid://shopify/Blog/389767568\",\n \"title\": \"New Article Title\",\n \"author\": {\n \"name\": \"Test User\"\n },\n \"handle\": \"new-article-title\",\n \"body\": \"This is the content of the article.\",\n \"summary\": \"This is a summary of the article.\",\n \"isPublished\": true,\n \"publishDate\": \"2023-01-01T12:00:00Z\",\n \"tags\": [\n \"Tag1\",\n \"Tag2\"\n ],\n \"image\": {\n \"altText\": \"Alt text for the image\",\n \"url\": \"http://example.com/fake_image.jpg\"\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 CreateArticle($article: ArticleCreateInput!) {\n articleCreate(article: $article) {\n article {\n id\n title\n author {\n name\n }\n handle\n body\n summary\n tags\n image {\n altText\n originalSrc\n }\n }\n userErrors {\n code\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"article\": {\n \"blogId\": \"gid://shopify/Blog/389767568\",\n \"title\": \"New Article Title\",\n \"author\": {\n \"name\": \"Test User\"\n },\n \"handle\": \"new-article-title\",\n \"body\": \"This is the content of the article.\",\n \"summary\": \"This is a summary of the article.\",\n \"isPublished\": true,\n \"publishDate\": \"2023-01-01T12:00:00Z\",\n \"tags\": [\"Tag1\", \"Tag2\"],\n \"image\": {\n \"altText\": \"Alt text for the image\",\n \"url\": \"http://example.com/fake_image.jpg\"\n }\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 CreateArticle($article: ArticleCreateInput!) {\n articleCreate(article: $article) {\n article {\n id\n title\n author {\n name\n }\n handle\n body\n summary\n tags\n image {\n altText\n originalSrc\n }\n }\n userErrors {\n code\n field\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"article\" => [\n \"blogId\" => \"gid://shopify/Blog/389767568\",\n \"title\" => \"New Article Title\",\n \"author\" => [\n \"name\" => \"Test User\",\n ],\n \"handle\" => \"new-article-title\",\n \"body\" => \"This is the content of the article.\",\n \"summary\" => \"This is a summary of the article.\",\n \"isPublished\" => true,\n \"publishDate\" => \"2023-01-01T12:00:00Z\",\n \"tags\" => [\"Tag1\", \"Tag2\"],\n \"image\" => [\n \"altText\" => \"Alt text for the image\",\n \"url\" => \"http://example.com/fake_image.jpg\",\n ],\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 CreateArticle($article: ArticleCreateInput!) {\n articleCreate(article: $article) {\n article {\n id\n title\n author {\n name\n }\n handle\n body\n summary\n tags\n image {\n altText\n originalSrc\n }\n }\n userErrors {\n code\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"article\": {\n \"blogId\": \"gid://shopify/Blog/389767568\",\n \"title\": \"New Article Title\",\n \"author\": {\n \"name\": \"Test User\"\n },\n \"handle\": \"new-article-title\",\n \"body\": \"This is the content of the article.\",\n \"summary\": \"This is a summary of the article.\",\n \"isPublished\": true,\n \"publishDate\": \"2023-01-01T12:00:00Z\",\n \"tags\": [\n \"Tag1\",\n \"Tag2\"\n ],\n \"image\": {\n \"altText\": \"Alt text for the image\",\n \"url\": \"http://example.com/fake_image.jpg\"\n }\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation CreateArticle($article: ArticleCreateInput!) {\n articleCreate(article: $article) {\n article {\n id\n title\n author {\n name\n }\n handle\n body\n summary\n tags\n image {\n altText\n originalSrc\n }\n }\n userErrors {\n code\n field\n message\n }\n }\n}"
input: { "article": { "blogId": "gid://shopify/Blog/389767568", "title": "New Article Title", "author": { "name": "Test User" }, "handle": "new-article-title", "body": "This is the content of the article.", "summary": "This is a summary of the article.", "isPublished": true, "publishDate": "2023-01-01T12:00:00Z", "tags": [ "Tag1", "Tag2" ], "image": { "altText": "Alt text for the image", "url": "http://example.com/fake_image.jpg" } } }
response: { "data": { "articleCreate": { "article": { "id": "gid://shopify/Article/1051293784", "title": "New Article Title", "author": { "name": "Test User" }, "handle": "new-article-title", "body": "This is the content of the article.", "summary": "This is a summary of the article.", "tags": [ "Tag1", "Tag2" ], "image": { "altText": "Alt text for the image", "originalSrc": "https://cdn.shopify.com/s/files/1/2637/1970/articles/fake_image.jpg?v=1730243735" } }, "userErrors": [] } } }