Alter Product Public API एकीकरण

Public API को स्टोरफ़्रंट, कॉमर्स बैकएंड, WordPress/WooCommerce प्लगइन और बाहरी उत्पादन प्रक्रियाओं के साथ सर्वर-से-सर्वर एकीकरण के लिए बनाया गया है।

प्रमाणीकरण और बेस URL

https://alterproduct.com/public-api/v1

ई-कॉमर्स सेटिंग पैनल में API क्रेडेंशियल बनाएँ। Access Token केवल एक बार दिखता है, इसलिए उसे तुरंत बैकएंड के सीक्रेट स्टोरेज में रखें।

Access Key और Access Token अपने सर्वर पर रखें। प्रमाणीकरण वाले एंडपॉइंट ब्राउज़र से आने वाली ऐसी कॉल अस्वीकार करते हैं जिनमें Origin या Referer हेडर हों।

क्रेडेंशियल के अनुमति-क्षेत्र सीमित किए जा सकते हैं। सक्रिय स्टोरफ़्रंट, योजना की क्षमताएँ और क्रेडेंशियल के अनुमति-क्षेत्र जाँचने के लिए GET /auth/check इस्तेमाल करें।

x-alter-access-key: YOUR_API_KEY
x-alter-access-token: YOUR_API_TOKEN
पैरामीटरआवश्यकविवरण
x-alter-access-keyहाँक्रेडेंशियल का सार्वजनिक पहचानकर्ता।
x-alter-access-tokenहाँऐक्सेस कुंजी से जुड़ा गोपनीय टोकन।
x-alter-client-fingerprintनहींएम्बेड सेशन की दर सीमित करने के लिए वैकल्पिक स्थिर फ़िंगरप्रिंट।
Authorizationकेवल रनटाइमPOST /embed/session से लौटाया गया Bearer टोकन, जिसे /runtime/bootstrap इस्तेमाल करता है।

कनेक्शन परीक्षण

लाइव एकीकरण में सिंक या एम्बेड सुविधाएँ चालू करने से पहले प्रमाणीकरण जाँच एंडपॉइंट इस्तेमाल करें।

GET https://alterproduct.com/public-api/v1/auth/check

उदाहरण अनुरोध (fetch)

const response = await fetch('https://alterproduct.com/public-api/v1/auth/check', {
  method: 'GET',
  headers: {
    'x-alter-access-key': process.env.ALTER_ACCESS_KEY,
    'x-alter-access-token': process.env.ALTER_ACCESS_TOKEN
  }
});

const payload = await response.json();

if (!response.ok) {
  throw new Error(payload?.code || payload?.error || `Alter API ${response.status}`);
}

console.log(payload);

उदाहरण जवाब

{
  "ok": true,
  "message": "success",
  "storefrontId": 12,
  "userOwnerId": 34,
  "credentialId": 56,
  "scopes": ["orders:read", "orders:write", "products:read"],
  "plan": {
    "requiredPlan": "Business",
    "currentPlanName": "Business",
    "eligible": true,
    "runtimeFlags": {
      "viewer": true,
      "configurator": true,
      "customizer": true
    },
    "limits": {
      "activeRuntimeBindingsLimit": 100,
      "monthlyReassignmentLimit": 1000,
      "monthlyEmbedTokenLimit": 50000
    }
  }
}

नीचे दिया हेल्पर बाकी उदाहरणों में इस्तेमाल होता है। यह साधारण fetch है और Node.js 18+ या fetch देने वाले किसी सर्वर रनटाइम में चल सकता है।

const ALTER_API_BASE = 'https://alterproduct.com/public-api/v1';

const authHeaders = {
  'x-alter-access-key': process.env.ALTER_ACCESS_KEY,
  'x-alter-access-token': process.env.ALTER_ACCESS_TOKEN
};

async function alterFetch(path, options = {}) {
  const response = await fetch(`${ALTER_API_BASE}${path}`, {
    ...options,
    headers: {
      ...authHeaders,
      ...(options.body ? { 'Content-Type': 'application/json' } : {}),
      ...options.headers
    }
  });

  const payload = await response.json().catch(() => null);

  if (!response.ok) {
    throw new Error(payload?.code || payload?.error || `Alter API ${response.status}`);
  }

  return payload;
}

एंडपॉइंट का अवलोकन

नीचे की तालिका backend-public-api/app.js में दर्ज सार्वजनिक रूट दिखाती है। पाथ में बाहरी एकीकरण द्वारा इस्तेमाल किया जाने वाला सार्वजनिक प्रॉक्सी प्रीफ़िक्स शामिल है।

विधिएंडपॉइंटविवरणऐक्सेस
GET/public-api/healthzसेवा की हेल्थ जाँच।सार्वजनिक
GET/public-api/v1/auth/checkक्रेडेंशियल सत्यापित करके स्टोरफ़्रंट, अनुमति-क्षेत्र और योजना की क्षमताएँ लौटाता है।कोई भी प्रमाणित क्रेडेंशियल
GET/public-api/v1/customer-ordersपेजिनेशन और फ़िल्टर वाली ग्राहक ऑर्डर सूची लौटाता है।orders:read
GET/public-api/v1/customer-orders/:idकॉन्फ़िगर किए गए उत्पाद आइटम के साथ एक ग्राहक ऑर्डर लौटाता है।orders:read
POST/public-api/v1/customer-orders/batchID से अधिकतम 100 ऑर्डर लौटाता है।orders:read
PATCH/public-api/v1/customer-orders/:id/statusऑर्डर की स्थिति अपडेट करता है।orders:write
PATCH/public-api/v1/customer-orders/:orderId/quantityऑर्डर के चुने हुए विवरणों की मात्रा अपडेट करता है।orders:write
PATCH/public-api/v1/customer-orders/:orderId/quantity/allऑर्डर के हर आइटम के लिए एक समान मात्रा सेट करता है।orders:write
DELETE/public-api/v1/customer-orders/:idस्टोरफ़्रंट मालिक के ग्राहक ऑर्डर को हटाता है।orders:write
GET/public-api/v1/productsएम्बेड उपलब्धता और मीडिया URL के साथ स्टोरफ़्रंट उत्पाद/डिज़ाइन लौटाता है।products:read
GET/public-api/v1/products/:idएक स्टोरफ़्रंट उत्पाद/डिज़ाइन लौटाता है।products:read
POST/public-api/v1/embed/sessionमॉडल जनरेटर सहित एम्बेड किए गए टूल के लिए अल्पकालिक JWT जारी करता है।embed:session:create
GET/public-api/v1/runtime/bootstrapएम्बेड JWT से रनटाइम संदर्भ प्राप्त करता है।Bearer एम्बेड टोकन
GET/public-api/v1/assetsमाँगे गए प्रकार के एसेट कैटलॉग आइटम की सूची देता है।कोई भी प्रमाणित क्रेडेंशियल
GET/public-api/v1/assets/:type/:assetIdडाउनलोड की जा सकने वाली फ़ाइल भूमिकाओं वाला एसेट मैनिफ़ेस्ट लौटाता है।कोई भी प्रमाणित क्रेडेंशियल
GET/public-api/v1/assets/:type/:assetId/files/:roleभूमिका के आधार पर एसेट फ़ाइल डाउनलोड करता है।कोई भी प्रमाणित क्रेडेंशियल
GET/public-api/v1/design-importsAlter पर होस्ट किए गए आयात योग्य डिज़ाइन की सूची देता है।प्रमाणित क्रेडेंशियल, Business योजना आवश्यक
GET/public-api/v1/design-imports/:idडिज़ाइन आयात का पेलोड और फ़ाइल विवरण लौटाता है।प्रमाणित क्रेडेंशियल, Business योजना आवश्यक
GET/public-api/v1/design-imports/:id/files/:fileIdडिज़ाइन आयात विवरण से फ़ाइल डाउनलोड करता है।प्रमाणित क्रेडेंशियल, Business योजना आवश्यक
GET/public-api/v1/file/public/products/:productId/:sizeसार्वजनिक उत्पाद प्रीव्यू लौटाता है। आकार small.png, medium.png या big.png होना चाहिए।सार्वजनिक
GET/public-api/v1/file/protected/:keyस्टोरेज कुंजी से सुरक्षित फ़ाइल लौटाता है।हस्ताक्षरित URL या files:read
GET/public-api/v1/fontsसभी उपलब्ध फ़ॉन्ट लौटाता है।सार्वजनिक
GET/public-api/v1/currenciesसभी मुद्राएँ लौटाता है।सार्वजनिक
POST/public-api/v1/runtime-bindings/sync-from-wordpressWordPress उत्पाद मैपिंग से रनटाइम बाइंडिंग बनाता या अपडेट करता है।कोई भी प्रमाणित क्रेडेंशियल
PATCH/public-api/v1/runtime-bindings/:idरनटाइम बाइंडिंग अपडेट करता है।कोई भी प्रमाणित क्रेडेंशियल
POST/public-api/v1/runtime-bindings/:id/activateरनटाइम बाइंडिंग सक्रिय करता है।कोई भी प्रमाणित क्रेडेंशियल
POST/public-api/v1/runtime-bindings/:id/deactivateरनटाइम बाइंडिंग निष्क्रिय करता है।कोई भी प्रमाणित क्रेडेंशियल
POST/public-api/v1/wp-connect/exchangeWordPress ऑटो-कनेक्ट हैंडऑफ़ कोड के बदले API क्रेडेंशियल देता है।एक बार उपयोग होने वाला हैंडऑफ़ कोड
GET/public-api/v1/model-generator/catalogदिखाई देने वाले जनरेटर उत्पाद, कॉन्फ़िगरेशन और टेम्पलेट संशोधन सूचीबद्ध करता है।embed:session:create
GET/public-api/v1/model-generator/modelsआयात के लिए निश्चित स्रोत संशोधनों वाले जनरेटर विवरण के साथ मॉडल सूचीबद्ध करता है।embed:session:create
GET/public-api/v1/model-generator/designer-catalogDesigner में इस्तेमाल होने वाला जनरेटर मॉडल कैटलॉग लौटाता है।embed:session:create
GET/public-api/v1/model-generator/projectsस्वामी के और सभी के लिए उपलब्ध जनरेटर प्रोजेक्ट सूचीबद्ध करता है।embed:session:create
GET/public-api/v1/model-generator/projects/:projectIdसबसे नया या चुना गया प्रोजेक्ट संशोधन, टेम्पलेट और फ़ाइल मैनिफ़ेस्ट लौटाता है।embed:session:create
GET/public-api/v1/model-generator/projects/:projectId/revisions/:revisionसबसे नया या चुना गया प्रोजेक्ट संशोधन, टेम्पलेट और फ़ाइल मैनिफ़ेस्ट लौटाता है।embed:session:create
GET/public-api/v1/model-generator/projects/:projectId/artifacts/:artifactIdप्रोजेक्ट की पहुँच जाँचने के बाद आउटपुट फ़ाइल डाउनलोड करता है।embed:session:create
GET/public-api/v1/model-generator/configurations/:configurationId/revisions/:revision/templateचुने गए कॉन्फ़िगरेशन संशोधन का पहुँच योग्य टेम्पलेट दस्तावेज़ लौटाता है।embed:session:create
GET/public-api/v1/model-generator/configurations/:configurationId/revisions/:revision/importनिर्भरता फ़ाइलों के साथ टेम्पलेट आयात पैक लौटाता है।embed:session:create
GET/public-api/v1/model-generator/mannequinsदोनों मैनिकिन और उनके संसाधन विवरण लौटाता है।embed:session:create
GET/public-api/v1/model-generator/image-libraries/:kind/assetsआयात योग्य फ़ाइलों के साथ टेक्सचर या बैकग्राउंड लाइब्रेरी के संसाधन सूचीबद्ध करता है।embed:session:create
GET/public-api/v1/model-generator/image-libraries/:kind/assets/:assetIdआयात योग्य फ़ाइलों के साथ एक टेक्सचर या बैकग्राउंड संसाधन लौटाता है।embed:session:create
GET/public-api/v1/model-generator/public-files/:keyजनरेटर की अनुमत निर्भरता फ़ाइल डाउनलोड करता है।embed:session:create

ग्राहक ऑर्डर

ग्राहक ऑर्डर एंडपॉइंट से बाहरी स्टोर कॉन्फ़िगर किए गए आइटम पढ़ सकता है, मात्रा बदल सकता है, ऑर्डर को पूर्ति स्थितियों में आगे बढ़ा सकता है और छोड़े गए ऑर्डर हटा सकता है।

पैरामीटरआवश्यकविवरण
nameनहींडिज़ाइन नाम और संख्यात्मक ऑर्डर ID से खोजता है।
category_idनहींउत्पाद श्रेणी ID से फ़िल्टर करता है।
order_statusनहींस्वीकृत ऑर्डर स्थितियों में से एक।
offsetनहींडिफ़ॉल्ट 0। मान >= 0 होना चाहिए।
limitनहींइस कंट्रोलर के लिए डिफ़ॉल्ट 9, अधिकतम 50।
order_byनहींid, created_at या design_name।
directionनहींASC या DESC।

उदाहरण अनुरोध (fetch)

const params = new URLSearchParams({
  limit: '20',
  offset: '0',
  order_status: 'shopping_cart',
  order_by: 'created_at',
  direction: 'DESC'
});

const orders = await alterFetch(`/customer-orders?${params.toString()}`);

const order = await alterFetch('/customer-orders/123');

const batch = await alterFetch('/customer-orders/batch', {
  method: 'POST',
  body: JSON.stringify({
    customerOrderIds: [123, 124, 125]
  })
});

स्वीकार्य मान

स्थितिविवरण
shopping_cartकार्ट चरण; ग्राहक अभी भी कॉन्फ़िगरेशन संपादित कर सकता है।
editableऑर्डर ग्राहक के लिए संपादन योग्य रहता है।
paidऑर्डर का भुगतान हो चुका है और वह पूर्ति के लिए तैयार है।
processingऑर्डर की पूर्ति की जा रही है।
completedऑर्डर पूरा हो चुका है।
cancelledऑर्डर रद्द कर दिया गया।

उदाहरण अनुरोध (fetch)

await alterFetch('/customer-orders/123/status', {
  method: 'PATCH',
  body: JSON.stringify({
    status: 'processing'
  })
});

await alterFetch('/customer-orders/123/quantity', {
  method: 'PATCH',
  body: JSON.stringify({
    items: [
      { orderDetailId: 987, quantity: 3 }
    ]
  })
});

await alterFetch('/customer-orders/123/quantity/all', {
  method: 'PATCH',
  body: JSON.stringify({
    quantity: 2
  })
});

await alterFetch('/customer-orders/123', {
  method: 'DELETE'
});

उदाहरण जवाब

{
  "order": {
    "id": 123,
    "customizerId": 381,
    "orderStatus": "shopping_cart",
    "createdAt": "2026-05-28T10:15:00.000Z",
    "customizerOrderURL": "https://alterproduct.com/app/customizer/381/123",
    "productItems": [
      {
        "id": 987,
        "model3d": { "id": 381 },
        "size": {
          "id": 395,
          "name": { "pl": "M", "en": "M" },
          "measureSize": null
        },
        "material": {
          "id": 2,
          "name": { "pl": "Bawełna", "en": "Cotton" }
        },
        "printType": {
          "id": 1,
          "name": { "pl": "DTG", "en": "DTG" }
        },
        "color": {
          "id": 418,
          "name": { "pl": "Domyślny", "en": "Default" },
          "hex": "#ffffff"
        },
        "variant": {
          "id": 531,
          "metadata": null,
          "stockQuantity": 25
        },
        "unitPrice": { "value": 12.5, "currency": "EUR" },
        "totalPrice": { "value": 37.5, "currency": "EUR" },
        "quantity": 3
      }
    ],
    "customizerName": "Men's T-Shirt",
    "productGroup": {
      "id": 4,
      "name": { "pl": "Koszulka", "en": "T-Shirt" }
    },
    "totalPrice": { "value": 37.5, "currency": "EUR" }
  }
}

स्टोरफ़्रंट उत्पाद

उत्पाद एंडपॉइंट ऐसे स्टोरफ़्रंट डिज़ाइन लौटाते हैं जिन्हें 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
  }
}

एम्बेड सेशन और रनटाइम बूटस्ट्रैप

अपने सर्वर पर कम अवधि वाला एम्बेड टोकन बनाएँ, 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
}

3D मॉडल जनरेटर

जनरेटर आयात एंडपॉइंट सर्वरों के बीच केवल पढ़ने के अनुरोध स्वीकार करते हैं। इनके लिए सामान्य API हेडर, embed:session:create अनुमति और सक्रिय प्लान ज़रूरी हैं। आयात का प्राधिकरण संपादक सत्र जारी नहीं करता और उसकी मासिक सीमा का उपयोग नहीं करता। संपादक खोलने पर अन्य एम्बेड किए गए टूल वाला साझा monthlyEmbedTokenLimit काउंटर इस्तेमाल होता है।

जनरेटर वाले मॉडल खोजें और आयात करें

जनरेटर वाले उपलब्ध मॉडल सूचीबद्ध करने के लिए /model-generator/models का उपयोग करें। generator विवरण में projectId, revision, configurationId, templateRevision, productId और productModel3dId निश्चित रहते हैं। ठीक वही स्रोत संशोधन पाने के लिए उसके importPath का उपयोग करें। उत्पाद संसाधन मैनिफ़ेस्ट में generators और हर मॉडल का generator विवरण भी मिलता है। टेम्पलेट को कॉन्फ़िगरेशन और संशोधन के आधार पर अलग से आयात किया जा सकता है।

कैटलॉग फ़िल्टर

एंडपॉइंटविवरण
/model-generator/modelsमॉडल सूची: name या q, categoryId, scope में all, own या global, limit में 1–50 और offset।
/model-generator/catalogटेम्पलेट कैटलॉग: generatorType, productId, audience, q, templateKey, configurationId, limit और offset।
/model-generator/projectsप्रोजेक्ट सूची: configurationId, q, scope में all, own या global, limit और offset। सार्वजनिक प्रॉक्सी scope को डिफ़ॉल्ट रूप से all रखता है।
/model-generator/image-libraries/:kind/assetsटेक्सचर/बैकग्राउंड लाइब्रेरी: kind का मान texture या background होता है; q, category और mapType उपलब्ध संसाधनों को फ़िल्टर करते हैं।

प्रोजेक्ट आयात में document, revision, template और files मैनिफ़ेस्ट होता है। हर फ़ाइल /v1/model-generator/ के अंतर्गत एक path देती है; Alter Product से डाउनलोड करते समय उसके आगे /public-api जोड़ें। ज़रूरी फ़ाइलें अपने स्टोरेज में कॉपी करें और स्रोत संदर्भों की जगह स्थानीय संदर्भ रखें। मैनिकिन और टेक्सचर लाइब्रेरी उनके कैटलॉग एंडपॉइंट से आयात करें। public-files केवल अनुमत संसाधन पथों तक सीमित है और टेम्पलेट को कॉन्फ़िगरेशन/संशोधन की पहुँच जाँच में सफल होना चाहिए।

उदाहरण अनुरोध (fetch)

// Server-side: uses the alterFetch helper and authHeaders defined above.
const catalog = await alterFetch('/model-generator/models?' + new URLSearchParams({
  scope: 'all', limit: '24', offset: '0'
}));

const selected = catalog.items[0];
if (!selected?.generator) throw new Error('Select an available generator model');

const importPath = selected.generator.importPath;
if (!importPath.startsWith('/v1/model-generator/projects/')) {
  throw new Error('Invalid generator import path');
}
const bundle = await alterFetch(importPath.slice('/v1'.length));

for (const file of bundle.files) {
  if (!file.path.startsWith('/v1/model-generator/')) {
    throw new Error('Invalid generator file path');
  }
  const response = await fetch('https://alterproduct.com/public-api' + file.path, {
    headers: authHeaders,
    redirect: 'error'
  });
  if (!response.ok) throw new Error(`File download failed: ${response.status}`);
  const bytes = new Uint8Array(await response.arrayBuffer());
  // Persist bytes in your local storage; record the mapping from
  // file.sourceHref / file.href to the resulting local file reference.
}
// Persist bundle.document, bundle.template and revision metadata locally.
// Import the related product asset and its textures/mockups as needed:
const product = await alterFetch('/assets/products/' + selected.generator.productId);
const mannequins = await alterFetch('/model-generator/mannequins');
console.log({ product, mannequins });

संपादक सत्र और स्थानीय स्टोरेज

संपादक सत्र बनाते समय tool: model-generator, स्थानीय जनरेटर प्रोजेक्ट की पहचान करने वाला धनात्मक संख्यात्मक toolId और अनुमत स्टोर origin दें। toolId प्रोजेक्ट का UUID या WooCommerce उत्पाद ID नहीं है। इस टूल के लिए designId, orderId, runtimeBindingId या कार्ट फ़ील्ड न भेजें। जनरेटर प्रोजेक्ट का UUID अलग पहचानकर्ता है। लौटाया गया token iframe हैंडशेक से भेजें; रनटाइम बूटस्ट्रैप storageMode: wordpress_local के साथ जनरेटर संदर्भ लौटाता है।

// Server-side, after authorizing the merchant's access to this local project.
const localProjectId = 42; // Local generator project ID, not its UUID or WC product ID.
const session = await alterFetch('/embed/session', {
  method: 'POST',
  body: JSON.stringify({
    tool: 'model-generator',
    toolId: localProjectId,
    origin: 'https://yourstore.com'
  })
});

// The iframe receives session.token through ALTER_CUSTOMIZER_SESSION_READY.
// Do not put API credentials or the token in the iframe URL.
const bootstrapResponse = await fetch('https://alterproduct.com/public-api/v1/runtime/bootstrap', {
  headers: { Authorization: `Bearer ${session.token}` }
});
if (!bootstrapResponse.ok) throw new Error('Generator bootstrap failed');
const context = await bootstrapResponse.json();
console.log(context);

उदाहरण जवाब

{
  "runtimeBindingId": null,
  "designId": null,
  "productId": 42,
  "toolId": 42,
  "runtimeType": "model-generator",
  "storageMode": "wordpress_local",
  "parentOrigin": "https://yourstore.com"
}
// Host page: WordPress returns a numeric toolId and a UUID in id.
const url = new URL('https://alterproduct.com/app/model-generator');
url.search = new URLSearchParams({
  embedded: '1',
  lng: 'en',
  parentOrigin: window.location.origin,
  toolId: String(localProject.toolId),
  serverProjectId: localProject.id
}).toString();
// Optional: serverProjectRevision pins an existing saved revision.
iframe.src = url.toString();
// Install the authenticated handshake and storage bridge described below.
// Setting iframe.src alone does not authorize the editor or provide storage.

WordPress ब्रिज में इस्तेमाल होने वाले iframe संदेश

WordPress प्लगइन स्टोरेज ब्रिज चलाता है और व्यवस्थापक या WooCommerce प्रबंधक की अनुमतियाँ जाँचता है। यह iframe के origin, स्रोत विंडो, nonce, अनुरोध ID और अनुमत प्रोजेक्ट पथों की पुष्टि करता है। ब्रिज स्थानीय पढ़ने और लिखने के अनुरोध /wp-json/alter-wc/v1/model-generator को भेजता है। API क्रेडेंशियल सर्वर पर रहते हैं। अपने इंटीग्रेशन में इसी तरह का प्रमाणित स्टोरेज प्रबंधन लागू करना ज़रूरी है; सार्वजनिक जनरेटर API प्रोजेक्ट को Alter Product में नहीं सहेजता।

प्रकारविवरण
ALTER_CHILD_HELLO / ALTER_PARENT_ACKचाइल्ड iframe nonce के साथ हैंडशेक शुरू करता है; पैरेंट उसी nonce की पुष्टि करता है।
ALTER_CUSTOMIZER_INIT_SESSION / ALTER_CUSTOMIZER_SESSION_READYचाइल्ड iframe model-generator संपादन सत्र माँगता है; पैरेंट अधिकृत टोकन लौटाता है।
ALTER_MODEL_GENERATOR_REQUESTचाइल्ड iframe requestId, nonce और request भेजता है, जिसमें method, path, data और responseType होते हैं।
ALTER_MODEL_GENERATOR_RESPONSEपैरेंट उसी requestId और nonce के साथ status, data, headers तथा कोई error होने पर उसे लौटाता है।
// Messages after ALTER_CHILD_HELLO / ALTER_PARENT_ACK agree on the nonce.
// Iframe -> parent:
const sessionRequest = {
  type: 'ALTER_CUSTOMIZER_INIT_SESSION',
  nonce: handshakeNonce,
  payload: {
    tool: 'model-generator', alterProductId: localProject.toolId, mode: 'edit'
  }
};

// Parent -> iframe, after the server authorizes the merchant and issues a token:
const sessionReady = {
  type: 'ALTER_CUSTOMIZER_SESSION_READY',
  nonce: handshakeNonce,
  token: session.token,
  tool: 'model-generator',
  cartKey: `model-generator:${localProject.id}`,
  mode: 'edit',
  localSession: false,
  adminSession: true
};
// Send only to the validated iframe's exact origin and source window.
// An authorized token and successful bootstrap are still required.

सहेजने के अनुरोध में expectedRevision, templateRevision, document और आउटपुट फ़ाइलों के संदर्भ भेजे जाते हैं। इससे अपरिवर्तनीय संशोधन बनता है; पुराना expectedRevision भेजने पर HTTP 409 मिलता है। WordPress मेटाडेटा अपने डेटाबेस में और फ़ाइलें uploads डायरेक्टरी में रखता है। JSON को संक्षिप्त किया जाता है और gzip से तभी संपीड़ित किया जाता है जब आकार घटता हो।

// Example message from the iframe; savedSnapshot and artifact IDs come
// from the generator. The host checks origin/source/nonce/project permissions.
const message = {
  type: 'ALTER_MODEL_GENERATOR_REQUEST',
  requestId: crypto.randomUUID(),
  nonce: handshakeNonce,
  request: {
    method: 'POST',
    path: `/pattern-generator/projects/${projectUuid}/revisions`,
    data: {
      expectedRevision: loadedRevision,
      name: projectName,
      templateRevision,
      document: savedSnapshot,
      references: { artifactIds: savedArtifactIds }
    },
    responseType: 'json'
  }
};

डिज़ाइन में सहेजा हुआ मॉडल इस्तेमाल करें क्रिया पूरे सहेजे गए संशोधन को जुड़े हुए डिज़ाइन में प्रकाशित करती है। ग्राहक इसे मौजूदा Customizer, Configurator या Viewer में सामान्य उत्पाद बाइंडिंग और सदस्यता जाँच के साथ देखते हैं। जनरेटर संपादक विक्रेता का टूल बना रहता है। ऑर्डर लिंक सहेजे गए प्रोजेक्ट/संशोधन को बनाए रखते हैं, इसलिए बाद के बदलाव पुराने ऑर्डर को चुपचाप नहीं बदलते।

एसेट कैटलॉग

एसेट कैटलॉग उत्पाद के स्रोत एसेट, पृष्ठभूमि, परिवेश, ग्राफ़िक लाइब्रेरी आइटम, डिज़ाइन टेम्पलेट और मॉकअप एसेट उपलब्ध कराता है। सूची एंडपॉइंट हल्के विवरण लौटाते हैं; विस्तृत एंडपॉइंट में फ़ाइल मैनिफ़ेस्ट होते हैं।

प्रकारविवरण
productsमूल उत्पाद एसेट, प्रीव्यू, 3D मॉडल तथा सामग्री और टेक्सचर विवरण।
backgroundsव्यूअर की स्थिर पृष्ठभूमियाँ।
environmentsपरिवेश मैप और प्रीव्यू चित्र।
image_libraryग्राफ़िक लाइब्रेरी एसेट, जिनमें स्टोरफ़्रंट-विशिष्ट ग्राफ़िक्स भी शामिल हैं।
design_templatesडिज़ाइन टेम्पलेट प्रीव्यू और लेयर फ़ाइल संदर्भ। product_id फ़िल्टर समर्थित है।
mockupsमॉकअप जनरेटर एसेट, पृष्ठभूमि और ओवरले मैप। product_id फ़िल्टर समर्थित है।

उदाहरण अनुरोध (fetch)

const assets = await alterFetch('/assets?' + new URLSearchParams({
  type: 'products',
  limit: '20',
  offset: '0',
  search: 'mug'
}));

const details = await alterFetch('/assets/products/4');

const fileResponse = await fetch(
  'https://alterproduct.com/public-api/v1/assets/products/4/files/preview_medium',
  {
    headers: authHeaders
  }
);

const fileBlob = await fileResponse.blob();

उदाहरण जवाब

{
  "type": "products",
  "items": [
    {
      "assetType": "products",
      "assetId": "4",
      "title": "Mug 450ml",
      "slug": "product-4",
      "description": "Base product 4",
      "primaryRole": "preview_big",
      "fileCount": 8,
      "remoteVersion": "1.0",
      "thumbnail": {
        "role": "preview_small",
        "fileName": "product-4-preview-small.png",
        "mime": "image/png",
        "downloadPath": "/v1/assets/products/4/files/preview_small"
      },
      "metadata": {
        "productCategoryId": 2,
        "productModelCount": 1,
        "isDedicated": false
      }
    }
  ],
  "total": 1,
  "limit": 20,
  "offset": 0
}

डिज़ाइन आयात

डिज़ाइन आयात से Alter पर होस्ट किए गए डिज़ाइन और उनकी फ़ाइलें बाहरी उत्पादन या माइग्रेशन के लिए मिलती हैं। API, Business योजना की पात्रता जाँचती है।

पैरामीटरआवश्यकविवरण
searchनहींडिज़ाइन के शीर्षक या ID से खोजता है।
offsetनहींडिफ़ॉल्ट 0।
limitनहींडिफ़ॉल्ट 20, अधिकतम 100।

उदाहरण अनुरोध (fetch)

const imports = await alterFetch('/design-imports?' + new URLSearchParams({
  limit: '20',
  offset: '0',
  search: 'mug'
}));

const details = await alterFetch('/design-imports/381');

const fileId = details.files[0].id;
const fileResponse = await fetch(
  `https://alterproduct.com/public-api/v1/design-imports/381/files/${fileId}`,
  {
    headers: authHeaders
  }
);

const fileBlob = await fileResponse.blob();

उदाहरण जवाब

{
  "eligible": true,
  "requiredPlan": "Business",
  "currentPlanName": "Business",
  "designs": [
    {
      "id": 381,
      "title": "Men's T-Shirt",
      "createdAt": "2026-01-03T23:55:05.000Z",
      "sourceStorefrontId": 12,
      "productId": 4,
      "productName": {
        "pl": "Koszulka",
        "en": "T-Shirt"
      },
      "storageMode": "alter",
      "runtimeStatus": {
        "designer": true,
        "viewer": true,
        "configurator": true,
        "customizer": true
      },
      "thumbnail": {
        "kind": "design-mockup",
        "fileId": "7df7...",
        "downloadPath": "/v1/design-imports/381/files/7df7..."
      }
    }
  ],
  "total": 1
}

फ़ाइलें, फ़ॉन्ट और मुद्राएँ

सार्वजनिक प्रीव्यू फ़ाइलें सीधे ब्राउज़र में इस्तेमाल की जा सकती हैं। सुरक्षित फ़ाइलों के लिए हस्ताक्षरित URL या files:read अनुमति वाला API क्रेडेंशियल चाहिए। फ़ॉन्ट और मुद्रा एंडपॉइंट सार्वजनिक रूप से पढ़े जा सकते हैं।

एंडपॉइंटऐक्सेसविवरण
/file/public/products/:productId/small.pngसार्वजनिकछोटा उत्पाद प्रीव्यू।
/file/public/products/:productId/medium.pngसार्वजनिकमध्यम उत्पाद प्रीव्यू।
/file/public/products/:productId/big.pngसार्वजनिकबड़ा उत्पाद प्रीव्यू।
/file/protected/:keyहस्ताक्षरित URL या files:readसुरक्षित ऑब्जेक्ट स्टोरेज फ़ाइल।
/fontsसार्वजनिकफ़ॉन्ट रिकॉर्ड की ऐरे।
/currenciesसार्वजनिकमुद्रा रिकॉर्ड की ऐरे।

उदाहरण अनुरोध (fetch)

const publicPreview = await fetch(
  'https://alterproduct.com/public-api/v1/file/public/products/4/medium.png'
);

const protectedFile = await fetch(
  'https://alterproduct.com/public-api/v1/file/protected/user_34/381/design/mockup-large.webp',
  {
    headers: authHeaders
  }
);

const fonts = await fetch('https://alterproduct.com/public-api/v1/fonts').then((res) => res.json());
const currencies = await fetch('https://alterproduct.com/public-api/v1/currencies').then((res) => res.json());

उदाहरण जवाब

[
  {
    "id": 1,
    "family": "Inter",
    "source": "google",
    "category": "sans-serif",
    "variants": ["regular", "600", "700"],
    "subsets": ["latin"],
    "version": "v19",
    "menu": "Inter",
    "files": {
      "regular": "https://..."
    }
  }
]
[
  {
    "id": 1,
    "code": "EUR",
    "name": "Euro",
    "symbol": "€",
    "decimalPlaces": 2
  }
]

रनटाइम बाइंडिंग

रनटाइम बाइंडिंग बाहरी कॉमर्स उत्पादों को 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"
    }
  ]
}

WordPress कनेक्ट एक्सचेंज

WordPress कनेक्ट एक्सचेंज एंडपॉइंट एक बार उपयोग होने वाला हैंडऑफ़ कोड लेता है और प्लगइन को API क्रेडेंशियल लौटाता है। यह सामान्य क्रेडेंशियल बनाने वाला एंडपॉइंट नहीं है।

उदाहरण अनुरोध (fetch)

const response = await fetch('https://alterproduct.com/public-api/v1/wp-connect/exchange', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    code: 'ONE_TIME_HANDOFF_CODE',
    storeUrl: 'https://yourstore.com/',
    siteOrigin: 'https://yourstore.com',
    codeVerifier: 'PKCE_CODE_VERIFIER_32_TO_128_CHARS'
  })
});

const credentials = await response.json();

उदाहरण जवाब

{
  "message": "wpConnect.exchange.ok",
  "accessKey": "generated-access-key",
  "accessToken": "generated-access-token",
  "storefrontId": 12
}

त्रुटियाँ और अनुरोध सीमाएँ

अधिकांश कंट्रोलर त्रुटियाँ code वाले जवाब में एकरूप की जाती हैं। प्रमाणीकरण मिडलवेयर और रेट लिमिटर इसके बजाय error वाला जवाब दे सकते हैं।

// Controller error
{
  "code": "assetCatalog.invalidType"
}

// Auth middleware or rate limit
{
  "error": "Unauthorized"
}

{
  "error": "Too Many Requests"
}
प्रकारसीमासमय अवधि
वैश्विक600 अनुरोध60 सेकंड
GET /auth/check60 अनुरोध60 सेकंड
ऑर्डर पढ़ना/उत्पाद पढ़ना300 अनुरोध60 सेकंड
ऑर्डर लिखना/एम्बेड सेशन/रनटाइम बाइंडिंग120 अनुरोध60 सेकंड
एसेट/डिज़ाइन आयात पढ़ना180 अनुरोध60 सेकंड
फ़ॉन्ट300 अनुरोध60 सेकंड
WP कनेक्ट एक्सचेंज30 अनुरोध60 सेकंड
GET /model-generator/*600 अनुरोध60 सेकंड