重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
b2c-scapi-admin by salesforcecommercecloud/b2c-developer-tooling
npx skills add https://github.com/salesforcecommercecloud/b2c-developer-tooling --skill b2c-scapi-admin本技能指导您如何使用管理 API 进行后端集成、数据同步和管理操作。管理 API 专为服务器到服务器的集成而设计,不适用于店面。
注意: 关于面向购物者的 API(产品、购物篮、结账),请参阅 b2c-scapi-shopper。本技能侧重于管理/后端操作。
管理 API 专为后端系统和集成设计:
https://{shortCode}.api.commercecloud.salesforce.com/{apiFamily}/{apiName}/v1/organizations/{organizationId}/{resource}
示例:
https://kv7kzm78.api.commercecloud.salesforce.com/product/products/v1/organizations/f_ecom_zzte_053/products/25518823M
注意: 管理 API 通常不需要 siteId 参数(与购物者 API 不同)。
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
管理 API 使用 Account Manager OAuth 和客户端凭证流程。
# 获取管理令牌(使用 dw.json 中的 clientId/clientSecret)
b2c auth token
# 获取具有特定作用域的令牌
b2c auth token --auth-scope sfcc.orders --auth-scope sfcc.products
# 以 JSON 格式获取令牌(包含过期时间)
b2c auth token --json
配置详情请参阅 b2c-config 技能。
curl "https://account.demandware.com/dwsso/oauth2/access_token" \
--request 'POST' \
--user "${CLIENT_ID}:${CLIENT_SECRET}" \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data "grant_type=client_credentials" \
--data-urlencode "scope=SALESFORCE_COMMERCE_API:${TENANT_ID} ${SCOPES}"
示例:
CLIENT_ID="your-client-id"
CLIENT_SECRET="your-client-secret"
TENANT_ID="zzte_053"
SCOPES="sfcc.orders sfcc.products"
TOKEN=$(curl -s "https://account.demandware.com/dwsso/oauth2/access_token" \
-u "$CLIENT_ID:$CLIENT_SECRET" \
-d "grant_type=client_credentials" \
--data-urlencode "scope=SALESFORCE_COMMERCE_API:$TENANT_ID $SCOPES" \
| jq -r '.access_token')
管理 API 需要两种类型的作用域:
SALESFORCE_COMMERCE_API:{tenant_id} - 授予对租户的访问权限sfcc.catalogs、sfcc.orders.rw 等 - 授予 API 访问权限scope=SALESFORCE_COMMERCE_API:zzte_053 sfcc.catalogs sfcc.products.rw
完整的作用域列表请参阅 OAuth 作用域参考。
client_secret_postJWT管理产品目录数据。
// 获取产品
const product = await fetch(
`https://${shortCode}.api.commercecloud.salesforce.com/product/products/v1/organizations/${orgId}/products/${productId}`,
{
headers: { 'Authorization': `Bearer ${adminToken}` }
}
).then(r => r.json());
// 更新产品
await fetch(
`https://${shortCode}.api.commercecloud.salesforce.com/product/products/v1/organizations/${orgId}/products/${productId}`,
{
method: 'PATCH',
headers: {
'Authorization': `Bearer ${adminToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: { default: 'Updated Product Name' },
shortDescription: { default: 'New description' }
})
}
);
所需作用域:
sfcc.productssfcc.products.rw管理目录结构和分配。
// 列出目录
const catalogs = await fetch(
`https://${shortCode}.api.commercecloud.salesforce.com/product/catalogs/v1/organizations/${orgId}/catalogs`,
{
headers: { 'Authorization': `Bearer ${adminToken}` }
}
).then(r => r.json());
// 获取目录详情
const catalog = await fetch(
`https://${shortCode}.api.commercecloud.salesforce.com/product/catalogs/v1/organizations/${orgId}/catalogs/${catalogId}`,
{
headers: { 'Authorization': `Bearer ${adminToken}` }
}
).then(r => r.json());
所需作用域:
sfcc.catalogssfcc.catalogs.rw检索和管理订单。
// 按订单号获取订单
const order = await fetch(
`https://${shortCode}.api.commercecloud.salesforce.com/checkout/orders/v1/organizations/${orgId}/orders/${orderNo}?siteId=${siteId}`,
{
headers: { 'Authorization': `Bearer ${adminToken}` }
}
).then(r => r.json());
// 更新订单状态
await fetch(
`https://${shortCode}.api.commercecloud.salesforce.com/checkout/orders/v1/organizations/${orgId}/orders/${orderNo}?siteId=${siteId}`,
{
method: 'PATCH',
headers: {
'Authorization': `Bearer ${adminToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
status: 'completed',
shippingStatus: 'shipped'
})
}
);
所需作用域:
sfcc.orderssfcc.orders.rw管理产品库存。
// 获取产品的库存
const availability = await fetch(
`https://${shortCode}.api.commercecloud.salesforce.com/inventory/availability/v1/organizations/${orgId}/availability-records/search`,
{
method: 'POST',
headers: {
'Authorization': `Bearer ${adminToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
skus: ['SKU001', 'SKU002'],
locationIds: ['warehouse-1']
})
}
).then(r => r.json());
// 更新库存
await fetch(
`https://${shortCode}.api.commercecloud.salesforce.com/inventory/availability/v1/organizations/${orgId}/availability-records`,
{
method: 'PATCH',
headers: {
'Authorization': `Bearer ${adminToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
records: [{
sku: 'SKU001',
locationId: 'warehouse-1',
onHand: 100,
effectiveDate: new Date().toISOString()
}]
})
}
);
所需作用域:
sfcc.inventory.availabilitysfcc.inventory.availability.rw高性能批量库存导入。用于 1000 个以上 SKU 的更新。
关键要求:
文件 > 100MB 必须进行 gzip 压缩
使用换行符分隔的 JSON (NDJSON),而不是逗号分隔的数组
不要在位置图更改期间运行导入
为获得最佳性能,请使用增量导入(仅更改的数据)
未来的数量值必须 > 0
// 步骤 1:启动导入
const importJob = await fetch(
https://${shortCode}.api.commercecloud.salesforce.com/inventory/impex/v1/organizations/${orgId}/availability-records/imports,
{
method: 'POST',
headers: {
'Authorization': Bearer ${adminToken},
'Content-Type': 'application/json'
},
body: JSON.stringify({})
}
).then(r => r.json());
// 步骤 2:准备换行符分隔的 JSON const ndjsonData = inventoryRecords .map(r => JSON.stringify({ recordId: r.recordId || crypto.randomUUID(), sku: r.sku, locationId: r.locationId, onHand: r.quantity, effectiveDate: new Date().toISOString() })) .join('\n');
// 步骤 3:将数据上传到 uploadLink await fetch(importJob.uploadLink, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: ndjsonData });
// 步骤 4:监控状态
const status = await fetch(importJob.importStatusLink, {
headers: { 'Authorization': Bearer ${adminToken} }
}).then(r => r.json());
所需作用域: sfcc.inventory.impex-inventory
注意: 库存 IMPEX 日志不会出现在日志中心。请使用关联 ID 并直接监控导入状态。
批量导入最佳实践请参阅 集成模式参考。
管理客户数据。
// 搜索客户
const customers = await fetch(
`https://${shortCode}.api.commercecloud.salesforce.com/customer/customers/v1/organizations/${orgId}/customer-search?siteId=${siteId}`,
{
method: 'POST',
headers: {
'Authorization': `Bearer ${adminToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: {
textQuery: { fields: ['email'], searchPhrase: 'john@example.com' }
}
})
}
).then(r => r.json());
所需作用域:
sfcc.shopper-customerssfcc.shopper-customers.rw管理促销和营销活动。
// 获取促销
const promotion = await fetch(
`https://${shortCode}.api.commercecloud.salesforce.com/pricing/promotions/v1/organizations/${orgId}/promotions/${promotionId}?siteId=${siteId}`,
{
headers: { 'Authorization': `Bearer ${adminToken}` }
}
).then(r => r.json());
// 更新促销
await fetch(
`https://${shortCode}.api.commercecloud.salesforce.com/pricing/promotions/v1/organizations/${orgId}/promotions/${promotionId}?siteId=${siteId}`,
{
method: 'PATCH',
headers: {
'Authorization': `Bearer ${adminToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
enabled: true,
startDate: '2024-06-01T00:00:00Z',
endDate: '2024-06-30T23:59:59Z'
})
}
);
所需作用域:
sfcc.promotionssfcc.promotions.rw包含关联 ID 以追踪跨系统请求:
const correlationId = crypto.randomUUID();
const response = await fetch(url, {
headers: {
'Authorization': `Bearer ${adminToken}`,
'correlation-id': correlationId
}
});
console.log(`Request ${correlationId} completed`);
// 在日志中心搜索:externalID:({correlationId})
启用详细日志记录以进行调试:
const response = await fetch(url, {
headers: {
'Authorization': `Bearer ${adminToken}`,
'sfdc_verbose': 'true'
}
});
在 scapi.verbose 类别下检查日志中心。
注意: 某些管理 API(CDN Zones、Inventory、Shopper Context)不会记录到日志中心。
| 状态码 | 含义 | 操作 |
|---|---|---|
| 400 | 错误请求 | 检查请求体/参数 |
| 401 | 未授权 | 令牌过期 - 获取新令牌 |
| 403 | 禁止访问 | 缺少作用域或租户访问权限 |
| 404 | 未找到 | 资源不存在 |
| 429 | 速率限制 | 实施退避策略 |
| 500 | 服务器错误 | 使用退避策略重试 |
| 504 | 超时 | 请求耗时 > 60 秒 |
管理 API 的速率限制低于购物者 API。对于批量操作:
每周安装数
68
代码仓库
GitHub 星标数
34
首次出现
2026年2月11日
安全审计
安装于
github-copilot63
codex60
opencode59
cursor59
amp58
kimi-cli58
This skill guides you through consuming Admin APIs for backend integrations, data synchronization, and management operations. Admin APIs are designed for server-to-server integration, not storefront use.
Note: For shopper-facing APIs (products, baskets, checkout), see b2c-scapi-shopper. This skill focuses on admin/backend operations.
Admin APIs are designed for backend systems and integrations:
https://{shortCode}.api.commercecloud.salesforce.com/{apiFamily}/{apiName}/v1/organizations/{organizationId}/{resource}
Example:
https://kv7kzm78.api.commercecloud.salesforce.com/product/products/v1/organizations/f_ecom_zzte_053/products/25518823M
Note: Admin APIs typically don't require siteId parameter (unlike Shopper APIs).
Admin APIs use Account Manager OAuth with client credentials flow.
# Get admin token (uses clientId/clientSecret from dw.json)
b2c auth token
# Get token with specific scopes
b2c auth token --auth-scope sfcc.orders --auth-scope sfcc.products
# Get token as JSON (includes expiration)
b2c auth token --json
See b2c-config skill for configuration details.
curl "https://account.demandware.com/dwsso/oauth2/access_token" \
--request 'POST' \
--user "${CLIENT_ID}:${CLIENT_SECRET}" \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data "grant_type=client_credentials" \
--data-urlencode "scope=SALESFORCE_COMMERCE_API:${TENANT_ID} ${SCOPES}"
Example:
CLIENT_ID="your-client-id"
CLIENT_SECRET="your-client-secret"
TENANT_ID="zzte_053"
SCOPES="sfcc.orders sfcc.products"
TOKEN=$(curl -s "https://account.demandware.com/dwsso/oauth2/access_token" \
-u "$CLIENT_ID:$CLIENT_SECRET" \
-d "grant_type=client_credentials" \
--data-urlencode "scope=SALESFORCE_COMMERCE_API:$TENANT_ID $SCOPES" \
| jq -r '.access_token')
Admin APIs require two types of scopes :
SALESFORCE_COMMERCE_API:{tenant_id} - grants access to the tenantsfcc.catalogs, sfcc.orders.rw, etc. - grants API accessscope=SALESFORCE_COMMERCE_API:zzte_053 sfcc.catalogs sfcc.products.rw
See OAuth Scopes Reference for the complete scope list.
client_secret_postJWTManage product catalog data.
// Get product
const product = await fetch(
`https://${shortCode}.api.commercecloud.salesforce.com/product/products/v1/organizations/${orgId}/products/${productId}`,
{
headers: { 'Authorization': `Bearer ${adminToken}` }
}
).then(r => r.json());
// Update product
await fetch(
`https://${shortCode}.api.commercecloud.salesforce.com/product/products/v1/organizations/${orgId}/products/${productId}`,
{
method: 'PATCH',
headers: {
'Authorization': `Bearer ${adminToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: { default: 'Updated Product Name' },
shortDescription: { default: 'New description' }
})
}
);
Required Scopes:
sfcc.productssfcc.products.rwManage catalog structure and assignments.
// List catalogs
const catalogs = await fetch(
`https://${shortCode}.api.commercecloud.salesforce.com/product/catalogs/v1/organizations/${orgId}/catalogs`,
{
headers: { 'Authorization': `Bearer ${adminToken}` }
}
).then(r => r.json());
// Get catalog details
const catalog = await fetch(
`https://${shortCode}.api.commercecloud.salesforce.com/product/catalogs/v1/organizations/${orgId}/catalogs/${catalogId}`,
{
headers: { 'Authorization': `Bearer ${adminToken}` }
}
).then(r => r.json());
Required Scopes:
sfcc.catalogssfcc.catalogs.rwRetrieve and manage orders.
// Get order by number
const order = await fetch(
`https://${shortCode}.api.commercecloud.salesforce.com/checkout/orders/v1/organizations/${orgId}/orders/${orderNo}?siteId=${siteId}`,
{
headers: { 'Authorization': `Bearer ${adminToken}` }
}
).then(r => r.json());
// Update order status
await fetch(
`https://${shortCode}.api.commercecloud.salesforce.com/checkout/orders/v1/organizations/${orgId}/orders/${orderNo}?siteId=${siteId}`,
{
method: 'PATCH',
headers: {
'Authorization': `Bearer ${adminToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
status: 'completed',
shippingStatus: 'shipped'
})
}
);
Required Scopes:
sfcc.orderssfcc.orders.rwManage product inventory.
// Get inventory for a product
const availability = await fetch(
`https://${shortCode}.api.commercecloud.salesforce.com/inventory/availability/v1/organizations/${orgId}/availability-records/search`,
{
method: 'POST',
headers: {
'Authorization': `Bearer ${adminToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
skus: ['SKU001', 'SKU002'],
locationIds: ['warehouse-1']
})
}
).then(r => r.json());
// Update inventory
await fetch(
`https://${shortCode}.api.commercecloud.salesforce.com/inventory/availability/v1/organizations/${orgId}/availability-records`,
{
method: 'PATCH',
headers: {
'Authorization': `Bearer ${adminToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
records: [{
sku: 'SKU001',
locationId: 'warehouse-1',
onHand: 100,
effectiveDate: new Date().toISOString()
}]
})
}
);
Required Scopes:
sfcc.inventory.availabilitysfcc.inventory.availability.rwHigh-performance bulk inventory import. Use for 1000+ SKU updates.
Critical Requirements:
Files > 100MB MUST be gzip compressed
Use newline-delimited JSON (NDJSON), not comma-separated arrays
Don't run imports during location graph changes
Use delta imports (changed data only) for best performance
Future quantity values must be > 0
// Step 1: Initiate import
const importJob = await fetch(
https://${shortCode}.api.commercecloud.salesforce.com/inventory/impex/v1/organizations/${orgId}/availability-records/imports,
{
method: 'POST',
headers: {
'Authorization': Bearer ${adminToken},
'Content-Type': 'application/json'
},
body: JSON.stringify({})
}
).then(r => r.json());
// Step 2: Prepare newline-delimited JSON const ndjsonData = inventoryRecords .map(r => JSON.stringify({ recordId: r.recordId || crypto.randomUUID(), sku: r.sku, locationId: r.locationId, onHand: r.quantity, effectiveDate: new Date().toISOString() })) .join('\n');
// Step 3: Upload data to the uploadLink await fetch(importJob.uploadLink, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: ndjsonData });
// Step 4: Monitor status
const status = await fetch(importJob.importStatusLink, {
headers: { 'Authorization': Bearer ${adminToken} }
}).then(r => r.json());
Required Scope: sfcc.inventory.impex-inventory
Note: Inventory IMPEX logs don't appear in Log Center. Use correlation IDs and monitor import status directly.
See Integration Patterns Reference for bulk import best practices.
Manage customer data.
// Search customers
const customers = await fetch(
`https://${shortCode}.api.commercecloud.salesforce.com/customer/customers/v1/organizations/${orgId}/customer-search?siteId=${siteId}`,
{
method: 'POST',
headers: {
'Authorization': `Bearer ${adminToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: {
textQuery: { fields: ['email'], searchPhrase: 'john@example.com' }
}
})
}
).then(r => r.json());
Required Scopes:
sfcc.shopper-customerssfcc.shopper-customers.rwManage promotions and campaigns.
// Get promotion
const promotion = await fetch(
`https://${shortCode}.api.commercecloud.salesforce.com/pricing/promotions/v1/organizations/${orgId}/promotions/${promotionId}?siteId=${siteId}`,
{
headers: { 'Authorization': `Bearer ${adminToken}` }
}
).then(r => r.json());
// Update promotion
await fetch(
`https://${shortCode}.api.commercecloud.salesforce.com/pricing/promotions/v1/organizations/${orgId}/promotions/${promotionId}?siteId=${siteId}`,
{
method: 'PATCH',
headers: {
'Authorization': `Bearer ${adminToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
enabled: true,
startDate: '2024-06-01T00:00:00Z',
endDate: '2024-06-30T23:59:59Z'
})
}
);
Required Scopes:
sfcc.promotionssfcc.promotions.rwInclude correlation IDs for tracking requests across systems:
const correlationId = crypto.randomUUID();
const response = await fetch(url, {
headers: {
'Authorization': `Bearer ${adminToken}`,
'correlation-id': correlationId
}
});
console.log(`Request ${correlationId} completed`);
// Search Log Center: externalID:({correlationId})
Enable verbose logging for debugging:
const response = await fetch(url, {
headers: {
'Authorization': `Bearer ${adminToken}`,
'sfdc_verbose': 'true'
}
});
Check Log Center under scapi.verbose category.
Note: Some Admin APIs (CDN Zones, Inventory, Shopper Context) don't log to Log Center.
| Status | Meaning | Action |
|---|---|---|
| 400 | Bad Request | Check request body/parameters |
| 401 | Unauthorized | Token expired - get new token |
| 403 | Forbidden | Missing scope or tenant access |
| 404 | Not Found | Resource doesn't exist |
| 429 | Rate Limited | Implement backoff |
| 500 | Server Error | Retry with backoff |
| 504 | Timeout | Request took > 60 seconds |
Admin APIs have lower rate limits than Shopper APIs. For bulk operations:
Weekly Installs
68
Repository
GitHub Stars
34
First Seen
Feb 11, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
github-copilot63
codex60
opencode59
cursor59
amp58
kimi-cli58
飞书视频会议CLI工具:lark-vc技能详解,高效搜索与管理会议记录与纪要
47,500 周安装
市场推广计划制定工具:3步生成可执行GTM策略,助力产品上市与客户获取
212 周安装
Excalidraw图表生成器 - AI驱动,自然语言描述一键生成流程图、架构图、思维导图
220 周安装
Terraform/OpenTofu专家:高级IaC自动化、状态管理与多云部署实践指南
214 周安装
docs-seeker:AI驱动的技术文档智能发现与分析工具,支持llms.txt优先搜索与仓库分析
213 周安装
Symfony API Platform状态提供器:设计API合约、序列化与安全的最佳实践
214 周安装
数据库管理员技能指南:云原生数据库管理、自动化运维与高可用性最佳实践
215 周安装