サンプルでは、接続ガイドに記載されたサーバー側のヘルパーalterFetchとauthHeadersヘッダーを使用します。APIキーは必ずサーバー側だけで保管してください。
接続、認証、alterFetchヘルパー 商品エンドポイントは、Viewer、Configurator、Customizer として埋め込み可能なストアフロントのデザインを返します。
パラメータ 必須 詳細 nameいいえ商品/デザイン名を検索します。 customizerいいえtrue または false。 offsetいいえデフォルトは 0。>= 0 である必要があります。 limitいいえデフォルトは 9、最大は 50 です。 order_byいいえid、name、created_at のいずれか。 directionいいえASC または DESC。
リクエスト例(fetch)
const params = new URLSearchParams ( {
limit : '20' ,
offset : '0' ,
name : 't-shirt' ,
customizer : 'true' ,
order_by : 'created_at' ,
direction : 'DESC'
} ) ;
const products = await alterFetch ( ` /products? ${ params . toString ( ) } ` ) ;
const product = await alterFetch ( '/products/381' ) ; レスポンス例
{
"products" : {
"items" : [
{
"id" : 381 ,
"name" : "Men's T-Shirt" ,
"createdAt" : "2026-01-03T23:55:05.000Z" ,
"productId" : 4 ,
"media" : {
"img" : {
"big" : "https://alterproduct.com/public-api/v1/file/public/products/4/big.png" ,
"medium" : "https://alterproduct.com/public-api/v1/file/public/products/4/medium.png" ,
"small" : "https://alterproduct.com/public-api/v1/file/public/products/4/small.png"
} ,
"mockups" : [ ]
} ,
"storefrontProduct" : {
"id" : 89 ,
"idUserDesign" : 381 ,
"shareAccess" : "public" ,
"isCustomizer" : 1
} ,
"runtimeBindings" : [
{
"id" : 42 ,
"runtimeType" : "customizer" ,
"status" : "active" ,
"externalProductId" : "wc_123"
}
] ,
"embeddable" : {
"viewer" : true ,
"configurator" : true ,
"customizer" : true
}
}
] ,
"total" : 1
}
} ランタイムバインディングは、外部コマースの商品を Alter Product のデザインとランタイムの種類に関連付けます。主に WordPress/WooCommerce 連携や高度なストアフロントのバックエンドで使用します。
パラメータ 必須 詳細 designIdいいえストアフロントが所有する Alter Product のデザイン ID。 externalProductId同期時は必須外部の商品 ID。例:WooCommerce の商品 ID。 runtimeType同期時は必須viewer、configurator、customizer のいずれか。 statusいいえdraft、active、inactive、archived、legacy_active のいずれか。 legacyStorefrontProductIdいいえ旧形式のマッピング ID(任意)。 legacyBindingMetaいいえ任意の JSON メタデータ。例:manifestHash。
リクエスト例(fetch)
await alterFetch ( '/runtime-bindings/sync-from-wordpress' , {
method : 'POST' ,
body : JSON . stringify ( {
bindings : [
{
externalProductId : 'wc_123' ,
runtimeType : 'customizer' ,
status : 'active' ,
designId : 381 ,
legacyBindingMeta : {
manifestHash : 'a3b1...'
}
}
]
} )
} ) ;
await alterFetch ( '/runtime-bindings/42' , {
method : 'PATCH' ,
body : JSON . stringify ( {
status : 'inactive'
} )
} ) ;
await alterFetch ( '/runtime-bindings/42/activate' , { method : 'POST' } ) ;
await alterFetch ( '/runtime-bindings/42/deactivate' , { method : 'POST' } ) ; wordpress_local
await alterFetch ( '/runtime-bindings/sync-from-wordpress' , {
method : 'POST' ,
body : JSON . stringify ( {
bindings : [
{
externalProductId : 'wc_123' ,
runtimeType : 'viewer' ,
status : 'active' ,
externalDesign : {
externalDesignKey : 'wp-design-381' ,
productId : 4 ,
title : 'WooCommerce local design' ,
manifestUrl : 'https://yourstore.com/wp-content/uploads/alter/381/manifest.json' ,
assetBaseUrl : 'https://yourstore.com/wp-content/uploads/alter/381/' ,
manifestHash : 'a3b1...' ,
sourceMeta : {
pluginVersion : '1.2.0'
}
}
}
]
} )
} ) ; レスポンス例
{
"message" : "runtimeBinding.syncCompleted" ,
"runtimeBindings" : [
{
"id" : 42 ,
"designId" : 381 ,
"externalProductId" : "wc_123" ,
"runtimeType" : "customizer" ,
"status" : "active"
}
]
} サーバーで有効期間の短い埋め込みトークンを作成し、iframe/ランタイムに渡した後、ランタイムから Bearer トークンを使用して bootstrap を呼び出します。
パラメータ 必須 詳細 runtimeBindingId推奨有効なランタイムバインディングの優先識別子。 toolruntimeBindingId がない場合は必須designer | viewer | configurator | customizer | model-generator toolIdtool: model-generatorローカルのジェネレータープロジェクトの正の数値IDです。UUIDやWooCommerceの商品IDではありません。 originはい埋め込みが表示されるオリジン。例:https://yourstore.com. designId識別子をいずれか指定Alter Product のデザイン ID。orderId と同時に指定しないでください。 orderId識別子をいずれか指定Customizer の注文 ID。customizer のみで有効です。 cartKey + cartModeいいえCustomizer 専用のカートコンテキスト。cartMode は view または edit です。
リクエスト例(fetch)
const session = await alterFetch ( '/embed/session' , {
method : 'POST' ,
headers : {
'x-alter-client-fingerprint' : '9f1b7a5e4b3c2d1f9f1b7a5e4b3c2d1f'
} ,
body : JSON . stringify ( {
runtimeBindingId : 42 ,
origin : 'https://yourstore.com'
} )
} ) ;
const bootstrapResponse = await fetch ( 'https://alterproduct.com/public-api/v1/runtime/bootstrap' , {
method : 'GET' ,
headers : {
Authorization : ` Bearer ${ session . token } `
}
} ) ;
const bootstrap = await bootstrapResponse . json ( ) ;
console . log ( { session , bootstrap } ) ; 注意事項
await alterFetch ( '/embed/session' , {
method : 'POST' ,
body : JSON . stringify ( {
tool : 'customizer' ,
origin : 'https://yourstore.com' ,
orderId : 123
} )
} ) ;
await alterFetch ( '/embed/session' , {
method : 'POST' ,
body : JSON . stringify ( {
tool : 'viewer' ,
origin : 'https://yourstore.com' ,
designId : 381
} )
} ) ; レスポンス例
{
"token" : "eyJhbGciOiJIUzI1NiIsImtpZCI6IjEifQ..." ,
"expiresIn" : 900 ,
"kid" : "1" ,
"mode" : "design" ,
"runtimeBindingId" : 42 ,
"runtimeType" : "customizer"
} Runtime bootstrap
{
"runtimeBindingId" : 42 ,
"designId" : 381 ,
"productId" : "wc_123" ,
"runtimeType" : "customizer" ,
"storageMode" : "wordpress_local" ,
"manifestUrl" : "https://yourstore.com/wp-content/uploads/alter/381/manifest.json" ,
"assetBaseUrl" : "https://yourstore.com/wp-content/uploads/alter/381/" ,
"manifestHash" : "a3b1..." ,
"planCapabilities" : {
"viewer" : true ,
"configurator" : true ,
"customizer" : true
} ,
"cartKey" : null ,
"cartMode" : null ,
"orderId" : null
}