360 Secure SkillHub
360 安全技能中心

Crossly Buyer API

提供 Crossly Buyer API 的开发集成指南,涵盖 OAuth 买家授权、商品目录、购物车报价、无人值守结账与消费限额、订单售后和反馈,并说明错误、限流、幂等及 Webhook 校验。

分类:开发
crossly
热度 9.17
最近更新 2026-11-30 11:08:00

安装

发给 Agent
帮我安装这个技能:npx secure-skills-cli add crossly/crossly-buyer-api
兼容性
通用兼容
联网要求
需要联网
数据出网
必须出网
Metadata
name
crossly-buyer-api
description
Build a shopper's app on the Crossly Buyer API (/v1/buyer/*) with a buyer OAuth token (buyer:* scopes, no PAT) and @crossly/buyer-sdk createBuyerClient. Covers catalog search, a listing, availability and shipping (buyer:catalog:read), the cart and its delivered quote (cart.addItem, cart.quote, taxComplete, meta.checkoutUrl), unattended POST /v1/buyer/checkout behind buyer:checkout:write and the per-key spending controls (GET/PUT /v1/buyer/checkout/controls), orders (list, eligibility, cancel, received, item-not-received case), feedback, integer-cents money, errors, rate limits, required idempotency and monitor webhook signatures. Use when writing code that acts on a person's own Crossly shopping, or when a Buyer API call returns 401, 402, 403 or 429.

Build on the Crossly Buyer API

The Buyer API acts on a person's own shopping: their cart, what they bought, their offers and lists. It lives on the same host as the seller API but authenticates a different principal: a seller PAT is refused by every /v1/buyer/* endpoint, and a buyer token never works on seller endpoints. For the store side see crossly-api-setup; for agents, monitors and offers see crossly-buyer-shopping-agent.

Setup

  1. Create a free Crossly account: https://crossly.net/register
  2. Buyer calls need an OAuth access token with buyer:* scopes from Crossly sign-in (https://crossly.net/atlas/oauth2/authorize, PKCE). Guide: https://crossly.net/shop/docs/authentication
  3. Send it as Authorization: Bearer <token> to https://crossly.net/api/v1/buyer/*. Full docs: https://crossly.net/docs

Auth: OAuth only, buyer scopes only

There is no buyer personal access token. Every buyer token comes from a person clicking Allow on Crossly's consent screen, including for your own account.

  • Authorization server: issuer https://crossly.net/atlas, authorization code + PKCE S256 (required for every client, confidential ones too). Authorize at https://crossly.net/atlas/oauth2/authorize with resource=https://crossly.net/api/v1, exchange and refresh at POST https://crossly.net/atlas/oauth2/token, revoke at https://crossly.net/atlas/oauth2/revoke. The full flow is in crossly-api-setup.
  • Ask only for buyer:* scopes. A session the shopper proved with a shopping sign-in (for example an emailed link) can grant buyer:* scopes and nothing else.
  • The access token is a JWT that lives 8 hours. Refresh tokens rotate: store the new one every time and never refresh from two processes. A 401 invalid_token after a failed refresh means the shopper disconnected your app (they can at /shop/settings/connected-apps): send them back through consent.
  • Register the app under Settings → API & developers → Your OAuth apps.

Base URL https://crossly.net/api (sandbox https://sandbox.crossly.net/api); every path is under /v1/buyer/*. Send Authorization: Bearer <token>. Keep tokens server-side or in the OS keychain.

Scopes you will use here

Scope Covers
buyer:catalog:read catalog search, browse, listing, availability, shipping, landed cost, sold history, FX
buyer:profile:read GET /v1/buyer/profile, GET /v1/buyer/badges
buyer:cart:read GET /v1/buyer/cart, GET /v1/buyer/cart/saved
buyer:cart:write add/remove lines, save for later, and POST /v1/buyer/cart/quote (the route checks cart:write, though SDK comments say cart:read)
buyer:orders:read orders, export, eligibility, price protection, cases, feedback lists
buyer:orders:write cancel, confirm received, item-not-received, cases
buyer:feedback:write leave and revise feedback
buyer:payment-methods:read / :write list saved cards / choose the default (never adds a card)
buyer:checkout:write spends money: unattended checkout, tips, bids, packs. See below

Ask for the narrowest set. A 403 insufficient_scope names required and have: that needs re-consent with the wider set, not a new login.

The SDK

import { createBuyerClient, CrosslyBuyerAPIError } from '@crossly/buyer-sdk';

const crossly = createBuyerClient({ token: process.env.CROSSLY_BUYER_TOKEN! }); // Atlas access token (JWT)

createBuyerClient({ token, baseUrl?, fetch?, timeoutMs?, userAgent? }) throws CrosslyBuyerConfigError at construction for a missing token or a crossly_pat_…. Version 0.2.0 accepts a JWT or a legacy crossly_oat_… string, but the API no longer honours crossly_oat_ tokens: use the Atlas JWT.

Wrapped methods used on this page: profile.get(), orders.list({ page, limit }), cart.get(), cart.addItem(body, { idempotencyKey }), cart.removeItem(id), cart.quote({ shippingServiceBySeller?, idempotencyKey? }), paymentMethods.list(), paymentMethods.setDefault(id). Everything else (catalog, checkout, order actions, feedback) goes through the escape hatch:

const res = await crossly.http.request<{ data: unknown[]; meta?: { nextCursor?: string } }>({
  method: 'GET', path: '/v1/buyer/catalog/search', query: { q: 'levis 501', limit: 100 },
});

http.request({ method, path, query?, body?, idempotencyKey?, timeoutMs?, signal? }) adds auth and throws CrosslyBuyerAPIError (status, code, details, body, isMissingScope). BUYER_SCOPES and SCOPE_BY_METHOD are exported; @crossly/buyer-sdk/operations exports the generated OPERATIONS table. The SDK never retries. Python: the generated crossly_buyer client lives in https://github.com/crossly-dev/crossly-python (pip install "git+https://github.com/crossly-dev/crossly-python#subdirectory=buyer"; it is not on PyPI yet), or use plain HTTP.

Catalog (buyer:catalog:read)

Endpoint Notes
GET /v1/buyer/catalog/search q, brand, category, condition, seller, minPriceCents, maxPriceCents, listedAfter, inStockOnly, sort = newest, price_low, price_high (no popular), limit 1-100 (default 24). Keyset paged: pass meta.nextCursor back as cursor; cursors are opaque. Send the ETag back as If-None-Match for a free 304
GET /v1/buyer/catalog/browse The shop's browse: format (auction, buy_it_now, offers), returns, sold=true (last 90 days, soldPriceCents), size, color, sort (best_match, newest, price_low, price_high, popular, ending_soon), page 1-50, limit 1-60 (default 24)
GET /v1/buyer/catalog/facets Brands, categories, conditions with live counts: the filter vocabulary
GET /v1/buyer/catalog/listings/{slug} Full listing: priceCents, available, quantityAvailable, variants[] (each with its own id, priceCents, available)
GET /v1/buyer/catalog/listings/{slug}/availability available, quantityAvailable, priceCents, status. The cheap one to poll (ETag); better, create a monitor
GET /v1/buyer/catalog/listings/{slug}/shipping zip (required domestic), state, country (2 letters), quantity 1-999. services[] with id, cents, minDays/maxDays; shipsToCountry, partial
GET /v1/buyer/listings/{slug}/landed-cost country required. status none, included (DDP, charged at checkout) or unavailable (DDU, may be billed at the door); 503 with missingEnv when not configured
GET /v1/buyer/catalog/listings/{slug}/sold-history This listing's own sales, last 50, per-unit cents
GET /v1/buyer/catalog/sellers q (required, 60 chars), limit 1-30
GET /v1/buyer/catalog/fx Display-only rates per 1 USD. Every price and charge is USD

Listings are addressed by slug, the same slug as in the shop URL.

Cart

const line = await crossly.cart.addItem(
  { listingSlug: 'vintage-levis-501', quantity: 1 },          // quantity 1-10; listingVariantId for listings with options
  { idempotencyKey: `cart:${userId}:vintage-levis-501` },
);
const quote = await crossly.cart.quote();
if (!quote.data.taxComplete) showNote('Add a delivery address for the final total');
redirect(quote.meta.checkoutUrl); // the person pays on Crossly
  • GET /v1/buyer/cart lines carry unitPriceCents captured when added, available and listingStatus. The sum of lines is not what will be charged.
  • Adding a listing already in the cart raises its quantity (capped at 10) instead of adding a second line.
  • DELETE /v1/buyer/cart/items/{id} removes a line. POST /v1/buyer/cart/items/{id}/save-for-later, GET /v1/buyer/cart/saved (last 200), POST /v1/buyer/cart/saved/{id}/move-to-cart (at today's price; refused if sold) and DELETE /v1/buyer/cart/saved/{id} manage saved-for-later. A line from an accepted offer cannot be saved for later.
  • POST /v1/buyer/cart/quote runs the real checkout pricing and charges nothing: itemsTotalCents, shippingCents, taxCents, totalCents, dutiesCents/dutiesStatus, per-seller shippingOptions, and meta.checkoutUrl. taxComplete: false means no saved address, so totalCents is a floor: say so. Body (optional): shippingServiceBySeller: { "<sellerUserId>": "<serviceId>" } (an id the seller does not offer there is a 400), registryToken.

Checkout

Default: the person pays on Crossly. Hand them meta.checkoutUrl. The SDK, CLI and MCP server have no purchase method.

Unattended: POST /v1/buyer/checkout buys one listing without the person present, on a card they already saved. Three gates, all required:

  1. The buyer:checkout:write scope, granted explicitly (consent reads "Buy on your behalf — spends money"). It is separate from buyer:cart:write. Ask for it only in the flow that needs it.
  2. The key switched on. "Key" is the credential making the call; for an OAuth app it is your app's grant on that shopper's account. Each key starts off, with its own switch and limits.
  3. The limits, checked before anything is charged.
PUT /v1/buyer/checkout/controls field (all required) Range Meaning
enabled boolean The switch; off takes effect immediately
dailyLimitCents 0-10,000,000 Most this key may spend in a rolling 24 h
perOrderLimitCents 0-10,000,000 Most one purchase may cost, delivered
maxUnitsPerListingPerDay 0-100 Units of one listing per day (stops a runaway loop)

GET /v1/buyer/checkout/controls returns the calling key's { patId, enabled, dailyLimitCents, perOrderLimitCents, maxUnitsPerListingPerDay }. A key changes only its own controls, and needs buyer:checkout:write to do so. Let the shopper choose the numbers on a screen you build; never set them silently.

Body: listingSlug and paymentMethodId (from GET /v1/buyer/payment-methods) required; quantity 1-10; listingVariantId (required on listings with options: without it the quote is refused and details.options lists them); maxTotalCents (send the price the shopper agreed to); shippingServiceId (default cheapest); shipTo { name, street1, city, street2?, state?, zip?, country?, phone? } or the saved address; localPickup; pickupPoint; gift; protectionPlanId; payInCurrency (e.g. "eur", with a 3% conversion charge; limits and maxTotalCents stay USD cents). There is no field for card details.

curl -X POST https://crossly.net/api/v1/buyer/checkout \
  -H "Authorization: Bearer $CROSSLY_BUYER_TOKEN" \
  -H "Idempotency-Key: checkout:$USER_ID:vintage-levis-501:v3" \
  -H "Content-Type: application/json" \
  -d '{ "listingSlug": "vintage-levis-501", "quantity": 1, "paymentMethodId": "pm_…", "maxTotalCents": 6000 }'

The Idempotency-Key is required (400 idempotency_key_required without it). Derive it from what is being bought and reuse it on every retry; a fresh UUID per attempt passes the check and keeps the double-buy bug. The response: totalCents, currency, chargeCurrency, chargeAmountMinor, paymentStatus, paymentIntentId, orderId.

Code Meaning
checkout_not_enabled_for_key The key's switch is off
per_order_limit_exceeded / daily_limit_exceeded / listing_velocity_exceeded A key limit; details has the numbers
over_max_total Delivered total above your maxTotalCents
402 authentication_required The card needs 3-D Secure: a normal outcome. Send the person to the listing to finish
422 currency_unavailable payInCurrency not possible (e.g. a pre-order)
shipping_address_required, buyer_email_required Nothing to ship to / no email on the account
quote_failed, checkout_failed Pricing or charging failed; re-read and decide again

The purchase is an ordinary order with receipts and buyer protection. Log the orderId and tell the person exactly what was bought, for how much, and where to see it. POST /v1/buyer/orders/{id}/tip (amountCents 100-50,000) also charges a saved card and sits behind the same scope and controls.

Orders

Endpoint Scope Notes
GET /v1/buyer/orders orders:read Newest first; page, limit (max 100, default 25). Rows: id, orderNumber, status, buyerPaidCents, createdAt
GET /v1/buyer/orders/export orders:read CSV text in data.csv (up to 5,000 orders, from/to). Its money columns are dollars
GET /v1/buyer/orders/{id}/eligibility orders:read canCancel, canMarkReceived, canLeaveFeedback, inr { eligible, reason, opensAt }, delivery dates, protectionEndsAt. Read it before acting; there is no single-order GET
POST /v1/buyer/orders/{id}/cancel orders:write Full refund while the seller has not bought a label or shipped; else 409 with details.shopCode already_shipped, label_purchased, disputed or already_refunded
POST /v1/buyer/orders/{id}/received orders:write Records receipt and opens feedback; does not release the seller's money sooner or shorten protection; closes the not-received route
POST /v1/buyer/orders/{id}/inr orders:write Item-not-received case: body (required, 2,000 chars), photoUrls (max 6). Only after the delivery window (409 with details.reason, details.opensAt); one case per order, ever; seller gets 72 h. Returns caseId
GET /v1/buyer/orders/{id}/price-protection orders:read until, active, creditedCents (credited to Bucks automatically)
GET /v1/buyer/cases, GET /v1/buyer/cases/{id} orders:read The resolution center; act with POST /v1/buyer/cases/{id}/messages, /respond, /counter, /escalate, /withdraw (orders:write)

Feedback

  • GET /v1/buyer/feedback/pending (orders:read): orders from the last 60 days still needing feedback (purchaseId).
  • POST /v1/buyer/feedback (buyer:feedback:write): reviews[], up to 25, each purchaseId, rating 1-5, optional body (2,000 chars) and ratingAsDescribed, ratingCommunication, ratingShipSpeed, ratingShipCost (1-5). Each entry succeeds or fails alone: read data[].ok and data[].error.
  • GET /v1/buyer/feedback lists what was left; PATCH /v1/buyer/feedback/{id} revises it within 60 days (rating required; omitted detailed ratings stay).

Conventions

  • Money is integer cents in every …Cents field (priceCents, totalCents, buyerPaidCents). Divide by 100 only for display. The order CSV export is the one dollar exception.
  • Envelope: { data } for objects, { data: [...], pagination?, meta? } for lists. pagination is absent when an endpoint returns everything; page until page reaches totalPages. Offers and auctions return the last 100, saved-for-later the last 200.
  • Errors: { error: { code, message, details? }, correlationId? }. Branch on code, log correlationId. 401 refresh or re-consent; 403 scope or spending control; 409 it changed under you, re-read; 422 business rule or a reused idempotency key with a different body.
  • Rate limits are per token (for an app: per shopper's grant), 60-second windows: reads 1,200/min, writes by the shopper's plan (Free 15, Starter 60, Pro 240, Business 1,000, Scale 2,000). Plan for 15 writes a minute. Read X-Quota-Limit, X-Quota-Remaining, X-Quota-Reset; on 429 wait Retry-After and retry writes with the same key.
  • Idempotency: Idempotency-Key replays the first response for 24 h. Optional on most writes, required on POST /v1/buyer/checkout and POST /v1/buyer/gift-cards; always send one on anything that can charge or that would duplicate (an offer retried without one is a second offer).

Webhooks

The Buyer API's webhooks are monitor deliveries (see crossly-buyer-shopping-agent). They use the seller scheme: Crossly-Signature: t=<unix>,v1=<hex HMAC-SHA256(secret, "{t}.{rawBody}")>, verified against the raw body with a constant-time compare and a 300 s tolerance, keyed with the monitor's webhookSecret (returned once at creation). Dedupe on Crossly-Delivery-Id. Reuse the verifier from crossly-webhooks.

Rules

  • Buyer token from OAuth, buyer:* scopes only, server-side; never a PAT, never in a browser bundle.
  • Present cart quotes with taxComplete: false as a minimum, and send people to meta.checkoutUrl to pay.
  • Unattended checkout only with the shopper's explicit scope grant, their switch and their limits, a derived Idempotency-Key, and maxTotalCents. Treat authentication_required as normal.
  • Check GET /v1/buyer/orders/{id}/eligibility before cancel, received or not-received.
  • Never claim a purchase happened unless POST /v1/buyer/checkout returned an orderId.

Docs: https://crossly.net/shop/docs/introduction · https://crossly.net/shop/docs/authentication · https://crossly.net/shop/docs/checkout-controls · https://crossly.net/shop/docs/errors · https://crossly.net/shop/docs/rate-limits · https://crossly.net/shop/docs/idempotency · https://crossly.net/shop/docs/responses-and-pagination · https://crossly.net/docs/api-authentication