Rufe Produkte ab, verknüpfe sie mit Werkzeugen und erstelle sichere Einbettungssitzungen für Viewer, Configurator und Customizer.
Die Beispiele verwenden den serverseitigen Helper alterFetch und die authHeaders-Header aus der Verbindungsanleitung. Bewahre API-Schlüssel ausschließlich auf dem Server auf.
Verbindung, Autorisierung und der Helper alterFetch Produktendpunkte geben Shop-Designs zurück, die als Viewer, Configurator oder Customizer eingebettet werden können.
Parameter Erforderlich Details nameneinDurchsucht Produkt-/Designnamen. customizerneintrue oder false. offsetneinStandard 0. Muss >= 0 sein. limitneinStandard 9, maximal 50. order_byneinid, name oder created_at. directionneinASC oder DESC.
Beispielanfrage (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' ) ; Beispielantwort
{
"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
}
} Laufzeitzuordnungen verbinden externe Shop-Produkte mit Alter Product Designs und Laufzeittypen. Sie werden hauptsächlich von WordPress/WooCommerce-Integrationen und erweiterten Shop-Backends verwendet.
Parameter Erforderlich Details designIdneinID eines Alter Product Designs, das dem Shop gehört. externalProductIdja für die SynchronisierungExterne Produkt-ID, z. B. eine WooCommerce-Produkt-ID. runtimeTypeja für die Synchronisierungviewer, configurator oder customizer. statusneindraft, active, inactive, archived oder legacy_active. legacyStorefrontProductIdneinOptionale ID einer bisherigen Zuordnung. legacyBindingMetaneinOptionale JSON-Metadaten, z. B. manifestHash.
Beispielanfrage (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'
}
}
}
]
} )
} ) ; Beispielantwort
{
"message" : "runtimeBinding.syncCompleted" ,
"runtimeBindings" : [
{
"id" : 42 ,
"designId" : 381 ,
"externalProductId" : "wc_123" ,
"runtimeType" : "customizer" ,
"status" : "active"
}
]
} Erstelle auf deinem Server ein kurzlebiges Einbettungstoken und übergib es an das iframe bzw. die Laufzeit. Diese ruft anschließend die Initialisierung mit einem Bearer-Token auf.
Parameter Erforderlich Details runtimeBindingIdempfohlenBevorzugte Kennung für aktive Laufzeitzuordnungen. toolohne runtimeBindingId erforderlichdesigner | viewer | configurator | customizer | model-generator toolIdtool: model-generatorPositive numerische ID des lokalen Generatorprojekts, nicht dessen UUID oder die WooCommerce-Produkt-ID. originjaOrigin, auf dem die Einbettung dargestellt wird, z. B. https://yourstore.com. designIdeine KennungAlter Product Design-ID. Nicht mit orderId kombinieren. orderIdeine KennungCustomizer-Bestell-ID. Nur für customizer gültig. cartKey + cartModeneinWarenkorbkontext nur für Customizer. cartMode ist view oder edit.
Beispielanfrage (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 } ) ; Hinweise
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
} )
} ) ; Beispielantwort
{
"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
}