//native
/**
* Delete Blog
* Permanently delete a blog. Accepts a numeric ID or a GID. Needs the write_content scope.
*/
export async function main(auth: RT.Shopify, blog_id: string) {
const id = blog_id.startsWith("gid://")
? blog_id
: `gid://shopify/Blog/${blog_id}`
const response = await fetch(
`https://${auth.store_name}.myshopify.com/admin/api/2026-10/graphql.json`,
{
method: "POST",
headers: {
"X-Shopify-Access-Token": auth.token,
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify({
query: `mutation ($id: ID!) { blogDelete(id: $id) { deletedBlogId userErrors { field message } } }`,
variables: { id },
}),
}
)
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
const { data, errors } = await response.json()
if (errors) {
throw new Error(JSON.stringify(errors))
}
if (data.blogDelete.userErrors.length) {
throw new Error(JSON.stringify(data.blogDelete.userErrors))
}
return data.blogDelete
}
Submitted by hugo989 3 hours ago