Documentation

Everything you need to integrate BaaS Platform into your e-commerce frontend.

Base URL

url
https://api.baasplatform.com

All API endpoints are relative to this base URL. For tenant-specific endpoints, use your subdomain: https://yourstore.baasplatform.com

Quick Start

Follow these steps to integrate your frontend with BaaS Platform:

1

Register your business

bash
curl -X POST https://api.baasplatform.com/api/platform/register/ \
  -H "Content-Type: application/json" \
  -d '{
    "business_name": "My Store",
    "email": "owner@mystore.com",
    "password": "securepassword123",
    "first_name": "John",
    "last_name": "Doe"
  }'
2

Get your API key

bash
curl -X POST https://api.baasplatform.com/api/platform/api-keys/ \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "Production API Key"}'
3

Make API requests to your store

bash
curl https://mystore.baasplatform.com/api/store/products/ \
  -H "X-API-Key: YOUR_API_KEY"

Authentication

BaaS Platform uses JWT tokens for admin authentication and API keys for storefront access.

JWT Authentication (Admin)

Use JWT tokens for business owner authentication and admin panel access.

json
# Get JWT tokens
POST /api/platform/token/
{
  "email": "owner@mystore.com",
  "password": "yourpassword"
}

# Response
{
  "access": "eyJ0eXAiOiJKV1QiLCJhbGciOi...",
  "refresh": "eyJ0eXAiOiJKV1QiLCJhbGciOi...",
  "user": { "id": 1, "email": "owner@mystore.com", ... }
}

API Key Authentication (Storefront)

Use API keys for frontend-to-backend communication in your storefront.

http
# Include in request headers
X-API-Key: sk_live_abc123xyz789

# Or as query parameter
GET /api/store/products/?api_key=sk_live_abc123xyz789

Products API

Retrieve product information for your storefront.

List Products

http
GET /api/store/products/

# Query Parameters
?category=electronics     # Filter by category
?search=laptop           # Search products
?min_price=100           # Minimum price
?max_price=1000          # Maximum price
?sort=price_asc          # Sort order
?page=1                  # Pagination
?per_page=20             # Items per page

Response

json
{
  "count": 150,
  "next": "/api/store/products/?page=2",
  "previous": null,
  "results": [
    {
      "id": "prod_abc123",
      "name": "Premium Headphones",
      "slug": "premium-headphones",
      "description": "High-quality wireless headphones...",
      "price": "99.99",
      "compare_price": "149.99",
      "images": [
        {"url": "https://...", "alt": "Product image"}
      ],
      "category": {"id": 1, "name": "Electronics"},
      "in_stock": true,
      "stock_quantity": 50,
      "created_at": "2024-01-15T10:30:00Z"
    }
  ]
}

Cart API

Manage shopping carts for your customers.

Add to Cart

http
POST /api/store/cart/items/
Authorization: Bearer CUSTOMER_JWT_TOKEN

{
  "product_id": "prod_abc123",
  "quantity": 2
}

Get Cart

json
GET /api/store/cart/

# Response
{
  "id": "cart_xyz789",
  "items": [
    {
      "id": "item_123",
      "product": {...},
      "quantity": 2,
      "unit_price": "99.99",
      "total_price": "199.98"
    }
  ],
  "subtotal": "199.98",
  "tax": "16.00",
  "total": "215.98",
  "item_count": 2
}

Orders API

Create and manage customer orders.

Create Order (Checkout)

http
POST /api/store/checkout/
Authorization: Bearer CUSTOMER_JWT_TOKEN

{
  "shipping_address": {
    "street": "123 Main St",
    "city": "New York",
    "state": "NY",
    "postal_code": "10001",
    "country": "US"
  },
  "billing_address": {...},
  "payment_method": "card",
  "notes": "Please leave at door"
}

Order Status Values

pending

Order placed, awaiting confirmation

confirmed

Order confirmed by merchant

processing

Order being prepared

shipped

Order shipped to customer

delivered

Order delivered

cancelled

Order cancelled

Rate Limiting

API requests are rate limited to ensure fair usage and platform stability.

PlanRequests/minuteRequests/day
Free6010,000
Starter12050,000
Pro300200,000
EnterpriseCustomUnlimited

Rate limit headers: Check X-RateLimit-Remaining and X-RateLimit-Reset headers in API responses.

Error Handling

All API errors follow a consistent format.

json
{
  "error": {
    "code": "validation_error",
    "message": "Invalid request data",
    "details": {
      "email": ["This field is required."],
      "password": ["Password must be at least 8 characters."]
    }
  },
  "status": 400
}

Common Error Codes

400Bad Request - Invalid input data
401Unauthorized - Invalid or missing authentication
403Forbidden - Insufficient permissions
404Not Found - Resource does not exist
429Too Many Requests - Rate limit exceeded
500Internal Server Error - Contact support

Need help? Contact support@baasplatform.com or join our Discord community.