Anchor to articleCreatearticle
articleCreate
mutation
Requires Any of ,
access scopes.
Creates an article.
Anchor to Arguments
Arguments
- Anchor to articlearticle•Article
Create requiredInput! The properties of the new article.
- Anchor to blogblog•
The properties of the new blog.
Was this section helpful?
Anchor to ArticleCreatePayload returnsArticleCreatePayload returns
- Anchor to articlearticle•
The article that was created.
- Anchor to userErrorsuser•
Errors [ArticleCreate non-nullUser Error!]! The list of errors that occurred from executing the mutation.
Was this section helpful?
- Creates an article for a blog
- articleCreate reference
Examples
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation CreateArticle($article: ArticleCreateInput!) {
articleCreate(article: $article) {
article {
id
title
author {
name
}
handle
body
summary
tags
image {
altText
originalSrc
}
}
userErrors {
code
field
message
}
}
}`,
{
variables: {
"article": {
"blogId": "gid://shopify/Blog/389767568",
"title": "New Article Title",
mutation CreateArticle($article: ArticleCreateInput!) {
articleCreate(article: $article) {
article {
id
title
author {
name
}
handle
body
summary
tags
image {
altText
originalSrc
}
}
userErrors {
code
field
message
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation CreateArticle($article: ArticleCreateInput!) { articleCreate(article: $article) { article { id title author { name } handle body summary tags image { altText originalSrc } } userErrors { code field message } } }",
"variables": {
"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"
}
}
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation CreateArticle($article: ArticleCreateInput!) {
articleCreate(article: $article) {
article {
id
title
author {
name
}
handle
body
summary
tags
image {
altText
originalSrc
}
}
userErrors {
code
field
message
}
}
}`,
{
variables: {
"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"
}
}
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation CreateArticle($article: ArticleCreateInput!) {
articleCreate(article: $article) {
article {
id
title
author {
name
}
handle
body
summary
tags
image {
altText
originalSrc
}
}
userErrors {
code
field
message
}
}
}`,
"variables": {
"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"
}
}
},
},
});
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
mutation CreateArticle($article: ArticleCreateInput!) {
articleCreate(article: $article) {
article {
id
title
author {
name
}
handle
body
summary
tags
image {
altText
originalSrc
}
}
userErrors {
code
field
message
}
}
}
QUERY
variables = {
"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 = client.query(query: query, variables: variables)
Input variables
JSON{
"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
JSON{
"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": []
}
}