Back to API Partners

Partner API Documentation

Complete guide to integrating SP3ND.shop into your platform

Quick Navigation

Getting Started

Step 1: Apply for Partnership

Submit your application to become a SP3ND partner:

  • Visit the application page or call the applyForPartnership function
  • Provide your company name, contact email, website, and description
  • Specify your expected order volume (low/medium/high)
  • Wait for approval from our team

Step 2: Create Your Partner Account

Once approved, you'll receive an email with instructions:

  1. Visit https://sp3nd.shop/partner-api/signup
  2. Sign up using the email address from your application
  3. After signing in, view your API credentials in the dashboard
  4. ⚠️ IMPORTANT: Save your API Secret immediately - it won't be shown again!

Step 3: Get Your API Credentials

Your credentials are available in the dashboard:

  • API Key: Your public identifier (always visible)
  • API Secret: Your private authentication token (shown only once during initial setup)
  • If you need to regenerate your secret, use the "Regenerate Secret" button in the dashboard

Authentication

Required Headers

All API requests (except application endpoints) require these headers:

Headers:
X-API-Key: sp3nd_xxxxxxxxxxxxxxxx
X-API-Secret: sp3nd_sec_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Authentication Flow

  1. Your system includes both headers in the request
  2. SP3ND validates the API key exists and is approved
  3. SP3ND verifies the API secret matches the hashed version
  4. If valid, the request proceeds; otherwise, you receive a 401 Unauthorized error

Security Best Practices

  • Never expose your API Secret in client-side code or public repositories
  • Store credentials securely (environment variables, secrets manager)
  • Use HTTPS for all API requests
  • Regenerate your secret immediately if it's compromised
  • Rotate secrets periodically (every 90 days recommended)

API Endpoints

Base URL

https://us-central1-sp3nddotshop-prod.cloudfunctions.net

Cart Management

POST /createPartnerCartRequires Auth

Create a shopping cart with items (destination-aware eBay shipping supported)

Request: { items: [...], shipping_address?, ship_to_country?, ship_to_postal_code? }
POST /addItemToPartnerCart/{cartId}Requires Auth

Add single item to cart (auto-scrapes product details, increases quantity if exists; eBay is destination-aware)

Request: { product_url, quantity, shipping_address?, ship_to_country?, ship_to_postal_code? }
PATCH /updateCartItemQuantity/{cartId}/{itemId}Requires Auth

Update item quantity in cart

Request: { quantity }
DELETE /removeCartItem/{cartId}/{itemId}Requires Auth

Remove item from cart

PATCH /updateCartShippingAddress/{cartId}Requires Auth

Update shipping address, reprice eBay shipping, and calculate tax automatically

Request: { shipping_address: {...} }
POST /addItemsToPartnerCart/{cartId}Legacy

Add multiple items to cart (legacy - use addItemToPartnerCart instead)

GET /getPartnerCart/{cartId}Requires Auth

Get cart details and totals

Order Management

POST /createPartnerOrderRequires Auth

Create order from cart with shipping address

Request: { cart_id, shipping_address, customer_email, test }
Test Orders: Set test: true to create test orders (hidden from admin by default, don't affect stats)
GET /getPartnerOrdersRequires Auth

List your orders with optional filters (status, user_wallet, customer_email)

Query Params: limit, offset, status, user_wallet, customer_email
GET /getPartnerOrder/{orderId}Requires Auth

Get single order details with full tracking information

URL: /getPartnerOrder/{orderId} or /getPartnerOrder/{orderNumber}

Payment Processing

POST /createPartnerTransactionRequires Auth

Create payment transaction with memo for order tracking

Important:

  • Memo format must be exactly: SP3ND Order: {order_number}
  • Recipient address: use the recipient_address returned by createPartnerOrder
  • SP3ND checks for payments every minute automatically

Dashboard & Analytics

GET /getPartnerDashboardRequires Auth

Get usage metrics, fees, and revenue share stats

GET /getPartnerKeysRequires Auth

View your API key (secret never returned)

Integration Flow

Complete Order Flow

  1. Partner creates cart with items
    Use simple format: just product_url and quantity
    For eBay items, include destination via shipping_address or ship_to_country + ship_to_postal_code
    SP3ND auto-scrapes product details (title, price, ASIN, image)
    Returns: cart_id
  2. Partner adds more items (optional)
    Use addItemToPartnerCart - auto-scrapes product details
    If item exists, quantity is increased automatically
    Updates cart totals
  3. Partner updates shipping address (optional but recommended)
    Use updateCartShippingAddress to calculate tax/VAT
    eBay shipping is repriced for the new postal code
    If undeliverable, the API returns 409 EBAY_UNDELIVERABLE
    Tax is automatically calculated based on shipping address
  4. Partner creates order from cart
    Returns: order_id and order_number
    Order status: "Created"
    Set test: true for test orders during integration
  5. Partner creates payment transaction
    Returns payment attempt details
    Customer sends payment with memo
  6. SP3ND system detects payment (checks every minute)
    Order status: "Paid"
    SP3ND processes order
  7. Order status updates automatically
    "Ordered""Shipped""Delivered"
    Estimated delivery dates extracted from Amazon emails
    Partner can query order status anytime with getPartnerOrders or getPartnerOrder

Status Progression

CreatedPaidOrderedShippedDelivered
Cancelled can happen at any time

Code Examples

JavaScript/TypeScript Example

// Helper function to make authenticated requests
async function makeAuthenticatedRequest(endpoint, method = 'GET', body = null) {
  const url = `https://us-central1-sp3nddotshop-prod.cloudfunctions.net/\${endpoint}`;
  
  const options = {
    method,
    headers: {
      'Content-Type': 'application/json',
      'X-API-Key': API_KEY,
      'X-API-Secret': API_SECRET,
    },
  };
  
  if (body) {
    options.body = JSON.stringify(body);
  }
  
  const response = await fetch(url, options);
  return await response.json();
}

// Create a cart (simple format - just URL and quantity)
async function createCart(productUrl, quantity = 1) {
  return await makeAuthenticatedRequest('createPartnerCart', 'POST', {
    items: [{ product_url: productUrl, quantity }]
  });
}

// Or create cart with full product details
async function createCartWithDetails(items) {
  return await makeAuthenticatedRequest('createPartnerCart', 'POST', { items });
}

// Add item to cart (auto-scrapes product details)
async function addItemToCart(cartId, productUrl, quantity = 1) {
  return await makeAuthenticatedRequest(`addItemToPartnerCart/\${cartId}`, 'POST', {
    product_url: productUrl,
    quantity
  });
}

// Update cart shipping address (calculates tax automatically)
async function updateCartShippingAddress(cartId, shippingAddress) {
  return await makeAuthenticatedRequest(`updateCartShippingAddress/\${cartId}`, 'PATCH', {
    shipping_address: shippingAddress
  });
}

// Create an order
async function createOrder(cartId, shippingAddress, customerEmail, isTest = false) {
  return await makeAuthenticatedRequest('createPartnerOrder', 'POST', {
    cart_id: cartId,
    shipping_address: shippingAddress,
    customer_email: customerEmail,
    test: isTest, // Set to true for test orders
  });
}

// Create payment transaction
async function createPayment(orderId, orderNumber, amount, recipientAddress, customerWallet) {
  return await makeAuthenticatedRequest('createPartnerTransaction', 'POST', {
    order_id: orderId,
    order_number: orderNumber,
    amount: amount,
    currency: 'USD',
    memo: `SP3ND Order: \${orderNumber}`,
    recipient_address: recipientAddress, // from the createPartnerOrder response
    sender_address: customerWallet,
  });
}

// Get orders (with optional filters)
async function getOrders(limit = 50, status = null, userWallet = null, customerEmail = null) {
  const params = new URLSearchParams({ limit: limit.toString() });
  if (status) params.append('status', status);
  if (userWallet) params.append('user_wallet', userWallet);
  if (customerEmail) params.append('customer_email', customerEmail);
  
  return await makeAuthenticatedRequest(`getPartnerOrders?\${params}`);
}

// Get single order by order_id or order_number
async function getOrder(orderIdOrNumber) {
  return await makeAuthenticatedRequest(`getPartnerOrder/\${orderIdOrNumber}`, 'GET');
}

Complete Order Flow Example

async function processOrder(productUrls, shippingAddress, customerEmail, customerWallet, isTest = false) {
  try {
    // 1. Create cart (start with first item)
    const cartResult = await createCart(productUrls[0], 1);
    const cartId = cartResult.cart.cart_id;
    
    // 2. Add additional items one by one
    for (let i = 1; i < productUrls.length; i++) {
      await addItemToCart(cartId, productUrls[i], 1);
    }
    
    // 3. Update shipping address (calculates tax automatically)
    await updateCartShippingAddress(cartId, shippingAddress);
    
    // 4. Create order
    const orderResult = await createOrder(cartId, shippingAddress, customerEmail, isTest);
    const orderId = orderResult.order.order_id;
    const orderNumber = orderResult.order.order_number;
    const totalAmount = orderResult.order.total_amount;
    
    // 5. Create payment transaction
    const paymentResult = await createPayment(
      orderId,
      orderNumber,
      totalAmount,
      orderResult.order.recipient_address,
      customerWallet
    );
    
    // 6. Return order details to customer
    return {
      orderId,
      orderNumber,
      totalAmount,
      memo: paymentResult.memo,
      recipientAddress: paymentResult.recipient_address,
    };
  } catch (error) {
    console.error('Error processing order:', error);
    throw error;
  }
}

Error Handling

Common Error Codes

Status CodeErrorDescription
400Bad RequestInvalid request parameters
401UnauthenticatedMissing or invalid API credentials
403Permission DeniedPartner account not approved or suspended
409ConflicteBay item undeliverable for destination
404Not FoundResource (cart, order, etc.) not found
410GoneCart has expired
500Internal Server ErrorServer-side error

Error Response Format

{
  error: "Error message describing what went wrong"
}

Best Practices

Cart Management

  • Create carts close to when orders will be placed (30 min expiry)
  • Validate items before creating carts
  • Handle cart expiration gracefully

Order Management

  • Always create orders from valid carts
  • Include customer email for notifications
  • Provide accurate shipping addresses
  • Monitor order status regularly

Payment Processing

  • Use exact memo format: SP3ND Order: {order_number}
  • Use correct treasury wallet address
  • Wait for payment confirmation
  • Handle payment failures gracefully

Security

  • Never expose API secrets in client-side code
  • Use environment variables or secrets manager
  • Rotate secrets periodically
  • Monitor API usage for suspicious activity

Support

For questions or issues: