Appearance
SDK Snippet Set
These scripts are contract-only and use the public API Gateway surfaces. They are small, intentional helpers that normalize common integration edges.
Downloads
- Client shim (Node.js): /common/snippets/client-shim-node.js
- Client shim (Python): /common/snippets/client-shim-python.py
- MRS gzip+MD5 helper (Node.js): /common/snippets/mrs-gzip-md5-node.js
- MRS gzip+MD5 helper (Python): /common/snippets/mrs-gzip-md5-python.py
- Minimum viable flow (Node.js): /common/snippets/minimum-viable-flow-node.js
- Minimum viable flow (Python): /common/snippets/minimum-viable-flow-python.py
Notes
- Use the custom domain (
https://api.g3nretailstack.com). - GET uses query params; POST uses JSON bodies.
- SDK integration checklist: /common/sdk-integration-checklist.html
Org Verification Gate
Org verification is operator-only (direct Lambda/IAM). The scripts log a reminder at the verification step; you must invoke ofm_orgstatusset via aws lambda invoke before org-scoped writes succeed. See Minimum Viable Flow step 3 for the exact command.
Client shim (header/body normalization + retries)
Use this thin shim to normalize header placement, enforce GET vs POST semantics, and add safe retry posture. It is intentionally small so you can embed it in SDKs or internal tooling.
Downloads:
- Node.js: /common/snippets/client-shim-node.js
- Python: /common/snippets/client-shim-python.py Repo module (versioned):
packages/client-shim(version0.1.1, private; not published)
MRS gzip + MD5 helper
MRS presign/complete flows require gzip payloads and content_md5 computed from the gzipped bytes (hex). These helpers return { gzipped_bytes, content_md5_hex } for JSON payloads.
Downloads:
Minimum viable flow — Node.js (fetch)
js
const API_BASE = process.env.API_BASE || 'https://api.g3nretailstack.com';
const EMAIL = process.env.EMAIL || 'user@example.com';
const PASSCODE = process.env.PASSCODE || 'Passw0rd!123';
const ORGCODE = process.env.ORGCODE || 'ACME';
const INVITE_CODE = process.env.INVITE_CODE || 'INV123';
async function post(path, body, headers = {}) {
const res = await fetch(`${API_BASE}${path}`, {
method: 'POST',
headers: { 'content-type': 'application/json', ...headers },
body: JSON.stringify(body),
});
const json = await res.json();
if (!json.success) {
throw new Error(`${path} failed: ${JSON.stringify(json.error)}`);
}
return json.data;
}
async function get(path, params, headers = {}) {
const url = new URL(`${API_BASE}${path}`);
Object.entries(params || {}).forEach(([k, v]) => {
if (v !== undefined && v !== null) url.searchParams.set(k, String(v));
});
const res = await fetch(url, { method: 'GET', headers });
const json = await res.json();
if (!json.success) {
throw new Error(`${path} failed: ${JSON.stringify(json.error)}`);
}
return json.data;
}
(async () => {
const session = await post('/usm/session/create', {
email: EMAIL,
passcode: PASSCODE,
caption: 'sdk',
session_label: 'sdk',
reason: 'login',
});
const sessionGuid = session.session_guid;
const userGuid = session.user_id;
const ofmHeaders = { 'x-session-guid': sessionGuid };
const org = await post('/ofm/org/create', {
orgcode: ORGCODE,
invitation_code: INVITE_CODE,
user_guid: userGuid,
caption: 'Acme HQ',
}, ofmHeaders);
const orgGuid = org.org_guid;
const orgRev = org.revision;
console.log('Operator-only: verify org via direct Lambda:', { org_guid: orgGuid, expected_revision: orgRev });
const physical = await post('/ofm/facility/physical/create', {
org_guid: orgGuid,
code: 'PHYS1',
caption: 'HQ',
address: { street: '1 Main St', city: 'Austin', region: 'TX', country: 'US' },
phone: '+1-555-0100',
}, ofmHeaders);
const legal = await post('/ofm/facility/legal/create', {
org_guid: orgGuid,
code: 'LEG1',
caption: 'Acme LLC',
address: { street: '1 Main St', city: 'Austin', region: 'TX', country: 'US' },
}, ofmHeaders);
const logical = await post('/ofm/facility/logical/create', {
org_guid: orgGuid,
code: 'LOG1',
caption: 'Online DC',
physical_guid: physical.physical_guid,
legal_guid: legal.legal_guid,
}, ofmHeaders);
const channel = await post('/ofm/sales-channel/create', {
org_guid: orgGuid,
logical_guid: logical.logical_guid,
channel_code: 'WEB',
market_code: 'US',
locale_codes: ['en-US'],
default_locale_code: 'en-US',
}, ofmHeaders);
await post('/ofm/sales-channel/status', {
org_guid: orgGuid,
channel_guid: channel.channel_guid,
status: 'active',
expected_revision: channel.revision,
reason: 'go-live',
}, ofmHeaders);
const pvmHeaders = { 'x-orgcode': ORGCODE, 'x-session-guid': sessionGuid };
const division = await post('/pvm/division', { code: 'DIV1', caption: 'Division 1' }, pvmHeaders);
await post('/pvm/division/status', {
division_id: division.division_id,
status: 'active',
expected_revision: division.revision,
}, pvmHeaders);
const department = await post('/pvm/department', {
division_id: division.division_id,
code: 'DEPT1',
caption: 'Department 1',
}, pvmHeaders);
await post('/pvm/department/status', {
department_id: department.department_id,
status: 'active',
expected_revision: department.revision,
}, pvmHeaders);
const category = await post('/pvm/category', {
department_id: department.department_id,
code: 'CAT1',
caption: 'Category 1',
}, pvmHeaders);
await post('/pvm/category/status', {
category_id: category.category_id,
status: 'active',
expected_revision: category.revision,
}, pvmHeaders);
const vendor = await post('/pvm/vendor', { code: 'VEND1', caption: 'Vendor 1' }, pvmHeaders);
await post('/pvm/vendor/status', {
vendor_id: vendor.vendor_id,
status: 'verified',
expected_revision: vendor.revision,
}, pvmHeaders);
const manufacturer = await post('/pvm/manufacturer', { code: 'MFG1', caption: 'Manufacturer 1' }, pvmHeaders);
await post('/pvm/manufacturer/status', {
manufacturer_id: manufacturer.manufacturer_id,
status: 'verified',
expected_revision: manufacturer.revision,
}, pvmHeaders);
const style = await post('/pvm/style', {
code: 'STYLE1',
category_id: category.category_id,
vendor_ids: [vendor.vendor_id],
manufacturer_ids: [manufacturer.manufacturer_id],
vendor_primary: vendor.vendor_id,
manufacturer_primary: manufacturer.manufacturer_id,
}, pvmHeaders);
await post('/pvm/style/status', {
style_id: style.style_id,
status: 'active',
expected_revision: style.revision,
}, pvmHeaders);
const variant = await post('/pvm/variant', {
style_id: style.style_id,
selections: [],
code: 'VAR1',
}, pvmHeaders);
await post('/pvm/variant/status', {
style_id: style.style_id,
variant_id: variant.variant_id,
status: 'active',
expected_revision: variant.revision,
}, pvmHeaders);
await post('/pvm/identifier/add', {
style_id: style.style_id,
variant_id: variant.variant_id,
type: 'sku',
value: 'SKU-001',
}, pvmHeaders);
const pmcHeaders = { 'x-orgcode': ORGCODE, 'x-session-guid': sessionGuid };
const run = await post('/pmc/publish/run/start', {
style_id: style.style_id,
variant_id: variant.variant_id,
channel_guid: channel.channel_guid,
reason: 'initial publish',
}, pmcHeaders);
let runRev = run.revision;
for (let i = 0; i < 10; i++) {
const step = await post('/pmc/publish/run/step', {
run_id: run.run_id,
expected_revision: runRev,
}, pmcHeaders);
if (step.revision) runRev = step.revision;
if (step.status && step.status !== 'running') break;
}
const product = await get('/pmc/product/get', {
variant_id: variant.variant_id,
channel_guid: channel.channel_guid,
}, pmcHeaders);
console.log('Published product:', product.product && product.product.product_id);
})().catch((err) => {
console.error(err);
process.exit(1);
});Minimum viable flow — Python (requests)
python
import os
import requests
API_BASE = os.getenv('API_BASE', 'https://api.g3nretailstack.com')
EMAIL = os.getenv('EMAIL', 'user@example.com')
PASSCODE = os.getenv('PASSCODE', 'Passw0rd!123')
ORGCODE = os.getenv('ORGCODE', 'ACME')
INVITE_CODE = os.getenv('INVITE_CODE', 'INV123')
session = requests.Session()
def post(path, body, headers=None):
url = f"{API_BASE}{path}"
res = session.post(url, json=body, headers=headers)
data = res.json()
if not data.get('success'):
raise RuntimeError(f"{path} failed: {data.get('error')}")
return data.get('data')
def get(path, params, headers=None):
url = f"{API_BASE}{path}"
res = session.get(url, params=params, headers=headers)
data = res.json()
if not data.get('success'):
raise RuntimeError(f"{path} failed: {data.get('error')}")
return data.get('data')
session_data = post('/usm/session/create', {
'email': EMAIL,
'passcode': PASSCODE,
'caption': 'sdk',
'session_label': 'sdk',
'reason': 'login',
})
session_guid = session_data['session_guid']
user_guid = session_data['user_id']
ofm_headers = { 'x-session-guid': session_guid }
org = post('/ofm/org/create', {
'orgcode': ORGCODE,
'invitation_code': INVITE_CODE,
'user_guid': user_guid,
'caption': 'Acme HQ',
}, ofm_headers)
org_guid = org['org_guid']
org_rev = org.get('revision')
print(f"Operator-only: verify org via direct Lambda: org_guid={org_guid}, expected_revision={org_rev}")
physical = post('/ofm/facility/physical/create', {
'org_guid': org_guid,
'code': 'PHYS1',
'caption': 'HQ',
'address': { 'street': '1 Main St', 'city': 'Austin', 'region': 'TX', 'country': 'US' },
'phone': '+1-555-0100',
}, ofm_headers)
legal = post('/ofm/facility/legal/create', {
'org_guid': org_guid,
'code': 'LEG1',
'caption': 'Acme LLC',
'address': { 'street': '1 Main St', 'city': 'Austin', 'region': 'TX', 'country': 'US' },
}, ofm_headers)
logical = post('/ofm/facility/logical/create', {
'org_guid': org_guid,
'code': 'LOG1',
'caption': 'Online DC',
'physical_guid': physical['physical_guid'],
'legal_guid': legal['legal_guid'],
}, ofm_headers)
channel = post('/ofm/sales-channel/create', {
'org_guid': org_guid,
'logical_guid': logical['logical_guid'],
'channel_code': 'WEB',
'market_code': 'US',
'locale_codes': ['en-US'],
'default_locale_code': 'en-US',
}, ofm_headers)
post('/ofm/sales-channel/status', {
'org_guid': org_guid,
'channel_guid': channel['channel_guid'],
'status': 'active',
'expected_revision': channel['revision'],
'reason': 'go-live',
}, ofm_headers)
pvm_headers = { 'x-orgcode': ORGCODE, 'x-session-guid': session_guid }
division = post('/pvm/division', { 'code': 'DIV1', 'caption': 'Division 1' }, pvm_headers)
post('/pvm/division/status', {
'division_id': division['division_id'],
'status': 'active',
'expected_revision': division['revision'],
}, pvm_headers)
department = post('/pvm/department', {
'division_id': division['division_id'],
'code': 'DEPT1',
'caption': 'Department 1',
}, pvm_headers)
post('/pvm/department/status', {
'department_id': department['department_id'],
'status': 'active',
'expected_revision': department['revision'],
}, pvm_headers)
category = post('/pvm/category', {
'department_id': department['department_id'],
'code': 'CAT1',
'caption': 'Category 1',
}, pvm_headers)
post('/pvm/category/status', {
'category_id': category['category_id'],
'status': 'active',
'expected_revision': category['revision'],
}, pvm_headers)
vendor = post('/pvm/vendor', { 'code': 'VEND1', 'caption': 'Vendor 1' }, pvm_headers)
post('/pvm/vendor/status', {
'vendor_id': vendor['vendor_id'],
'status': 'verified',
'expected_revision': vendor['revision'],
}, pvm_headers)
manufacturer = post('/pvm/manufacturer', { 'code': 'MFG1', 'caption': 'Manufacturer 1' }, pvm_headers)
post('/pvm/manufacturer/status', {
'manufacturer_id': manufacturer['manufacturer_id'],
'status': 'verified',
'expected_revision': manufacturer['revision'],
}, pvm_headers)
style = post('/pvm/style', {
'code': 'STYLE1',
'category_id': category['category_id'],
'vendor_ids': [vendor['vendor_id']],
'manufacturer_ids': [manufacturer['manufacturer_id']],
'vendor_primary': vendor['vendor_id'],
'manufacturer_primary': manufacturer['manufacturer_id'],
}, pvm_headers)
post('/pvm/style/status', {
'style_id': style['style_id'],
'status': 'active',
'expected_revision': style['revision'],
}, pvm_headers)
variant = post('/pvm/variant', {
'style_id': style['style_id'],
'selections': [],
'code': 'VAR1',
}, pvm_headers)
post('/pvm/variant/status', {
'style_id': style['style_id'],
'variant_id': variant['variant_id'],
'status': 'active',
'expected_revision': variant['revision'],
}, pvm_headers)
post('/pvm/identifier/add', {
'style_id': style['style_id'],
'variant_id': variant['variant_id'],
'type': 'sku',
'value': 'SKU-001',
}, pvm_headers)
pmc_headers = { 'x-orgcode': ORGCODE, 'x-session-guid': session_guid }
run = post('/pmc/publish/run/start', {
'style_id': style['style_id'],
'variant_id': variant['variant_id'],
'channel_guid': channel['channel_guid'],
'reason': 'initial publish',
}, pmc_headers)
run_rev = run.get('revision')
for _ in range(10):
step = post('/pmc/publish/run/step', { 'run_id': run['run_id'], 'expected_revision': run_rev }, pmc_headers)
if step.get('revision'):
run_rev = step['revision']
if step.get('status') and step['status'] != 'running':
break
product = get('/pmc/product/get', {
'variant_id': variant['variant_id'],
'channel_guid': channel['channel_guid'],
}, pmc_headers)
print('Published product:', product.get('product', {}).get('product_id'))