360 Secure SkillHub
360 安全技能中心

Crossly Sandbox testing

说明如何在不触碰真实店铺和资金的前提下测试 Crossly 集成:区分独立沙箱环境与 OAuth 应用沙箱,用测试令牌调用 API,通过模拟订单、取消、退款、发货等事件触发真实签名 Webhook,并给出隔离错误码、失败注入和测试 Webhook 的用法。

分类:开发
crossly
热度 9.20
最近更新 2026-11-30 11:11:12

安装

发给 Agent
帮我安装这个技能:npx secure-skills-cli add crossly/crossly-sandbox-testing
兼容性
通用兼容
联网要求
需要联网
数据出网
必须出网
Metadata
name
crossly-sandbox-testing
description
Test a Crossly integration without touching real stores, marketplaces or money. Covers the separate sandbox environment (https://sandbox.crossly.net/api, crossly_pat_test_ tokens, 401 credential_environment_mismatch, the Crossly-Environment header, seeded data, Stripe test mode, weekly reset) and the app sandbox for OAuth apps (a sandbox twin client, seeded sandbox sellers, simulated marketplaces, POST /v1/sandbox/simulate/order, order.cancelled, refund, order.delivered, order.address, listing.sold_out, inventory, POST /v1/sandbox/reset, GET /v1/sandbox/events, the Crossly-Sandbox-Simulate failure-injection header), plus webhook test fires (POST /v1/webhooks/{id}/test) and crossly dev --forward. Use when writing tests or a staging setup for Crossly code, simulating orders and refunds to exercise webhooks, or debugging sandbox_only, sandbox_not_supported or sandbox_environment_mismatch errors.

Test against the Crossly sandbox

Crossly has two test setups. Pick by what you are building:

Sandbox environment App sandbox
For your own scripts, agents, SDK and CLI code a third-party OAuth app other sellers install
Where a second Crossly: https://sandbox.crossly.net/api, its own database and accounts production Crossly, against sandbox sellers you create
Credential crossly_pat_test_… minted in the sandbox your app's sandbox twin client (own client id, secret, redirect URIs), authorized as a sandbox seller
Marketplaces connections disabled simulated eBay, Poshmark, Mercari, Shopify, Crossly's shop, …
Money Stripe test mode none: no charges, payouts, labels or CBX
Crossly-Environment response header sandbox sandbox
Simulations (/v1/sandbox/*) no yes

For token basics see crossly-api-setup; for OAuth app registration see crossly-oauth-apps.

Setup

  1. Create a free Crossly account: https://crossly.net/register
  2. 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.
  3. Export it as CROSSLY_PAT and send it as Authorization: Bearer $CROSSLY_PAT to https://crossly.net/api/v1/*. Full docs: https://crossly.net/docs

1. The sandbox environment

Sign in at sandbox.crossly.net (a separate account from production), open Settings → API & developers and mint a token: it is a test token, the only kind the sandbox accepts.

export CROSSLY_PAT=crossly_pat_test_…
curl -i https://sandbox.crossly.net/api/v1/me -H "Authorization: Bearer $CROSSLY_PAT"
# crossly-environment: sandbox

@crossly/sdk reads the environment word in the token and picks the base URL itself:

import { createClient } from '@crossly/sdk';
const crossly = createClient({ pat: process.env.CROSSLY_PAT! }); // _test_ → https://sandbox.crossly.net/api

The CLI does not switch on its own (it defaults to https://crossly.net/api): set CROSSLY_API_BASE_URL=https://sandbox.crossly.net/api. See crossly-cli.

  • Environment enforcement. crossly.net accepts only crossly_*_live_… credentials and the sandbox only crossly_*_test_… (PATs, OAuth tokens, publishable keys). The wrong one is 401 credential_environment_mismatch before anything else runs. Never override baseUrl to point a test token at production or the reverse.
  • Seeded data. A market catalogue in three book shapes (sneakers by size, raw cards by condition, graded slabs by grade) with asks from a demo seller on a paid plan and bid ladders from seeded players.
  • Payments. Stripe test mode: 4242 4242 4242 4242, any future expiry, any CVC; Stripe's documented test cards for declines, 3-D Secure and disputes. Payouts are simulated by Stripe.
  • Resets weekly (Sunday 05:00 UTC). Keep fixtures in code and re-create them, never depend on sandbox state surviving.
  • Marketplace connections are disabled; rate limits and scopes are the same as production.

2. The app sandbox (OAuth apps)

  1. Sandbox credentials. Settings → API & developers → your app → Sandbox tab → Create sandbox credentials. A second OAuth client with its own client id, secret (shown once) and redirect URIs (empty = reuse the live ones; http://localhost works). Its scopes follow your live app.
  2. Sandbox sellers. Same tab → Create sandbox seller. Up to ten; one idle for 30 days is deleted. A sandbox seller cannot sign in, gets no email and is never public. Seed: SKUs such as SBX-LEVI-501-3230 and SBX-NIKE-AM90-10 live on simulated eBay, Poshmark, Mercari and Crossly's shop; a tee in S/M/L as a variation group; dropship items with a supplier and costBasisCents (retail from Walmart and Amazon, one wholesale); an order waiting to ship on Crossly's shop and on eBay with full addresses; a delivered past sale.
  3. Authorize with the sandbox client id through the normal Atlas flow. The consent screen shows a Sandbox banner and asks which sandbox seller the app acts on; the token acts on that seller only.
  4. Call the API exactly as in production (GET /v1/inventory, POST /v1/listings, POST /v1/orders/{id}/tracking, POST /v1/webhooks). GET /v1/connections lists every simulated channel as connected.
curl -s https://crossly.net/api/v1/sandbox -H "Authorization: Bearer $SANDBOX_TOKEN"
# { environment: "sandbox", seller: { id, label, seedVersion, seededAt, lastResetAt }, channels: [...],
#   simulate: { header: "Crossly-Sandbox-Simulate", values: ["none","rate_limited","platform_error"] }, ttlDays }

Simulations

Each runs the real pipeline, so your webhooks get real, signed payloads.

Call Body Scope (any of) Webhooks
GET /v1/sandbox orders:read, listings:read, inventory:read
POST /v1/sandbox/simulate/order lines (1–20 of { listingId | sku, quantity 1–100, unitPrice }), platform, address (inline | delayed), buyer { username, email, address }, shippingCharged orders:write, orders:read order.created, sale.detected, stock and cross-channel updates
POST /v1/sandbox/simulate/order.cancelled orderId, reason (≤ 300) same order.cancelled
POST /v1/sandbox/simulate/refund orderId, amount (dollars; omit = full), reason same refund.issued
POST /v1/sandbox/simulate/order.delivered orderId same order.delivered
POST /v1/sandbox/simulate/order.address orderId, optional address { name, line1, line2?, city, state, zip, country (2), phone? } same order.address_available
POST /v1/sandbox/simulate/listing.sold_out listingId, platform inventory:write, listings:write stock moves, other channels delist (listing.delisted)
POST /v1/sandbox/simulate/inventory inventoryItemId or sku, mode (set | increase | decrease), value (0–1,000,000) same quantity pushed to every channel
POST /v1/sandbox/reset same back to the seed; your grant and webhook subscriptions are kept
GET /v1/sandbox/events?limit= read the simulated marketplaces' call log (verb, platform, outcome, latencyMs)

Money in unitPrice, shippingCharged and amount is dollars.

const crossly = createClient({ pat: process.env.SANDBOX_TOKEN! }); // the sandbox client's access token

const order = await crossly.sandbox.simulateOrder(
  { lines: [{ sku: 'SBX-LEVI-501-3230', quantity: 1 }], platform: 'ebay', address: 'delayed' },
  { idempotencyKey: crypto.randomUUID() },
);
// { platform, platformOrderId, orderIds: [...], addressPending: true }
await crossly.sandbox.addressArrived({ orderId: order.orderIds[0] });   // order.address_available now
await crossly.sandbox.simulateRefund({ orderId: order.orderIds[0], amount: 5 });
await crossly.sandbox.reset();

SDK: crossly.sandbox.info, reset, simulateOrder, simulateCancellation, simulateRefund, simulateDelivery, addressArrived, simulateSoldOut, simulateInventory, events. MCP: sandbox_info, sandbox_reset, sandbox_simulate_order, sandbox_simulate_cancellation, sandbox_simulate_refund, sandbox_simulate_delivery, sandbox_simulate_address, sandbox_simulate_sold_out, sandbox_simulate_inventory, sandbox_events. CLI: crossly sandbox simulate-order, simulate-refund, reset, …

curl -X POST https://crossly.net/api/v1/sandbox/simulate/order \
  -H "Authorization: Bearer $SANDBOX_TOKEN" -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"lines":[{"sku":"SBX-NIKE-AM90-10","quantity":1}],"platform":"crossly","address":"delayed"}'

Pushing tracking with POST /v1/orders/{id}/tracking marks the order shipped (order.shipped) and the simulated carrier delivers about 15 seconds later (order.delivered).

Marketplace behaviour and failure injection

  • Every simulated marketplace call takes 150–900 ms; publish, delist and quantity pushes complete in the background (POST /v1/listings returns job ids, listing.created follows).
  • Send Crossly-Sandbox-Simulate: rate_limited or platform_error on any sandbox call and every marketplace call that request causes fails that way (429-shaped or 502-shaped). Ignored on live tokens. SDK: { simulate: 'rate_limited' } on sandbox calls, or sandboxSimulate on a raw request.
  • Production dropship rules apply: crossposting a retail-sourced item to eBay, or any supplier item to Poshmark, is refused with dropship_not_allowed_on_platform.

Isolation errors

Status error.code Cause
403 sandbox_only a live token on /v1/sandbox/*
403 sandbox_not_supported a sandbox token on a route outside the seller-app surface (buyer checkout, billing, payouts, label purchases, AI generation, …)
401 sandbox_environment_mismatch a live token on a sandbox seller or a sandbox token on a live one
404 not_found the sandbox seller was deleted (idle 30 days): create another and re-authorize

3. Test webhooks

  • POST /v1/webhooks/{id}/test (webhooks:write) sends test.ping; with body { "event": "order.created" } it sends a sample of that event marked "test": true. Response { ok, deliveryId, message }. SDK crossly.webhooks.test(id, { event: 'order.created' }); the MCP test_webhook tool (and so crossly webhooks test) only sends test.ping.
  • In the app sandbox, the simulations above fire real events; each delivery is in GET /v1/webhooks/{id}/deliveries and on the app's Sandbox tab, with Redeliver.
  • Local development with no tunnel: crossly dev --forward http://localhost:3000/webhooks holds an outbound stream (GET /v1/webhooks/stream, webhooks:read) and re-POSTs each event as a real delivery envelope signed with --secret, else CROSSLY_WEBHOOK_SECRET, else a printed whsec_dev_…. --events a,b filters. Non-localhost targets need CROSSLY_DEV_ALLOW_REMOTE=1. Forwards carry x-crossly-forwarded-by: crossly-cli.
curl -X POST https://crossly.net/api/v1/webhooks/$WEBHOOK_ID/test \
  -H "Authorization: Bearer $CROSSLY_PAT" -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" -d '{"event":"order.created"}'

Verification code is in crossly-webhooks.

Rules

  • Keep live and test credentials in separate secrets; branch on the Crossly-Environment header in logs and assertions, never on the base URL alone.
  • Re-create fixtures per run: the sandbox resets weekly and POST /v1/sandbox/reset restores the seed.
  • Exercise the async cases: address: "delayed", partial refunds, cancellations, and Crossly-Sandbox-Simulate failures, and make your handlers idempotent on the event id.
  • Run your app end to end against a sandbox seller before listing it in the directory.

Docs: https://crossly.net/docs/api-sandbox · https://crossly.net/docs/api-app-sandbox · https://crossly.net/docs/api-webhooks · https://crossly.net/docs/api-authentication