crossly-workflows
Latest: v1.0.1
Update from ed3253f
Build and run Crossly workflows
A workflow is a graph of nodes. A trigger node (on.*) emits items; every other node takes items in on a port and sends items out of one or more ports; edges connect ports. A one-step automation is just a small workflow (trigger → action). Old automation rules, workflow chains and standalone sales events were converted into workflows, and the /v1/automation/rules, /v1/automation/runs and /v1/workflow-chains endpoints are deprecated facades over them (sunset 2027-03-01, see the last section).
Scopes: automation:read for every read and for POST /v1/workflows/expressions/preview; automation:write for every other write (create, save, activate, test, run, cancel, retry, decide approvals, rotate webhook URLs, end sales). Auth: crossly-api-setup. Paging, errors, idempotency: crossly-api-conventions.
import { createClient } from '@crossly/sdk';
const crossly = createClient({ pat: process.env.CROSSLY_PAT! });
Setup
- Create a free Crossly account: https://crossly.net/register
- Create a personal access token at https://crossly.net/settings/api/tokens/new (guide: https://crossly.net/guides/personal-access-tokens). Use a
crossly_pat_test_token against the sandbox while building. - Export it as
CROSSLY_PATand send it asAuthorization: Bearer $CROSSLY_PATtohttps://crossly.net/api/v1/*. Full docs: https://crossly.net/docs
Read the catalog first
GET /v1/workflows/catalog (crossly.workflows.catalog()) returns { data: { nodes, capabilities, connectedPlatforms, expressionHelpers, expressionBindings, conditionOperators } }. Each node spec has its type, params (keys, types, defaults, min/max, required), input/output ports, outputSchema, risk and a platform capability; capabilities[key] lists the platforms that capability covers and which of them the seller has connected. Build graphs from it; never guess a node type or param key.
Node families (the catalog is the full list):
| Prefix | Examples |
|---|---|
on.* triggers | on.manual, on.schedule, on.webhook, on.listing.sold, on.listing.age_reached (ageDays), on.listing.no_views_after, on.order.created, on.order.ship_by_soon, on.offer.received, on.message.received, on.inventory.low_stock, on.connection.lost, on.workflow_error |
flow.* | flow.if (true/false), flow.filter (kept/discarded), flow.switch, flow.merge, flow.loop, flow.wait, flow.approval (approved/rejected/timeout), flow.execute_workflow, flow.ab_split, flow.limit, flow.stop |
data.* | data.set, data.aggregate, data.summarize, data.dedupe, data.math, data.text, data.date |
| actions | listing.price_drop, listing.reprice, listing.publish, listing.delist, listing.auto_relist, sale.start, notify.slack / notify.discord / notify.webhook / notify.email_user, http.request, webhook.emit |
Rules every node follows: money params and fields are integer cents (priceCents, floorCents, amountCents); every node puts canonical ids (listingId, orderId, inventoryItemId, platform, offerId…) on its output items, and entity id params default to them (listingId: "{{ $json.listingId }}"), so any node can follow any node.
The graph and the crossly.workflow document
{
"version": 1,
"nodes": [
{ "id": "age", "type": "on.listing.age_reached", "name": "Listed 30 days", "params": { "ageDays": 30 }, "position": { "x": 0, "y": 0 } },
{ "id": "pricey", "type": "flow.if", "name": "Over $25", "position": { "x": 240, "y": 0 },
"params": { "conditions": { "kind": "group", "combinator": "and",
"rules": [{ "kind": "rule", "left": "{{ $json.priceCents }}", "op": "gt", "right": 2500 }] } } },
{ "id": "drop", "type": "listing.price_drop", "name": "Drop 5%", "position": { "x": 480, "y": 0 },
"params": { "mode": "percent", "percent": 5, "floorCents": 1200 } }
],
"edges": [
{ "id": "e1", "source": "age", "sourcePort": "main", "target": "pricey", "targetPort": "main" },
{ "id": "e2", "source": "pricey", "sourcePort": "true", "target": "drop", "targetPort": "main" }
],
"settings": { "timezone": "America/New_York" }
}
Shape limits (shared zod schema): version is the literal 1; at most 300 nodes, 1,000 edges, 200 sticky notes, 2 MB serialised. Node id matches ^[a-z0-9_-]{1,40}$, name 1-120 characters. Optional per node: disabled, notes, retry (maxAttempts 1-10, backoffMs ≤ 3,600,000), timeoutMs (≤ 86,400,000), onError (inherit, stop, continue, error_output), executeOnce, pinnedData (≤ 200 items of { json }). settings: timezone (IANA), onError (stop | continue), errorWorkflowId, maxConcurrentRuns (1-50, default 5), vars, saveSuccessData (default true), notifyOnFailure (default true).
Expressions are {{ … }} holding JSONata. Bindings: $json, $trigger, $node("Name").json, $items("Name"), $run, $workflow, $now, $today, $vars, $itemIndex. Crossly helpers include $money(cents), $cents(dollars), $dollars(cents), $applyPercent(cents, -15), $roundPrice(cents, ending), $daysSince(iso), $coalesce(…). Try one without saving: POST /v1/workflows/expressions/preview { value, item?, trigger?, nodes?, runId?, timezone? } answers { ok: true, value, type } or { ok: false, error } (a bad expression is not an HTTP error). Condition operators: eq, neq, gt, gte, lt, lte, between, contains, not_contains, starts_with, ends_with, matches, in, not_in, exists, not_exists, is_empty, not_empty, is_true, is_false, before, after, within_last, older_than.
Export document. GET /v1/workflows/{id}/export returns { $schema: "https://crossly.net/schemas/workflow-v1.json", format: "crossly.workflow", exportVersion: 1, exportedAt, name, description, tags, templateId, graph, stripped } with Content-Disposition: attachment; filename="<slug>.crossly-workflow.json". Save it under that suffix: SchemaStore maps *.crossly-workflow.json to the published JSON Schema, so editors validate the file. Import ignores $schema, exportedAt and stripped, and only graph is required. Credential-looking params, headers and $vars are blanked, integration and workflow ids are set to null, pinned test data is dropped unless ?pinnedData=true; every blanked path (nodeId.paramKey, settings.vars.<key>) is listed in stripped so the importer knows what to refill.
Validate, create, import
const { data: check } = await crossly.workflows.validate(graph); // POST /v1/workflows/validate
if (check.blocking) throw new Error(JSON.stringify(check.issues)); // issues: { level, code, message, nodeId? }
const { data: created } = await crossly.workflows.create( // POST /v1/workflows → 201 { workflow, issues }
{ name: 'Stale listing markdown', graph, timezone: 'America/New_York' },
{ idempotencyKey: crypto.randomUUID() });
POST /v1/workflows takes from: blank (default; name, description ≤ 5,000, tags ≤ 30 of ≤ 50 chars, graph, timezone, templateId), template (templateId, setup, name, activate) or import (document, name). POST /v1/workflows/import takes the export document itself or { document, name } and answers { workflow, issues, stripped } (crossly.workflows.import(doc, { name })). A draft that does not validate can still be saved; activation refuses it.
curl -sS -X POST https://crossly.net/api/v1/workflows/import \
-H "Authorization: Bearer $CROSSLY_PAT" -H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" --data @stale-markdown.crossly-workflow.json
Templates. GET /v1/workflows/templates?category=&q= lists ready graphs (weekend sale, stale-listing markdowns, offer responder, ship-by alerts…), each with setup: [{ nodeId, paramKey, label }]. POST /v1/workflows/templates/{id}/use { setup, name?, activate? } creates it (crossly.workflows.useTemplate(id, { setup })) and returns activated. Key setup as the template lists it.
Every new workflow starts paused. Create, import, template use and duplicate count against the plan's automation limit: 402 plan_limit_reached. Saves, activation and deletes never do.
Save, activate, pause
PUT /v1/workflows/{id}{ version, name?, description?, tags?, graph? }: pass theversionyou read. A save over a newer one is 409version_conflict: re-read, merge, retry. Saving an active workflow validates it like activation.POST /v1/workflows/{id}/activate: triggers start firing; blocking issues → 422validation_errorwithdetails.issues.POST /v1/workflows/{id}/deactivatepauses (started runs finish).GET /v1/workflows/{id}/versions,POST /v1/workflows/{id}/versions/{v}/restore{ version? }(restores as a new version; 409 if someone saved sinceversion),POST /v1/workflows/{id}/duplicate{ name? },DELETE /v1/workflows/{id}(archives: triggers stop, open runs cancelled, history kept).- List:
GET /v1/workflows?active=true|false&tag=&trigger=on.listing.sold&q=&legacyRef=rule:<id>. Rows have trigger/node types and a 7-day run sparkline, not the graph;GET /v1/workflows/{id}has the graph andversion.
SDK: update, activate, deactivate, listVersions, restoreVersion, duplicate, delete, list, get, export.
Test and run
// Safe test: write, destructive and money nodes report what they would do and change nothing.
const { data: test } = await crossly.workflows.test(id, { mode: 'dry' }); // POST /v1/workflows/{id}/test → 202
// Live run now on selected listings (one kind per call, up to 1,000 ids), active or paused.
await crossly.workflows.run(id, { listingIds: ['…'] }, { idempotencyKey: crypto.randomUUID() });
POST /v1/workflows/{id}/test{ graph?, mode: test|dry, triggerNodeId?, startNodeId?, stopAfterNodeId?, triggerItems? }:testruns for real using pinned data where a node has it;drychanges nothing. Trigger items: the ones you pass, else pinned, else the last real trigger item, else the sample.POST /v1/workflows/{id}/runandPOST /v1/workflows/run-on({ workflowId, … }) takeitems([{ json }]),listingIds,orderIdsorinventoryItemIds(≤ 1,000). The graph must validate (422 otherwise).- Runs are asynchronous (202). Poll
GET /v1/workflow-runs/{runId}(crossly.workflows.getRun), or list withGET /v1/workflows/{id}/runs/GET /v1/workflow-runs?workflowId=&status=&mode=live|test|dry&since=&until=&page=&limit=(limit ≤ 100, default 25). Run statuses:queued,running,waiting,succeeded,failed,cancelled. - Item data:
GET /v1/workflow-runs/{runId}/nodes/{nodeId}(getNodeRun): each port keeps the first 50 items, 16 KB per item (truncated: true). Pruned data comes backnullwithpruned: true; that means "no longer kept", never "no items". Successful live runs lose node data after 30 days, failed runs after 90; run rows go after 180. POST /v1/workflow-runs/{runId}/cancel(409 when finished);POST /v1/workflow-runs/{runId}/retryre-runs a failed run from the failed node (new run withretryOfRunId; succeeded nodes are not repeated; 409 otherwise).
Engine limits: 5,000 node executions per run, 1,000 items into one node, 1,000 loop iterations, 50 concurrent runs per seller, maxConcurrentRuns per workflow (more queue). A failed live run notifies the seller unless settings.notifyOnFailure is false.
Approvals
A flow.approval node parks the run and notifies the seller. GET /v1/workflow-approvals?status=pending,approved,rejected,expired&workflowId= (pending by default) lists them; POST /v1/workflow-approvals/{id}/decide { decision: "approved" | "rejected", note? } (≤ 2,000 chars; approve/reject also accepted) resumes the run down that port. 409 conflict when it was already decided (another device, Telegram, or the timeout).
const { data: pending } = await crossly.workflows.listApprovals();
await crossly.workflows.decideApproval(pending[0].id, { decision: 'approved', note: 'ok' },
{ idempotencyKey: crypto.randomUUID() });
Webhook triggers
An on.webhook node gets a public inbound URL. POST /v1/workflows/{id}/webhooks/{nodeId}/rotate { withSecret?: boolean } (crossly.workflows.rotateWebhook) issues a new URL (the old one stops working) and returns { nodeId, url, secret, rotatedAt } once: store it now. A retried rotate rotates again (it is never replayed from the idempotency store).
Callers POST to that URL (https://crossly.net/api/hooks/workflows/<token>, no PAT). With a secret, send X-Crossly-Signature: sha256=<hex HMAC-SHA256 of the raw body>. Answers: 202 { runId } (never waits for the run), 401 bad or missing signature, 404 unknown/rotated token or paused workflow, 413 body over 256 KB, 429 over 60 requests a minute per token. The run's item is { body, headers (allow-listed), query, method, receivedAt }. The workflow must be active.
Sales events
A sale.start node runs a timed sale. GET /v1/workflows/sales/active (crossly.workflows.sales.active()) lists live and upcoming sales with their workflow, percent off, window and listing count; POST /v1/workflows/sales/{saleEventId}/end (sales.end(id)) ends one now: not started → cancelled, live → closed and every discounted price restored (reverted = listings put back).
Rules, chains and recipes (deprecated)
The /v1/automation/rules endpoints (including import and validate-recipe), GET /v1/automation/runs and the /v1/workflow-chains endpoints are deprecated since 2026-11-27 and work until 2027-03-01; responses carry Deprecation, Sunset and Link: rel="successor-version" headers. Each converted rule or chain is a workflow you can find with GET /v1/workflows?legacyRef=rule:<id> (or chain:<id>, sale_event:<id>). A converted workflow tagged needs-review does nothing until it validates and is activated. Recipe JSON (automation-recipe-v1) is a different, single-step format: see the crossly-automation-recipes skill; build new automations as workflows. Workflow triggers also fire on webhook events (see crossly-webhooks).
MCP (see crossly-mcp-server): get_workflow_catalog, validate_workflow, create_workflow, import_workflow, export_workflow, update_workflow, activate_workflow, deactivate_workflow, test_workflow, run_workflow, list_workflow_runs, get_workflow_run, retry_workflow_run, list_workflow_approvals, decide_workflow_approval, rotate_workflow_webhook, use_workflow_template, list_active_sales, end_workflow_sale.
Rules
- Read
GET /v1/workflows/catalogbefore writing a graph, and validate before you save;blocking: truemeans activation will be refused. - Dry-test (
mode: "dry") before activating anything that changes prices, delists or spends money; activate only after the seller has seen the result. - Money is integer cents in params, items and expressions. Every repeating markdown needs a
floorCents. - Always send
versiononPUT, and handle 409version_conflictby re-reading, never by overwriting. - After an import, refill every path in
stripped(integration ids, secrets) before activating. - Store a rotated webhook URL and secret at once; they are never shown again.
- Send an
Idempotency-Keyon creates, runs and decisions.
Docs: https://crossly.net/docs/workflows-and-scheduled-sales · https://crossly.net/docs/automation-rules · https://crossly.net/docs/api-automation
