Skip to content

Your first App ​

Build a merchant order action that writes { "flag": true } to your App's metadata. This minimal example fits SDK 0.1.0's types and does not change the order's shipping status.

Prepare your environment and tools ​

You need Node 24, pnpm 11.24.0, Python 3.11+, permission to create and release an App in the Developer Portal, and a merchant environment where you can install a test App. Register or sign in to the Developer Portal and create an App with installation owner merchant. Contact the platform administrator first if your account does not have access.

CLI 0.7.0 and SDK 0.1.0 are not published to the npm registry. Obtain versioned tool packages or access to the tools repository from the platform. With the matching tools source checkout, run these commands in that directory. They install dependencies, package the tools, and create a project without starting a server:

sh
pnpm install --frozen-lockfile
pnpm pack:packages
node packages/cli/bin/gowarehouse.mjs app init --name metadata-demo --installation-owner merchant --template admin-action --path ../metadata-demo

The generator includes versioned packages in the new project. Run pnpm install from that project and retain its lockfile and tool archives. The destination must not already exist; do not overwrite an existing App.

Link and configure the App ​

Run from the new project, replacing the example email and YOUR_APP_UUID:

sh
pnpm exec gowarehouse auth login --hub https://developer.gowarehouse.ai --email [email protected]
pnpm exec gowarehouse app config link --hub https://developer.gowarehouse.ai --app-id YOUR_APP_UUID --force

--force allows replacement of this new project's App configuration; it does not bypass Portal authorization. After linking, check gowarehouse.app.toml:

  • installation_owner = "merchant", with the client ID from your real linked App.
  • [access_scopes] has scopes containing orders:read,orders:write.
  • [gowarehouse] has partners_api_version = "2026-10"; verify that the destination supports it first.
  • Set application_url, auth_origins, and other URLs to your working, approved HTTPS origins. Do not publish the generated example.invalid defaults.

Use admin.order-details.action.render and api_version = "2026-10" in the extension TOML. Preserve its generated UID, module path, and capabilities. See App configuration.

Add the action and translations ​

Replace the generated extensions/<handle>/src/Action.ts with this example. It creates UI using the Host's s-admin-action, s-button, and s-text, and passes the entire operation Promise to respondWith.

ts
import { getExtensionAPI } from '@gowarehouse/ui-extensions';

export default function render() {
  const api = getExtensionAPI();
  const t = (key: string) => api.i18n.translate(key);
  const action = document.createElement('s-admin-action');
  action.setAttribute('heading', t('name'));
  const status = document.createElement('s-text');
  const save = document.createElement('s-button');
  save.setAttribute('slot', 'primaryAction');
  save.textContent = t('save');
  const close = document.createElement('s-button');
  close.textContent = t('close');

  async function saveFlag() {
    const orderId = api.data.selected[0]?.id;
    if (!orderId) { status.textContent = t('missingOrder'); return; }
    save.disabled = true;
    status.textContent = t('saving');
    let written = false;
    try {
      const result = await api.request({
        method: 'PATCH',
        path: `/orders/${orderId}/metadata`,
        body: { flag: true },
      });
      if (!result.success) {
        status.textContent = `${t('denied')} (${result.message})`;
        return;
      }
      written = true;
      status.textContent = t('saved');
      try {
        await api.refresh();
      } catch {
        status.textContent = t('savedRefreshFailed');
      }
    } catch {
      status.textContent = t('unknownResult');
    } finally {
      save.disabled = written;
    }
  }

  save.addEventListener('click', event => event.respondWith(saveFlag()));
  close.addEventListener('click', event => event.respondWith(api.close()));
  action.append(status, save, close);
  document.body.append(action);
}

Download Action.ts, English translations, and Traditional Chinese translations. Save the translations as the extension's locales/en.default.json and locales/zh-TW.json. Their key sets must match.

Package and install ​

Run in the App project:

sh
pnpm exec gowarehouse app config validate
pnpm exec gowarehouse app package --version 0.1.0

CLI 0.7.0 writes out/<handle>-0.1.0.gwapp. Successful packaging verifies configuration and bundle checks; it does not install the App or verify authorization on a real deployment.

Follow the release workflow to upload, submit, and publish, then have an authorized person consent to installation in your test merchant environment. The tools do not approve submissions or install on behalf of merchants.

Verify the result ​

  1. Open a test merchant order as a user with order edit permission.
  2. Open the App action and select “Save flag.” A successful write displays “Flag saved.”
  3. “Flag saved. Reload the order page” means the write succeeded but refresh failed; do not interpret it as a failed write.
  4. Use the same App's metadata read to confirm metadata.flag is true. This is not a native order status and does not automatically appear in a native order field.
  5. To clean up, send { "flag": null } from the same App. See Host SDK for the SDK type limitation on general patches.

The example's TypeScript and static build can be checked independently. Installation, authorization, and UI execution must still be verified on the destination deployment using this workflow. See Troubleshooting if needed.

Last updated 2026-11-29 21:53