Guides
Build a storefront
Hosted site or headless
A hosted site needs no code. Every shop has one at your-shop.3commerce.com, with its theme, home page sections, navigation, pages, blog, and a shopping assistant, all edited in the dashboard under Online store. It shows only your shop's products and collections, and its checkout is 3Commerce's. Choose it unless you need a design or a stack of your own.
A headless storefront is a site you build and host. It reads the public catalog and sends shoppers to the hosted checkout, as the rest of this guide shows. You can sell your own products and, for a commission, other shops' too. The 2 can run side by side: the hosted site stays at its subdomain.
Your hosted site
sites.get reads the site: its address, whether it is published, whether the shop is listed on the 3Commerce marketplace, and its theme, home sections, navigation, pages, and search settings. With the sites:write scope, sites.update publishes it or takes it offline, and lists or unlists the shop. Publishing sends site.published. The look and the content stay in the dashboard's editors, where a merchant previews a change before it goes live.
curl "https://3commerce.com/api/v1/site" -H "Authorization: Bearer 3c_live_…"
# Go live, and list the shop on the 3Commerce marketplace
curl -X PATCH "https://3commerce.com/api/v1/site" \
-H "Authorization: Bearer 3c_live_…" \
-H "Content-Type: application/json" \
-d '{"published": true, "marketplace_listed": true}'Subdomains and custom domains
The subdomain starts as the shop's slug and can be changed in the dashboard. A Pro shop can connect its own domain there too, such as shop.example.com, or an apex and its www together, 1 of them redirecting to the other. The dashboard shows the DNS records to add. The domain is pending until it verifies and points at 3Commerce, which we check every 10 minutes for 3 days, then verified or failed. Once verified, the site answers on it, the subdomain redirects there, and domain.verified is sent.
curl "https://3commerce.com/api/v1/site/domain" -H "Authorization: Bearer 3c_live_…"
# Ask for a fresh check after you change DNS
curl -X POST "https://3commerce.com/api/v1/site/domain/check" -H "Authorization: Bearer 3c_live_…"How headless fits together
A shop on 3Commerce holds the products. Your site shows them with the public Catalog reads, and when a shopper is ready to buy, checkout.create returns a link to 3Commerce's hosted checkout with their items in the bag. You never handle card details.
1. Stock your shop
Create a key with the library:write and products:write scopes in your dashboard, under Developers. Search the dropshipping library, import what you want to sell, and publish it. An import starts as a draft, and keeps the supplier's variants, so its sizes and colors come with it.
curl "https://3commerce.com/api/v1/library?q=linen&limit=10" \
-H "Authorization: Bearer 3c_live_…"
curl -X POST "https://3commerce.com/api/v1/library/LIBRARY_ID/import" \
-H "Authorization: Bearer 3c_live_…"
curl -X POST "https://3commerce.com/api/v1/products/PRODUCT_ID/publish" \
-H "Authorization: Bearer 3c_live_…"2. Show your products
List your shop's live products with catalog.products and its shop filter, and read 1 with catalog.product. Its options are what the shopper picks from, and price_delta is added to the price for a value that costs more.
// Public: no key, so this runs in the browser too.
const base = 'https://3commerce.com/api/v1'
const { data } = await fetch(`${base}/catalog/products?shop=your-shop&limit=24`).then((r) => r.json())
const product = await fetch(`${base}/catalog/products/${data[0].slug}`).then((r) => r.json())
// product.options: [{ id: 'size', label: 'Size', values: [{ id: 'm', label: 'M', price_delta: 0, available: true }] }]3. Send shoppers to checkout
Post the shopper's lines to checkout.create, naming each option by its id and the chosen value by its id. Every option must be chosen. The response prices the lines and carries a checkout_url: send the shopper there to pay and pick delivery. Pass a return_url, and the order confirmation links back to it with ?order=3C-104829 added.
const response = await fetch('https://3commerce.com/api/v1/checkout', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
lines: [{ slug: 'corbett-cotton-linen-straight-leg-pants', quantity: 1, options: { color: 'navy', size: 'm' } }],
return_url: 'https://your-store.com/thanks',
}),
})
const { checkout_url } = await response.json()
window.location.href = checkout_urlSell other shops' products
Your site can sell any live product, not only your own. A shop can offer a commission to storefronts that sell its products: catalog.product returns it as resale_commission_rate, where 0.1 is 10% of the items and 0 means none. To earn it, call checkout.create from your server with your shop's key. Any scope works, since the key only names your shop.
// On your server, so the key never reaches a browser.
const response = await fetch('https://3commerce.com/api/v1/checkout', {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.THREECOMMERCE_KEY}`, 'Content-Type': 'application/json' },
body: JSON.stringify({ lines, return_url: 'https://your-store.com/thanks' }),
})The commission covers the products you sent to the checkout, not ones the shopper adds on 3Commerce or your own products, and not orders you place yourself. It is paid to your Stripe account once the selling shop is paid for the order, and a refund takes back the same share. income.commissions lists what you earned.
After the sale
Each shop in the order gets its own order, visible in the dashboard and through Orders. A library product is ordered from its supplier automatically, and the payout reaches the shop on the usual schedule. To hear about orders, shipments, and commissions as they happen, add a webhook.