The problem
The client operated a custom products business on Amazon where each order required personalization details (names, messages, design preferences). The workflow was manual and error-prone:
- Manual order review: Team members had to log in, pull orders, and copy customer personalization details
- PII restrictions: Amazon's standard APIs don't expose customer names, addresses, or custom messages without special access
- Production delays: Forwarding details to the production team was done via spreadsheets or manual messages
- Delivery coordination: Once products were ready, coordinating with delivery partners required more manual steps
- Human errors: Typos, missed details, and timing issues caused delays and customer complaints
The client needed an automated system that could securely access customer data, extract customization details, and coordinate production + delivery without manual intervention.
Step 1: Securing PII access
Amazon's SP-API requires explicit approval to access Personally Identifiable Information (PII). We navigated the approval process:
Restricted Data Token (RDT) Setup
- Applied for Restricted Data Token (RDT) access via Amazon Seller Central
- Documented the business use case: custom product personalization
- Implemented secure handling protocols for customer data (encryption at rest, limited access, audit logs)
- Received approval and configured SP-API credentials with PII permissions
Key requirement: Amazon requires clear documentation of why PII access is needed and how data will be protected. We provided detailed use cases and security measures to get approved quickly.
With RDT access, we could now programmatically retrieve:
- Customer names (for personalized products)
- Shipping addresses (for delivery coordination)
- Custom order details/messages (the personalization instructions)
Step 2: Automating custom order extraction
Once PII access was secured, we built an automated order processing pipeline:
Order Monitoring
- Scheduled SP-API pulls every 15 minutes to fetch new orders
- Filtered for orders requiring customization (specific SKUs/product lines)
- Extracted customer personalization details from order item notes and custom fields
Data Parsing
- Parsed custom order details: names, messages, design choices, font preferences, etc.
- Validated data completeness (flagged orders with missing information)
- Normalized formats (e.g., date formats, capitalization) for production consistency
Sample order extraction flow:
import requests
from sp_api.api import Orders
from sp_api.base import Marketplaces
# 1. Fetch new orders
def fetch_custom_orders():
orders_api = Orders(credentials=sp_credentials, marketplace=Marketplaces.DE)
# Get orders from last 15 minutes
new_orders = orders_api.get_orders(
CreatedAfter=(datetime.now() - timedelta(minutes=15)).isoformat(),
OrderStatuses=['Unshipped']
)
return [order for order in new_orders if requires_customization(order)]
# 2. Extract custom details with RDT
def extract_customization_details(order_id):
# Request RDT for this order
rdt_token = get_restricted_data_token(order_id)
# Fetch order items with PII access
order_details = orders_api.get_order_items(
order_id,
headers={'x-amz-access-token': rdt_token}
)
# Parse custom fields
customization = {
'customer_name': order_details['BuyerInfo']['BuyerName'],
'personalization_text': order_details['ItemCustomization']['Message'],
'design_preference': order_details['ItemCustomization']['DesignOption']
}
return customization
Security note: RDT tokens expire quickly (typically 1 hour). We implemented token refresh logic and stored tokens securely in environment variables, never in code or logs.
Step 3: Forwarding to production team
Once order details were extracted and validated, we automated the handoff to the production team:
Production System Integration
- API integration: If the production team had an API (e.g., internal manufacturing system), we pushed orders directly via REST API
- Email forwarding: For teams without APIs, we generated formatted emails with order details and sent them automatically
- Spreadsheet export: As a fallback, we populated Google Sheets with order details for manual review if needed
Order Formatting
We created production-ready formats that included:
- Order ID + Amazon order number
- Customer name and personalization text
- Design/product specifications
- Deadline (based on promised delivery date)
- Shipping address (for production planning)
Example production email:
Subject: [URGENT] New Custom Order #12345 - Due: Jan 25, 2026 Order ID: 12345-6789012-3456789 Customer: Max Mustermann Product: Personalized Coffee Mug Customization Details: - Text: "Happy Birthday Sarah!" - Font: Script Style - Color: Blue Ship to: Berlin, Germany Promised Delivery: Jan 28, 2026 Production Deadline: Jan 25, 2026 (3 days) [Link to full order details]
Pro tip: We added priority flags based on delivery deadlines. Orders with tight timelines were flagged as "URGENT" to help production prioritize.
Step 4: Delivery partner integration
The final automation step was coordinating with delivery partners once products were ready:
Shipment Creation
- Production team marked orders as "ready to ship" in the system
- Automated trigger created shipment requests with delivery partners (DHL, DPD, etc.)
- Generated shipping labels automatically using partner APIs
Tracking Updates
- Received tracking numbers from delivery partners
- Automatically updated Amazon orders with tracking info via SP-API
- Sent confirmation emails to customers (optional)
Delivery API integration example:
def create_shipment(order_id, delivery_partner='DHL'):
# Get order details
order = get_order_details(order_id)
# Create shipment with delivery partner
shipment_request = {
'recipient': order['shipping_address'],
'package_weight': order['product_weight'],
'service_level': 'express' if order['is_urgent'] else 'standard'
}
# Call delivery partner API
response = delivery_api.create_shipment(shipment_request)
tracking_number = response['tracking_number']
# Update Amazon order
update_amazon_tracking(order_id, tracking_number, carrier='DHL')
return tracking_number
Multi-Partner Support
We integrated with multiple delivery partners:
- DHL: Primary partner for Germany
- DPD: Backup/alternative for certain regions
- Hermes: For lightweight packages
The system automatically selected the best partner based on destination, package size, and delivery speed requirements.
Error handling and guardrails
Custom order workflows are sensitive — mistakes mean unhappy customers. We built safeguards:
1. Validation Checks
- Flagged orders with missing customization details (incomplete forms)
- Alerted on suspicious patterns (profanity, unusually long text)
- Validated addresses before forwarding to production
2. Manual Override
- Built a simple dashboard where ops team could review flagged orders
- Allowed manual approval before forwarding to production
- Maintained audit logs of all overrides
3. Retry Logic
def forward_to_production_with_retry(order, max_retries=3):
for attempt in range(max_retries):
try:
send_to_production(order)
log_success(order['id'])
return True
except Exception as e:
log_error(order['id'], e)
if attempt == max_retries - 1:
alert_ops_team(order['id'], e)
return False
time.sleep(2 ** attempt) # Exponential backoff
4. Alerts
- Slack notifications for failed order processing
- Daily summary reports of orders processed
- Alerts for orders approaching production deadlines
Architecture and tech stack
- SP-API: Order fetching with Restricted Data Token (RDT) for PII access
- Python: Core automation scripts + data parsing
- PostgreSQL: Order tracking and audit logs
- Cron / Cloud Scheduler: Every 15 minutes order pulls
- Production API: REST API integration for order forwarding
- Delivery partner APIs: DHL, DPD, Hermes integrations
- Slack: Real-time alerts for ops team
- Simple dashboard: Django-based UI for manual review/overrides
System architecture:
Outcome
The automated system transformed the client's custom order operations:
Before Automation
- Manual order review: 15-20 minutes per order
- Frequent errors in customization details (typos, missed fields)
- Production delays due to slow handoffs
- Delivery coordination required manual tracking and updates
- Customer complaints about slow processing and errors
After Automation
- Order processing time: Reduced from 15-20 minutes to under 1 minute (automated)
- Error rate: Dropped by ~80% (validation + standardization)
- Production handoff: Instant forwarding vs. hours of manual coordination
- Delivery updates: Automatic tracking updates to Amazon (customers happy)
- Team capacity: Ops team freed up to handle customer service and growth initiatives
Key Wins
- Processed 500+ custom orders/month without manual intervention
- Improved delivery speed by 2-3 days on average
- Reduced customer complaints about order errors by 70%
- Enabled the client to scale custom product offerings without hiring additional ops staff
Client feedback: "This system paid for itself in the first month. We can now handle 3x the order volume with the same team, and customers love the faster turnaround."
What's next
We continue to enhance the system with:
- ML-based text validation: Automatically detect and suggest corrections for common typos in customization text
- Inventory integration: Check material availability before confirming production timelines
- Dynamic deadline calculation: Smarter production scheduling based on current workload
- Multi-marketplace expansion: Extending to UK, FR, and IT marketplaces
- Customer preview system: Allow customers to see mockups before production (future enhancement)
Want something like this?
Tell me your stack + what you want automated. I’ll reply with a simple plan.