Shopify Admin API SOP — 通过 GraphQL/REST 实现产品标签、库存及其他写入操作。适用于任何使用自定义 App 访问令牌的 Shopify 商店。
Shopify has two distinct APIs — know which one to use:
APIPurposeAuthStorefront API / MCP ( /api/mcp)Read product catalog, cart (read-only)None requiredAdmin API (GraphQL/REST)Write products, tags, inventory, etc.X-Shopify-Access-Token
The Storefront MCP is read-only. For any write operation, use the Admin API directly via the
httptool.
Stored as skill secrets (injected at runtime):
SHOPIFY_STORE_DOMAIN — e.g. your-store.myshopify.comSHOPIFY_ACCESS_TOKEN — shpat_xxx token from a Custom App with required scopesUse the http tool with X-Shopify-Access-Token header.
text
POST https://{SHOPIFY_STORE_DOMAIN}/admin/api/2024-01/graphql.json
Headers:
Content-Type: application/json
X-Shopify-Access-Token: {SHOPIFY_ACCESS_TOKEN}
text
GET/PUT https://{SHOPIFY_STORE_DOMAIN}/admin/api/2024-01/products/{id}.json
Headers:
X-Shopify-Access-Token: {SHOPIFY_ACCESS_TOKEN}
graphql
mutation {
productUpdate(input: {
id: "gid://shopify/Product/{PRODUCT_ID}",
tags: ["existing-tag1", "existing-tag2", "new-tag"]
}) {
product { id title tags }
userErrors { field message }
}
}
⚠️ tags is a full replacement. Always fetch current tags first, then merge.
graphql
{ product(id: "gid://shopify/Product/{PRODUCT_ID}") { id title tags } }
15501243941233gid://shopify/Product/15501243941233For full product management, the token needs:
read_products, write_products
For broader operations add:
read_orders, read_inventory, write_inventory, read_themes, write_themes
shpat_xxx token (shown once)PUT /skills/shopify-admin/secrets {"SHOPIFY_ACCESS_TOKEN": "shpat_xxx", "SHOPIFY_STORE_DOMAIN": "your-store.myshopify.com"}If you use a Dev Dashboard app (Partner App), the token is obtained via OAuth. See the OAuth Refresh SOP below.
When a token expires (401) or needs new scopes:
In shopify.app.toml:
toml
[auth]
redirect_urls = [ "https://example.com" ]
If empty, add it and run: shopify app deploy --force
text
https://{SHOPIFY_STORE_DOMAIN}/admin/oauth/authorize?client_id={CLIENT_ID}&scope={SCOPES}&redirect_uri=https://example.com&state=refresh
Browser redirects to https://example.com/?code=XXXXXX&...
Extract the code value (valid for ~60 seconds).
text
POST https://{SHOPIFY_STORE_DOMAIN}/admin/oauth/access_token
Body: {"client_id": "{CLIENT_ID}", "client_secret": "{CLIENT_SECRET}", "code": "{code}"}
Response contains the new access_token.
shopify app dev triggers APP_UNINSTALLED webhook — avoid for production stores. Use shopify app deploy to update config only./api/mcp) is already configured in Kocoro for product search. Admin write ops bypass MCP entirely.