//native
/**
* Delete Article
* Permanently delete a article. Accepts a numeric ID or a GID. Needs the write_content scope.
*/
export async function main(auth: RT.Shopify, article_id: string) {
const id = article_id.startsWith("gid://")
? article_id
: `gid://shopify/Article/${article_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!) { articleDelete(id: $id) { deletedArticleId 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.articleDelete.userErrors.length) {
throw new Error(JSON.stringify(data.articleDelete.userErrors))
}
return data.articleDelete
}
Submitted by hugo989 3 hours ago