{% extends 'superuser/base_superuser.html' %} {% block title %}E-Commerce API Documentation | ChatLab{% endblock %} {% block documentation_active %}active{% endblock %} {% block workspace %}

1. Authentication & Base URL

All requests sent from our chatbot system to your e-commerce API will be authenticated using a Bearer Token. You will generate this token (API Key) in the chatbot settings and configure your server to validate it.

Authorization: Bearer <YOUR_API_KEY>

2. Connection Test Endpoint

Used by the chatbot dashboard to verify that the connection to your store is working correctly.

GET /api/bot/test/

Expected JSON Response

{ "status": "success", "message": "API is working properly." }

3. Fetch Product Catalog

The chatbot will call this endpoint to fetch your store's live product catalog to recommend items to customers.

GET /api/bot/catalog/

Expected JSON Format

Field Type Description
id String / Int Unique product identifier.
name String The name or title of the product.
price Number The regular price of the item.
discount_price Number The discounted price (if applicable). Send null or 0 if none.
brand String The brand name of the product.
stock Boolean / Number Whether the item is in stock.

Sample Response

{ "status": "success", "products": [ { "id": "1001", "name": "Wireless Noise Cancelling Headphones", "price": 150.00, "discount_price": 120.00, "brand": "AudioTech", "stock": true }, { "id": "1002", "name": "Smart Fitness Watch", "price": 200.00, "discount_price": null, "brand": "FitWear", "stock": false } ] }

4. Create Product Order

When a user confirms they want to buy a product, the chatbot will send a POST request to create the order in your system.

POST /api/bot/order/

Request Payload (Sent by Chatbot)

{ "customer_name": "John Doe", "customer_phone": "+1234567890", "customer_address": "123 Main St, City, Country", "product_id": "1001", "quantity": 1, "notes": "Please deliver in the evening." }

Expected JSON Response

Return the created order ID and a confirmation message that the chatbot will relay to the user.

{ "status": "success", "order_id": "ORD-5592", "message": "Order created successfully. Our team will contact you shortly for delivery." }
{% endblock %}