Beta, invite only

Bulk Vault API

Show your Bulk Vault inventory on your own site, sell it with your own checkout, and keep stock in sync with eBay automatically.

Quickstart

  1. Request access in Settings > API. Once approved, create a key with the permissions you need.
  2. Keep the key on your server (env var). Never ship it to the browser.
  3. Fetch your cards: GET /api/v1/listings. Each entry is one physical copy with its own photos, condition and price.
  4. When your checkout takes payment, report it: POST /api/v1/orders. Those copies are marked sold and, depending on your setting, their eBay listings are ended.
  5. Add a webhook so your site hears when stock changes anywhere (eBay sales, in-person sales, edits).
curl https://bulkvault.app/api/v1/listings?limit=20 \
  -H "Authorization: Bearer $BULKVAULT_API_KEY"

Limits and errors

120 requests per minute per key. Every response includes X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset; a 429 also has Retry-After. Errors are { "error": { "code", "message" } }.

Selling with Stripe: the recommended setup

Bulk Vault never touches money. Your site takes payment with your own Stripe account and tells Bulk Vault what sold; Bulk Vault keeps stock, eBay and your orders in step. This is the setup we run on our own card shop.

  1. Build in test mode end to end. Pair a Bulk Vault bv_test_ key with a Stripe sandbox sk_test_ key: real catalog, but orders are saved as test orders and nothing is marked sold. Never mix a test key with a live one.
  2. No Stripe Product per card. Create a Checkout Session with inline price_data and put the Bulk Vault listing_id in the line item's metadata.
  3. Prices come from your server. Re-read each copy with GET /listings/{id} when the buyer checks out, and refuse copies that aren't available anymore.
  4. Short sessions. Most cards are one of a kind: set expires_at to about 30 minutes.
  5. Record the sale from the webhook, not the success page. Listen for checkout.session.completed and checkout.session.async_payment_succeeded, only when payment_status is paid, and POST /orders with external_order_id = the session id. Retries are safe. A 409 means a copy sold elsewhere first: refund the buyer in full.
  6. Refunds cancel the order. On a full charge.refunded, find the order by external_order_id and POST /orders/{id}/cancel: the copies go back on hand.
  7. Buyer emails from Bulk Vault events. Subscribe to storefront_order.created and storefront_order.updated and send the confirmation, shipped (with tracking) and cancelled emails from there, so they always match what you did in Website orders.
  8. Delayed payment methods. Bank debits take days to clear while the card stays listed elsewhere. Consider turning them off in Stripe for one-of-a-kind stock.
  9. Keep the two webhook secrets apart. Stripe's start with whsec_, Bulk Vault's with bv_whsec_. Store them in separate env vars, server side only.
  10. Sales tax: Stripe Tax (automatic_tax) works, but only once your state registrations are added in Stripe.

1. Create the Checkout Session

// Your server: POST /checkout { listingIds }
// Re-read every copy from Bulk Vault: prices never come from the browser.
const listings = await Promise.all(listingIds.map(async (id) => {
  const res = await fetch(`https://bulkvault.app/api/v1/listings/${id}`, {
    headers: { Authorization: `Bearer ${process.env.BULKVAULT_API_KEY}` },
  })
  return res.ok ? res.json() : null
}))
if (listings.some((l) => !l || l.status !== 'available')) {
  return Response.json({ error: 'A card just sold' }, { status: 409 })
}

const session = await stripe.checkout.sessions.create({
  mode: 'payment',
  // No Stripe Product per card: describe each copy inline.
  line_items: listings.map((l) => ({
    quantity: 1,
    price_data: {
      currency: 'usd',
      unit_amount: Math.round(l.price * 100),
      product_data: {
        name: l.card.name,
        images: [l.photos.front ?? l.card.imageUrl],
        metadata: { listing_id: l.id }, // read back in the webhook
      },
    },
  })),
  shipping_address_collection: { allowed_countries: ['US'] },
  // One-of-a-kind cards: don't hold the page open for 24 hours.
  expires_at: Math.floor(Date.now() / 1000) + 30 * 60,
  success_url: 'https://yourshop.com/order?session={CHECKOUT_SESSION_ID}',
  cancel_url: 'https://yourshop.com/cart',
})

2. Record the order from Stripe's webhook

// Your Stripe webhook, after verifying Stripe's signature
if (
  (event.type === 'checkout.session.completed' ||
    event.type === 'checkout.session.async_payment_succeeded') &&
  event.data.object.payment_status === 'paid'
) {
  const session = event.data.object
  const lines = await stripe.checkout.sessions.listLineItems(session.id, {
    expand: ['data.price.product'],
  })
  const res = await fetch('https://bulkvault.app/api/v1/orders', {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.BULKVAULT_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      external_order_id: session.id, // retries never sell twice
      items: lines.data.map((li) => ({
        listing_id: li.price.product.metadata.listing_id,
        price: li.price.unit_amount / 100,
      })),
      customer: { email: session.customer_details?.email },
      shipping_address: session.collected_information?.shipping_details?.address,
      amounts: { total: session.amount_total / 100 },
    }),
  })
  if (res.status === 409) {
    // A copy sold somewhere else first: refund in full, tell the buyer.
    await stripe.refunds.create({ payment_intent: session.payment_intent })
  } else if (!res.ok) {
    return new Response('retry', { status: 500 }) // Stripe retries
  }
}

if (event.type === 'charge.refunded' && event.data.object.refunded) {
  // Full refund in Stripe: find the order and cancel it (cards back on hand).
  // GET /api/v1/orders?external_order_id=<session id>, then POST /orders/{id}/cancel
}

Then pack and ship from Website orders in Bulk Vault (or POST /orders/{id}/fulfillment). Order history for a buyer: GET /orders?email=...&expand=listings.

Verifying webhooks

Each delivery has a BulkVault-Signature header, t=<unix>,v1=<hex>, an HMAC-SHA256 of `${t}.${rawBody}` with your endpoint secret. Failed deliveries are retried up to 3 times.

import crypto from 'node:crypto'

// rawBody: the exact request body string (don't re-serialize parsed JSON)
export function verifyBulkVault(rawBody, header, secret) {
  const parts = Object.fromEntries(header.split(',').map((p) => p.split('=')))
  const t = Number(parts.t)
  if (!t || Math.abs(Date.now() / 1000 - t) > 300) return false
  const expected = crypto
    .createHmac('sha256', secret)
    .update(`${t}.${rawBody}`)
    .digest('hex')
  return crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(parts.v1 ?? ''))
}

Reference

Raw spec: /api/v1/openapi.json