Skip to main content

Setup

Before Mercatto can do anything, it needs to exist on Ishtaran: an Organization, an Application to hold its integration, an Environment, and a key to authenticate with. One call does all four.

examples/marketplace-mercatto/setup.ts
const owner = createClient();
const signup = await owner.auth.signUp(`Mercatto ${runId}`, emails.owner, STORY_PASSWORD);

const mercatto = createClient(signup.apiKeyPlainText!);

Result​

{
"organizationId": "…",
"applicationId": "…",
"environmentId": "…",
"apiKeyPlainText": "isht_sandbox_…"
}

Two clients come out of this step, and Mercatto keeps both:

  • owner — a Member session. A handful of real operations later on require this specifically, not an API Key (see Architecture).
  • mercatto — the Application API Key. Everything else uses this one, the same as any real integrator would.

What happened under the hood​

auth.signUp() → OrganizationTenancy creates the Organization, its default Application, that Application's Sandbox Environment, and a first API Key — atomically, one real HTTP call. The Asset Network Mercatto will trade in (USDT on Tron, in Sandbox) isn't hardcoded: setup.ts looks it up by symbol/network code, the same way an integrator would when pointing at a Sandbox they didn't seed themselves.

examples/marketplace-mercatto/setup.ts
async function resolveUsdtTronAssetNetworkId(owner) {
const assetNetworks = await owner.assetNetworkCatalog.listAssetNetworks();
for (const candidate of assetNetworks) {
const [asset, network] = await Promise.all([
owner.assetNetworkCatalog.getAsset(candidate.assetId),
owner.assetNetworkCatalog.getNetwork(candidate.networkId),
]);
if (asset.symbol === 'USDT' && network.code === 'tron') return candidate.assetNetworkId;
}
throw new Error('No USDT/Tron Asset Network found in this Sandbox.');
}

assetNetworkCatalog is real, but — like workflows and accounts.authorizeApplication — Member-only today, not reachable with an API Key. That's why this lookup runs on owner, not mercatto.