Partner API
Build carts from product URLs, handle reviewed quotes as a normal asynchronous state, and pay server-authoritative orders.
Authentication and authority
Keep credentials and all partner API calls on your server.
X-API-Key: sp3nd_...
X-API-Secret: sp3nd_sec_...Base URLschema_versionpayment_readyOrder lifecycle
A review state is a successful order creation, not an API failure.
{
"status": "Created",
"checkout_role": "direct_payment",
"pricing_status": "ready_for_payment",
"requires_manual_quote": false,
"payment_ready": true
}{
"status": "Awaiting Review",
"checkout_role": "manual_review",
"pricing_status": "awaiting_team_quote",
"requires_manual_quote": true,
"payment_ready": false
}{
"checkout_role": "manual_review",
"pricing_status": "shipping_selection_required",
"payment_ready": false,
"selected_shipping_option_id": null
}If any item in a mixed cart needs manual review, the entire cart becomes one `Awaiting Review` order in v2. It is not split into child orders.
checkout_rolepricing_statuspayment_readyCreate a destination-aware cart
Send URLs and quantities. SP3ND resolves product metadata and commerce values.
const response = await fetch(
'https://us-central1-sp3nddotshop-prod.cloudfunctions.net/createPartnerCart',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': process.env.SP3ND_API_KEY,
'X-API-Secret': process.env.SP3ND_API_SECRET
},
body: JSON.stringify({
ship_to_country: 'United States',
ship_to_postal_code: '10007',
items: [{
product_url: 'https://www.ebay.com/itm/123456789',
quantity: 1
}]
})
}
);Carts expire after 30 minutes. A complete `shipping_address` can replace the country/postal shortcut. Legacy clients can send extra item metadata, but caller-supplied titles and prices are not treated as verified data.
Create an idempotent order
One stable idempotency key represents one checkout attempt.
const response = await fetch(
'https://us-central1-sp3nddotshop-prod.cloudfunctions.net/createPartnerOrder',
{
method: 'POST',
headers: {
...authHeaders,
'Idempotency-Key': checkoutAttemptId
},
body: JSON.stringify({
cart_id: cart.cart_id,
customer_email: 'buyer@example.com',
shipping_address: {
name: 'Ada Buyer',
recipient: 'Ada Buyer',
address1: '123 Main Street',
address2: 'Suite 4',
city: 'New York',
state: 'NY',
postalCode: '10007',
country: 'United States',
phone: '+12125550123'
}
})
}
);Idempotency-Keysame key + same requestsame key + changed requestReview quotes and shipping
Poll the order, present current choices, and submit an opaque option ID.
GET https://us-central1-sp3nddotshop-prod.cloudfunctions.net/getPartnerOrder?order_id=abc123
POST https://us-central1-sp3nddotshop-prod.cloudfunctions.net/selectPartnerOrderShippingOption
{
"order_id": "abc123",
"shipping_option_id": "standard"
}quote_revisionquote_expires_atshipping_optionsselected_shipping_option_idselected_shipping_optionselected_manual_shipping_optionQuote revision and expiry are enforced on selection. If the server returns a conflict, refresh the order and show the current options. Never calculate or patch the total client-side.
Pay a ready order
Payment requests identify an order; they do not define the payment.
POST https://us-central1-sp3nddotshop-prod.cloudfunctions.net/createPartnerTransaction
{
"order_id": "abc123"
}
// x402 agents use the same order identity:
POST https://us-central1-sp3nddotshop-prod.cloudfunctions.net/payAgentOrder
{
"order_id": "abc123"
}`order_number` is optional for compatibility and is validated when sent. Caller-provided `amount`, `currency`, `memo`, and `recipient_address` are ignored. Payment endpoints derive all of them from the latest ready order. Payment can begin only when the latest response has `payment_ready: true`; `pricing_status` is informational and is never a second payment gate.
For x402, sign the payment requirements returned by `payAgentOrder`, then submit the signed `PAYMENT-SIGNATURE` back to SP3ND `payAgentOrder`. Do not call a facilitator's verify or settle endpoints directly. SP3ND is the sole settlement authority; after submission, poll the SP3ND order for its authoritative state.
Supported endpoints
Cloud Function endpoint names are part of the public contract.
createPartnerCartCreate a 30-minute cartaddItemToPartnerCart/{cartId}Add one itemupdateCartItemQuantity/{cartId}/{itemId}Change quantityremoveCartItem/{cartId}/{itemId}Remove an itemupdateCartShippingAddress/{cartId}Change destination and repricegetPartnerCart/{cartId}Read a cartcreatePartnerOrderCreate an ordergetPartnerOrder?order_id=...Read one ordergetPartnerOrdersList ordersselectPartnerOrderShippingOptionChoose reviewed shippingcreatePartnerTransactionCreate payment instructionspayAgentOrderPay with x402To list all orders, omit `status` or use `status=all`. The plural `addItemsToPartnerCart` endpoint is not supported in v2.
Lifecycle conflicts
Use machine-readable codes and refresh state after quote conflicts.
ORDER_NOT_PAYMENT_READYPoll the order; do not submit payment.
ORDER_NOT_PAYABLEStop; this order cannot accept payment.
PAYMENT_SETTLEMENT_IN_PROGRESSDo not resubmit payment; poll the order.
PAYMENT_SETTLEMENT_UNKNOWNDo not retry; retain the order ID for manual reconciliation.
IDEMPOTENCY_CONFLICTUse the original payload or a new checkout key.
QUOTE_EXPIREDFetch the current order and quote.
QUOTE_REVISION_CONFLICTRefresh before selecting shipping.
CART_EXPIREDCreate and price a new cart.
RATE_LIMITEDBack off before retrying.
Migration checklist
Support
Email support@sp3nd.shop with your partner name, endpoint, timestamp, and `order_id` or `cart_id`. Never send an API secret or signed payment payload.