Choose an execution API
OmniCommerce’s script endpoints are session-authenticated app endpoints. An
OmniCommerce API key or OAuth token alone does not authenticate these calls.
There is currently no public
/api/v1/scripts execution endpoint. The
Mintlify bearer-token playground does not supply an app session.Prepare a script in OmniCommerce
Open/app/{organizationId}/scripts, create a general TypeScript script, and open its editor. Your organization must have Windmill configured, and your account must have permission to manage and execute scripts.
For a first run, use this example to count a list of up to 500 product IDs:
{"receivedCount":3,"uniqueCount":2}. Test executes real code, including any side effects in your script. Click Deploy and wait for the script to become Active before calling the deployed-run endpoint. Saving a draft alone does not deploy it.
Copy organizationId and scriptId from the editor URL, /app/{organizationId}/scripts/{scriptId}. The script ID is different from its script__... tool name and its Windmill deployment hash.
Start a deployed run
The response is HTTP
201 with { "run": ... }. It can contain a finished run or a run still in progress. Retain run.id before tracking it; HTTP 201 does not establish that the script or every product operation succeeded.
Track completion and read results
Continue with the helper andrunId from the previous example:
await refreshes the current state and can return pending jobs. Repeat this status request with a delay, for example every 2–5 seconds, while jobs are pending. It does not submit the script again. Send all returned run IDs when tracking multiple runs; each request accepts 1–100 job IDs.
The response includes success, jobIds, succeededCount, failedCount, pendingCount, and ordered results. These counts describe script jobs, not individual products. Top-level success is true only when every requested job has succeeded.
For the counting example, a successful run’s
resultRef contains:
GET /api/scripts/{scriptId}/runs?organizationId=YOUR_ORGANIZATION_ID using the same app session. This returns { "items": [...] } and can help locate a submitted run if the original response was interrupted.
Request cancellation
requested, confirmed, and status. A cancellation request is not confirmation that execution stopped. Poll with action: "await" until the outcome is known.
Call Windmill from an external system
Use this option only with your own authorized Windmill workspace credentials. An OmniCommerce API key is not a Windmill token, and access to OmniCommerce Scripts does not itself provide a Windmill token. Windmill provides HTTP webhooks for deployed scripts. Select the asynchronous endpoint for a long-running batch. A script hash identifies a fixed deployed version. Save your script arguments inarguments.json, containing the productIds object shown above with the full list. Send that object directly, without OmniCommerce’s organizationId or args wrapper:
WINDMILL_BASE_URL to your Windmill origin, such as https://app.windmill.dev. Obtain the workspace and deployed script hash from your Windmill script’s Details and Triggers tab. Keep the token in your external system’s secret storage.
The response is a Windmill job UUID. Store it as WINDMILL_JOB_ID and check its state:
type is CompletedJob, inspect success and result. See Windmill’s job API documentation for result and log retrieval. Native Windmill calls return Windmill job responses and are tracked in Windmill; they do not create an OmniCommerce script-run record.
Batch size, retries, and token usage
- OmniCommerce validates
argsagainst the accepted deployment’s schema. The JSON-encoded arguments and returned result each have a 256 KiB limit. A script or downstream API can impose a smaller batch limit. - Pass large ID lists directly to the script. Putting the same IDs in an AOP prompt, model-generated tool arguments, or a tool result still incurs model tokens when those values reach the model.
- Use bounded batches when calling product APIs, validate every target in the authenticated organization, and retain per-product outcomes. Follow the target API’s limits and marketplace capabilities.
- A script’s
succeededstatus means its code completed successfully. If it catches individual errors, its returned result must make partial failures explicit. - Submitting another
POST /runscreates a new invocation. The current HTTP body does not accept an idempotency key. After a timeout or interrupted response, check existing runs before submitting again. - For large reports, have your script save the details to authorized storage and return a compact summary and report reference. A generic product
selectionRefresolver is not provided by these endpoints; it must be implemented by the script’s integration if needed.
Troubleshooting
Use the AOP API when the workflow needs an agent to interpret instructions or choose tools. Use direct script execution when the inputs and operation are already known.