Create Your First Store

Create Your First Store

Go from zero to your first API call in under 10 minutes. This guide walks you through creating a store, generating API keys, and adding your first product.

Prerequisites

Step 1: Create Your Store

After signing up, you'll create your first store. A store is a container for all your products, orders, customers, and settings.

Via Dashboard (Recommended)

  1. Go to your dashboard (opens in a new tab)
  2. Click "Create Store"
  3. Enter your store name (e.g., "My Awesome Shop")
  4. Optionally set your domain and currency
  5. Click "Create"

Via API (Advanced)

curl -X POST "https://api.barecommercecore.com/stores" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My Awesome Shop",
    "currency": "USD"
  }'

Step 2: Generate an API Key

API keys authenticate your requests to BareCommerce. Each key has specific scopes that control what it can access.

Via Dashboard

  1. Open your store in the dashboard
  2. Go to Settings → API Keys
  3. Click "Create API Key"
  4. Give it a name (e.g., "Development Key")
  5. Select scopes (for testing, select all)
  6. Click "Create" and copy the key immediately

⚠️ Important: The full API key is only shown once when created. Store it securely in your environment variables.

API Key Format

sk_live_aBcDeFgHiJkLmNoPqRsTuVwXyZ123456

All API keys start with sk_live_ followed by 32 random characters.

Step 3: Set Up Your Environment

Store your API key and store ID as environment variables:

# .env.local (add to .gitignore!)
BARECOMMERCE_API_KEY=sk_live_your_api_key_here
BARECOMMERCE_STORE_ID=your_store_id_here

Test Your Connection

curl "https://api.barecommercecore.com/stores/YOUR_STORE_ID/products" \
  -H "Authorization: Bearer sk_live_YOUR_API_KEY"
 
# Should return: { "items": [], "total": 0 }

Step 4: Create Your First Product

Let's add a product to your store:

curl -X POST "https://api.barecommercecore.com/stores/YOUR_STORE_ID/products" \
  -H "Authorization: Bearer sk_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Classic Blue T-Shirt",
    "slug": "classic-blue-tshirt",
    "price": "29.99",
    "status": "published",
    "description": "A comfortable cotton t-shirt in ocean blue.",
    "sku": "TSHIRT-BLUE-001",
    "stock": 100,
    "trackStock": true
  }'

Response

{
  "id": "prod_abc123def456",
  "storeId": "store_xyz789",
  "title": "Classic Blue T-Shirt",
  "slug": "classic-blue-tshirt",
  "status": "published",
  "price": "29.99",
  "sku": "TSHIRT-BLUE-001",
  "stock": 100,
  "publishedAt": "2024-01-15T10:00:00.000Z",
  "createdAt": "2024-01-15T10:00:00.000Z"
}

🎉 Congratulations! You've created your first product.

Step 5: Fetch Products in Your Frontend

Display your products on a website. Here's a Next.js example:

// app/products/page.tsx
async function getProducts() {
  const res = await fetch(
    `https://api.barecommercecore.com/stores/${process.env.BARECOMMERCE_STORE_ID}/products?status=published`,
    {
      headers: {
        'Authorization': `Bearer ${process.env.BARECOMMERCE_API_KEY}`,
      },
      next: { revalidate: 60 },
    }
  );
  
  if (!res.ok) throw new Error('Failed to fetch products');
  return res.json();
}
 
export default async function ProductsPage() {
  const { items: products } = await getProducts();
 
  return (
    <div className="grid grid-cols-3 gap-6">
      {products.map((product) => (
        <div key={product.id} className="border rounded-lg p-4">
          <h2 className="font-bold">{product.title}</h2>
          <p className="text-gray-600">{product.description}</p>
          <p className="text-xl font-bold mt-2">${product.price}</p>
        </div>
      ))}
    </div>
  );
}

What's Next?

Quick Reference

Base URL

https://api.barecommercecore.com

Authentication Header

Authorization: Bearer sk_live_YOUR_API_KEY

Store-scoped Endpoints

EndpointDescription
/stores/:storeId/productsProducts
/stores/:storeId/ordersOrders
/stores/:storeId/customersCustomers
/stores/:storeId/categoriesCategories
/stores/:storeId/mediaMedia
/stores/:storeId/webhooksWebhooks

Need Help?