Supply Chain Management Use Case
Track orders, products, and origins across your supply chain using Coolset APIs.
Overview
Manage your end-to-end supply chain with complete visibility from source to delivery. Track orders, monitor product flows, and ensure traceability.
Common Workflows
1. Order Management
Create and track purchase and sale orders
2. Product Tracking
Monitor product movements through the value chain
3. Origin Verification
Document and verify product origins
4. Value Chain Mapping
Map complete supply chain relationships
Supply Chain Flow
Workflow: Complete Order Lifecycle
# 1. Create a purchase order
curl -X POST https://developers-scranton.coolset.com/api/orders/ \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"identifier": "PO-2024-001",
"type": "purchase",
"supplier": "Supplier Ltd",
"status": "pending"
}'
# 2. Add products to order
curl -X POST https://developers-scranton.coolset.com/api/orders/123/order-items/ \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"product_id": 456,
"quantity": 1000,
"unit": "kg"
}'
# 3. Link to origin
curl -X POST https://developers-scranton.coolset.com/api/origins/ \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Brazilian Farm A",
"country": "BR",
"region": "Minas Gerais",
"geolocation": {
"latitude": -19.9167,
"longitude": -43.9345
}
}'
# 4. Update order status
curl -X PATCH https://developers-scranton.coolset.com/api/orders/123/ \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"status": "in_transit"
}'
Complete Example: Order Management System
import requests
from datetime import datetime
class CoolsetSupplyChain:
def __init__(self, api_token):
self.base_url = "https://developers-scranton.coolset.com/api"
self.headers = {
"Authorization": f"Bearer {api_token}",
"Content-Type": "application/json"
}
def create_purchase_order(self, supplier, items):
"""Create a new purchase order with items"""
# Create order
order = requests.post(
f"{self.base_url}/orders/",
headers=self.headers,
json={
"identifier": f"PO-{datetime.now().strftime('%Y%m%d-%H%M')}",
"type": "purchase",
"supplier": supplier,
"status": "pending"
}
).json()
# Add items
for item in items:
requests.post(
f"{self.base_url}/orders/{order['id']}/order-items/",
headers=self.headers,
json=item
)
return order
def track_order_status(self, order_id):
"""Get current order status and items"""
order = requests.get(
f"{self.base_url}/orders/{order_id}/",
headers=self.headers
).json()
items = requests.get(
f"{self.base_url}/orders/{order_id}/order-items/",
headers=self.headers
).json()
return {
"order": order,
"items": items['results']
}
def update_order_status(self, order_id, new_status):
"""Update order status"""
return requests.patch(
f"{self.base_url}/orders/{order_id}/",
headers=self.headers,
json={"status": new_status}
).json()
def map_value_chain(self, product_id):
"""Get complete value chain for a product"""
value_chains = requests.get(
f"{self.base_url}/value-chains/",
headers=self.headers,
params={"product_id": product_id}
).json()
return value_chains['results']
# Usage
sc = CoolsetSupplyChain("YOUR_API_TOKEN")
# Create order
order = sc.create_purchase_order(
supplier="Coffee Co-op Brazil",
items=[
{
"product_id": 456,
"quantity": 5000,
"unit": "kg",
"price_per_unit": 4.50
}
]
)
print(f"Created order: {order['identifier']}")
# Track order
status = sc.track_order_status(order['id'])
print(f"Current status: {status['order']['status']}")
# Update status
sc.update_order_status(order['id'], "in_transit")