Magic e-Verse

Spranz Mail Flow - API Requirements

8 views Updated 28 Jan 2026

Purpose

This document describes all API endpoints and configurations needed from the Spranz ERP system to make the automated mail flow work. The n8n workflow processes incoming quote requests via email and generates quotations automatically.

Key features of the flow:

  • Automatically reads incoming emails from a dedicated mailbox
  • Uses AI (Claude) to analyze customer requests and match products
  • Retrieves real-time stock and pricing information from Spranz ERP
  • Generates professional quotations with correct pricing tiers
  • Handles repeat orders by checking order history (no setup costs for returning customers)
  • Escalates complex requests to human team members via WhatsApp

1. User/Customer Data

Why needed: When a customer sends an email requesting a quote, we need to identify who they are in the Spranz system. This allows us to apply the correct pricing, discounts, and credit terms automatically.

Data FieldDescriptionWhy Important
Customer NumberUnique ID in ERPLinks email to customer account
Company NameBusiness nameFor quotation header
Contact PersonMain contactPersonalized communication
EmailEmail addressMatch incoming email to customer
PhonePhone numberFor follow-up calls
AddressBilling/shippingShipping cost calculation
Discount GroupCustomer tierApply correct pricing level
Credit LimitMax order valueFlag large orders for review
Payment TermsNet 30/60/etcInclude on quotation

2. Product Data

Why needed: The AI needs to search and match products based on customer requests. Product details are shown in the quotation.

Data FieldWhy Important
SKU / Article NumberUnique product identifier for ordering
Product NameDisplay name on quotation
DescriptionAI uses this to match customer requests
CategoryFilter products by type
Available ColorsMatch customer color preferences
DimensionsProduct specifications
WeightCalculate shipping costs
Images URLInclude product images in quote
Min. Order QuantityValidate customer quantities

3. Stock/Inventory Data

Why needed: Before quoting, we need to verify the product is available. If not in stock, provide expected delivery date.

Data FieldWhy Important
Available QuantityCan we fulfill the order?
Reserved QuantityAlready allocated to other orders
Expected Restock DateWhen will new stock arrive?
Supplier Lead TimeHow long to get from supplier?

4. Pricing Data

Why needed: Promotional products use tiered pricing - the more you order, the lower the unit price. We need all price breaks to generate accurate quotes.

Data FieldWhy Important
Tiered PricesPrice per 100/250/500/1000/2500/5000 units
Customer-specific DiscountSpecial pricing for this customer
Print/Decoration CostsCost per color/technique
Setup CostsOne-time costs (screens, dies, etc.)
Shipping RatesPer weight/destination zone

5. Print/Decoration Techniques

Why needed: Different products support different printing methods. Each method has different costs, color limits, and positioning options.

Data FieldWhy Important
Available Techniques per ProductScreen print, pad print, laser, embroidery, etc.
Cost per ColorAdditional cost for multi-color prints
Maximum ColorsHow many colors possible per technique
Print PositionsWhere on the product can be printed
Print Area SizeMaximum print dimensions

6. Order History (Return Orders Check)

Why needed: For repeat orders, customers should NOT pay setup costs again. The system checks if this customer has ordered this product with the same print before.

IMPORTANT: Return Order Logic
Check RequiredHas this customer ordered this SKU + same print technique + same artwork before?
If YES (repeat)Waive setup costs, only charge unit price + print costs
If NO (new)Include full setup costs in quotation

Data needed for this check:

  • Customer order history
  • Previous order line items (SKU, technique, artwork reference)
  • Order date (how recent was the last order?)

7. Quotation/Order Management

Why needed: After generating a quote, we need to save it in the ERP so sales can track it.

ActionDescription
Create QuotationStart new quote with customer info
Add Quote LinesAdd products with qty, price, print options
Update StatusDraft → Sent → Accepted → Order
Convert to OrderWhen customer accepts the quote

8. Track & Trace

Why needed: Customers can ask about their order status. The AI agent needs to look this up.

Data FieldDescription
Order StatusIn production, Ready for shipping, Shipped, Delivered
CarrierDHL, UPS, PostNL, etc.
Tracking NumberFor customer to track shipment
Expected Delivery DateWhen will it arrive?

9. Sample Orders

Why needed: Customers often want to see/feel a product before ordering. The system handles sample requests.

Data FieldDescription
Sample PolicyFree, paid, or limited per customer?
Sample LimitMax samples per customer per month
Sample CostIf charged, what is the cost?

Required API Endpoints (17 Total)

These are the endpoints we need from the Spranz ERP. Please provide the URLs and authentication method.

NrEndpointMethodURL from Spranz
1Get Customer (by number or email)GET
2Search ProductsGET
3Get Product DetailsGET
4Check Stock AvailabilityGET
5Get Tiered PricingGET
6Get Print Techniques per ProductGET
7Create QuotationPOST
8Get Order Status / Track TraceGET
9Request SamplePOST
10Create Stock ReservationPOST
11API AuthenticationPOST
12Get Customer Order HistoryGET
13Get InvoicesGET
14Get Business HoursGET
15Submit Discount RequestPOST
16WhatsApp NotificationPOST
17Check Return Orders (no setup costs)GET

Yellow fields: fill in URLs from Spranz after the meeting


Email Configuration

The n8n workflow needs to read incoming emails. We need access credentials for the mailbox.

Option A: Microsoft 365 / Outlook (Recommended)

For Microsoft 365, we need an Azure App Registration with Mail.Read and Mail.Send permissions.

SettingValue
Mailbox Addresse.g. quotes@spranz.de
Azure App (Client) ID
Azure Tenant ID
Client Secret

Option B: IMAP/SMTP

If not using Microsoft 365, provide standard IMAP/SMTP credentials.

SettingValue
IMAP Server
IMAP Port993 (SSL)
SMTP Server
SMTP Port587 (TLS)
Username
Password / App Password

Required Mailbox Folders

These folders should exist in the mailbox. The workflow will move emails between them.

FolderPurpose
InboxNew quote requests arrive here
Quotation DoneSuccessfully processed - quote sent
Awaiting ResponseWaiting for customer reply (clarification needed)
Team EscalationComplex requests forwarded to human team

n8n Workflow Location

Internal URL: http://192.168.1.26:8090/workflow/SpranzMailFlow02

Workflow ID: SpranzMailFlow02

Total nodes: 113