Anchor to blogCreateblog
blogCreate
mutation
Requires Any of ,
access scopes.
Creates a blog.
Anchor to Arguments
Arguments
- Anchor to blogblog•Blog
Create requiredInput! The properties of the new blog.
Was this section helpful?
Anchor to BlogCreatePayload returnsBlogCreatePayload returns
- Anchor to blogblog•
The blog that was created.
- Anchor to userErrorsuser•
Errors [BlogCreate non-nullUser Error!]! The list of errors that occurred from executing the mutation.
Was this section helpful?
- Create a new Blog
- blogCreate reference
Examples
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation CreateBlog($blog: BlogCreateInput!) {
blogCreate(blog: $blog) {
blog {
id
title
handle
templateSuffix
commentPolicy
}
userErrors {
code
field
message
}
}
}`,
{
variables: {
"blog": {
"title": "New Blog Title",
"handle": "new-blog-title",
"templateSuffix": "standard",
"commentPolicy": "MODERATED"
}
},
},
);
mutation CreateBlog($blog: BlogCreateInput!) {
blogCreate(blog: $blog) {
blog {
id
title
handle
templateSuffix
commentPolicy
}
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 CreateBlog($blog: BlogCreateInput!) { blogCreate(blog: $blog) { blog { id title handle templateSuffix commentPolicy } userErrors { code field message } } }",
"variables": {
"blog": {
"title": "New Blog Title",
"handle": "new-blog-title",
"templateSuffix": "standard",
"commentPolicy": "MODERATED"
}
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation CreateBlog($blog: BlogCreateInput!) {
blogCreate(blog: $blog) {
blog {
id
title
handle
templateSuffix
commentPolicy
}
userErrors {
code
field
message
}
}
}`,
{
variables: {
"blog": {
"title": "New Blog Title",
"handle": "new-blog-title",
"templateSuffix": "standard",
"commentPolicy": "MODERATED"
}
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation CreateBlog($blog: BlogCreateInput!) {
blogCreate(blog: $blog) {
blog {
id
title
handle
templateSuffix
commentPolicy
}
userErrors {
code
field
message
}
}
}`,
"variables": {
"blog": {
"title": "New Blog Title",
"handle": "new-blog-title",
"templateSuffix": "standard",
"commentPolicy": "MODERATED"
}
},
},
});
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 CreateBlog($blog: BlogCreateInput!) {
blogCreate(blog: $blog) {
blog {
id
title
handle
templateSuffix
commentPolicy
}
userErrors {
code
field
message
}
}
}
QUERY
variables = {
"blog": {
"title": "New Blog Title",
"handle": "new-blog-title",
"templateSuffix": "standard",
"commentPolicy": "MODERATED"
}
}
response = client.query(query: query, variables: variables)
Input variables
JSON{
"blog": {
"title": "New Blog Title",
"handle": "new-blog-title",
"templateSuffix": "standard",
"commentPolicy": "MODERATED"
}
}
Response
JSON{
"blogCreate": {
"blog": {
"id": "gid://shopify/Blog/1008414248",
"title": "New Blog Title",
"handle": "new-blog-title",
"templateSuffix": "standard",
"commentPolicy": "MODERATED"
},
"userErrors": []
}
}