{"openapi":"3.0.3","info":{"title":"Towrilla API","description":"REST API for Towrilla towing equipment store. Use these endpoints to integrate with the product catalog, manage orders, and build mobile apps.","version":"1.0.0","contact":{"name":"Towrilla","url":"https://towrilla.ca"}},"servers":[{"url":"/api","description":"Production API"}],"paths":{"/products":{"get":{"summary":"List all products","description":"Returns paginated list of active products with optional filters.","parameters":[{"name":"category","in":"query","schema":{"type":"string"},"description":"Filter by category slug"},{"name":"search","in":"query","schema":{"type":"string"},"description":"Search by name or description"},{"name":"minPrice","in":"query","schema":{"type":"number"},"description":"Minimum price filter"},{"name":"maxPrice","in":"query","schema":{"type":"number"},"description":"Maximum price filter"},{"name":"limit","in":"query","schema":{"type":"integer","default":50},"description":"Max results (max 100)"},{"name":"offset","in":"query","schema":{"type":"integer","default":0},"description":"Pagination offset"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"products":{"type":"array","items":{"$ref":"#/components/schemas/Product"}},"total":{"type":"integer"},"limit":{"type":"integer"},"offset":{"type":"integer"}}}}}}}}},"/products/{id}":{"get":{"summary":"Get product details","description":"Returns a single product by ID or slug, including stock and pricing.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"Product ID or slug"}],"responses":{"200":{"description":"Product details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Product"}}}},"404":{"description":"Product not found"}}}},"/categories":{"get":{"summary":"List categories","description":"Returns all product categories with product counts.","responses":{"200":{"description":"Categories list","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Category"}}}}}}}},"/orders":{"post":{"summary":"Create an order","description":"Creates a new order and returns a Square payment link for checkout.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["items","customerName","customerEmail"],"properties":{"items":{"type":"array","items":{"type":"object","properties":{"productId":{"type":"string"},"quantity":{"type":"integer","minimum":1}}}},"customerName":{"type":"string"},"customerEmail":{"type":"string","format":"email"},"phone":{"type":"string"},"shippingAddress":{"type":"string"},"notes":{"type":"string"}}}}}},"responses":{"201":{"description":"Order created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"orderNumber":{"type":"string"},"status":{"type":"string"},"total":{"type":"number"},"paymentUrl":{"type":"string","nullable":true}}}}}},"400":{"description":"Validation error"}}}},"/orders/{id}":{"get":{"summary":"Get order status","description":"Returns order details by ID or order number.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"Order ID or order number"}],"responses":{"200":{"description":"Order details"},"404":{"description":"Order not found"}}}}},"components":{"schemas":{"Product":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"description":{"type":"string"},"price":{"type":"number"},"compareAt":{"type":"number","nullable":true},"sku":{"type":"string"},"stock":{"type":"integer"},"image":{"type":"string","nullable":true},"weight":{"type":"number","nullable":true},"featured":{"type":"boolean"},"active":{"type":"boolean"},"category":{"$ref":"#/components/schemas/Category"}}},"Category":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"description":{"type":"string","nullable":true},"image":{"type":"string","nullable":true}}}}}}