Tavola Romagna REST API — Base URL:
/api
All endpoints return JSON. Authenticated endpoints require a valid session_token cookie. Errors follow the shape { error: string }.
- Health & System
- Authentication
- Products & Catalog
- Producers
- Cart
- Checkout & Orders
- Subscriptions
- Pricing Engine
- Delivery
- Surplus / Food Rescue
- Gift Boxes
- Events
- Recipes
- Recommendations
- Community & Forum
- Adoptions
- Cooperatives
- Tourism
- Traceability
- Reviews
- Notifications
- Loyalty
- Coupons
- Search
- Uploads & Storage
- GDPR & Privacy
- Newsletter
- Admin
- Producer Analytics
- Webhooks
- Messaging
- Cron Jobs
- Miscellaneous
Health check endpoint. Returns service status and integration connectivity.
Auth: None
Response: 200
{
"status": "healthy",
"services": {
"database": { "status": "up", "latencyMs": 5 },
"stripe": { "status": "up" },
"email": { "status": "mock" }
}
}Returns localized message dictionary for the detected/requested locale.
Auth: None
Query: ?locale=en (optional, defaults to Accept-Language detection)
Platform-wide metrics dashboard data.
Auth: Required
Register a new user account.
Auth: None
Body:
{
"email": "user@example.com",
"password": "securepass",
"name": "Mario Rossi"
}Response: 201 — Sets session_token cookie
Authenticate and create a session.
Auth: None
Body:
{
"email": "user@example.com",
"password": "securepass"
}Response: 200 — Sets session_token cookie
Destroy the current session.
Auth: Required
Response: 200 — Clears session_token cookie
Get the current authenticated user.
Auth: Required
Response: 200 — User object with producer relation if applicable
Read or update the user profile.
Auth: Required
Initiate a password reset flow.
Auth: None
Body: { "email": "user@example.com" }
Manage saved delivery addresses.
Auth: Required
List active sessions or revoke a session.
Auth: Required
MFA setup and verification.
Auth: Required
OAuth login (Google / Apple).
Auth: None
Body: { "provider": "google", "token": "..." }
List all active products with filtering.
Auth: None
Query: ?category=formaggi&organic=true&featured=true&search=parmigiano
Create a new product (producer only).
Auth: Required (producer)
Full-text search across products, producers, recipes.
Auth: None
Query: ?q=search+term&category=vino
Seasonal product availability calendar.
Auth: None
List all approved producers.
Auth: None
Producer registration and Stripe Connect onboarding flow.
Auth: Required
POST Body:
{
"businessName": "Azienda Agricola Rossi",
"partitaIva": "IT12345678901",
"specialty": "formaggi",
"categories": ["formaggi", "salumi"]
}Get the current user's cart items.
Auth: Required
Add an item to the cart.
Auth: Required
Body: { "productId": "...", "quantity": 2 }
Remove item(s) or clear the cart.
Auth: Required
Body: { "productId": "..." } or { "clear": true }
Process a checkout. Creates an order, applies coupons/loyalty, triggers Stripe payment.
Auth: Required
Body:
{
"deliveryAddress": "Via Roma 1",
"deliveryCity": "Forlì",
"deliveryPostalCode": "47121",
"deliverySlot": "2025-01-15 09:00-12:00",
"couponCode": "WELCOME10",
"notes": "Citofono Rossi"
}Split checkout — creates separate sub-orders per producer for multi-producer carts.
Auth: Required
List user orders or update order status.
Auth: Required
Request a refund for an order/payment.
Auth: Required
Body: { "paymentIntentId": "pi_...", "amount": 1500, "reason": "requested_by_customer" }
Manage subscription boxes (create, pause, cancel, update preferences).
Auth: Required
Dietary profile for personalized box composition.
Auth: Required
GET /api/subscriptions/[id]/composition · POST /api/subscriptions/[id]/composition · PATCH /api/subscriptions/[id]/composition
View/manage the composition of an upcoming delivery box.
Auth: Required
Submit satisfaction feedback for a delivered box.
Auth: Required
A/B testing for subscription box variants.
Auth: Required (admin)
Evaluate dynamic pricing for a product given context (quantity, delivery slot, expiry).
Auth: None
Body:
{
"productId": "...",
"quantity": 5,
"deliverySlotId": "...",
"daysToExpiry": 2
}Response:
{
"unitOriginalPrice": 8.50,
"unitDynamicPrice": 6.80,
"originalPrice": 42.50,
"dynamicPrice": 34.00,
"savings": 8.50,
"appliedRules": [
{ "name": "Expiry markdown", "type": "expiry_markdown", "reason": "..." }
]
}List or create pricing rules.
Auth: Required (admin)
Update or delete a pricing rule.
Auth: Required (admin)
Trigger a scan for near-expiry products and apply automatic markdowns.
Auth: Required (admin/cron)
Available delivery time slots by zone.
Auth: None
Query: ?zone=forli-centro
Validate a delivery address and return the matching zone/fee.
Auth: None
Body: { "city": "Forlì", "postalCode": "47121" }
List active surplus listings or create a new surplus offer (producer).
Auth: Required
Browse or create gift box templates.
Auth: Required
Purchase a gift or list gift orders.
Auth: Required
Unbox a gift using a token.
Auth: None
Query: ?token=unboxing-token-uuid
List or create farm events/experiences.
Auth: POST requires auth
Get or update an event.
Auth: PUT requires auth
Book an event.
Auth: Required
Body: { "quantity": 2 }
List or create recipes.
Auth: None (POST may require auth)
AI-powered recipe generation from available ingredients.
Auth: None
Build a shopping basket from a recipe's ingredients.
Auth: None
Body: { "recipeId": "...", "servings": 4 }
Get or generate a weekly meal plan.
Auth: None
Get personalized product recommendations.
Auth: Optional (better results when authenticated)
Query: ?productId=...&recipeId=...
Returns sections: also_bought, similar, personal, trending, contextual, recipe_ingredients.
List or create forum posts.
Auth: POST requires auth
Get a forum post with comments.
Auth: None
Add a comment.
Auth: Required
Like a post.
Auth: Required
List or create adoption programs (olive trees, vineyards, etc.).
Auth: POST requires auth
Adopt a tree/vine.
Auth: Required
List or create cooperatives.
Auth: POST requires auth
CRUD for a single cooperative.
Auth: Required
GET /api/cooperatives/[id]/members · POST /api/cooperatives/[id]/members · DELETE /api/cooperatives/[id]/members
Manage cooperative membership.
Auth: Required
Agri-tourism itinerary management.
Auth: POST requires auth
Hospitality partner management.
Auth: POST requires auth
Ship products home (for tourists visiting the region).
Auth: Required
Full supply chain timeline for a product.
Auth: None
Record a supply chain event.
Auth: Required
Manage producer certifications (DOP, IGP, Bio).
Auth: Required
Verify a blockchain-anchored traceability hash.
Auth: None
List or submit product reviews.
Auth: Required
List or mark notifications as read.
Auth: Required
Manage notification channel preferences (email, push, WhatsApp, in-app).
Auth: Required
Server-Sent Events (SSE) stream for real-time notifications.
Auth: Required
View loyalty account/points or earn/redeem points.
Auth: Required
List or create coupon codes.
Auth: Required (admin)
Validate a coupon code against an order.
Auth: Required
Body: { "code": "WELCOME10", "subtotal": 45.00 }
Full-text product/producer search.
Auth: None
Query: ?q=piadina&category=pane
Upload images via Vercel Blob or Cloudinary.
Auth: Required
POST: multipart/form-data with file field
Read or record user consent (analytics, marketing, etc.).
Auth: Required
Request or download a full data export.
Auth: Required
Request or confirm account deletion.
Auth: Required
Subscribe to the newsletter.
Auth: None
Body: { "email": "...", "name": "...", "language": "it" }
Unsubscribe.
Auth: None
Body: { "email": "..." }
All admin endpoints require authentication with an admin role.
| Endpoint | Methods | Purpose |
|---|---|---|
/api/admin/stats |
GET | Aggregated platform statistics |
/api/admin/producers |
GET, PATCH | Producer approval/management |
/api/admin/applications |
GET, POST | Producer application review |
/api/admin/reviews |
GET, DELETE | Review moderation |
/api/admin/operations |
GET, PATCH | Operations dashboard |
/api/admin/payouts |
GET, POST | Producer payout management |
/api/admin/drivers |
GET, POST | Delivery driver management |
/api/admin/jobs |
GET, POST | Background job management |
/api/admin/metrics |
GET, POST | Platform metrics |
/api/admin/support |
GET, POST | Support ticket management |
/api/admin/audit |
GET | Security audit log |
All endpoints require producer authentication.
| Endpoint | Methods | Purpose |
|---|---|---|
/api/producer/analytics |
GET | Dashboard overview |
/api/producer/analytics/alerts |
GET, PATCH | Price/stock alerts |
/api/producer/analytics/benchmarks |
GET, POST | Category benchmarks |
/api/producer/analytics/cohorts |
GET | Customer cohort analysis |
/api/producer/analytics/forecast |
GET | Revenue forecasting |
/api/producer/analytics/lifecycle |
GET | Product lifecycle stages |
/api/producer/analytics/report |
GET | Downloadable reports |
Stripe webhook receiver. Handles checkout.session.completed, payment_intent.succeeded, invoice.paid, etc.
Auth: Stripe signature verification
WhatsApp Business API webhook verification and message ingestion.
Auth: WhatsApp verification token
Register a push notification subscription.
Auth: Required
Send a push notification.
Auth: Required
Send a WhatsApp message.
Auth: Required
Scheduled via Vercel Cron (vercel.json):
| Endpoint | Schedule | Purpose |
|---|---|---|
GET /api/cron/analytics |
Daily 2:00 AM | Compute daily sales, benchmarks, cohorts |
GET /api/cron/pricing-scan |
Every 6 hours | Scan for expiry markdowns and price adjustments |
GET /api/cron/surplus-scan |
Daily 8:00 AM | Identify new surplus opportunities |
GET /api/cron/notification-digest |
Monday 9:00 AM | Send weekly notification digest emails |
GET /api/cron/menu-generation |
On demand | Generate weekly menu suggestions |
Innovation portfolio / experimental features listing.
Auth: None
Federated product listing for partner platforms.
Auth: None
Seed the database with sample data (development only).
Auth: None
Manage product inventory levels.
Auth: Required
Subscribe to stock-back-in notifications.
Auth: Required
| Scope | Limit | Window |
|---|---|---|
| Auth endpoints | 5 requests | 15 minutes |
| General API | 100 requests | 1 minute |
| Webhooks | 50 requests | 1 minute |
| Admin | 30 requests | 1 minute |
| Uploads | 10 requests | 1 minute |
Rate limit headers: X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After (on 429).
All errors follow a consistent shape:
{ "error": "Human-readable error message in Italian" }| Status | Meaning |
|---|---|
400 |
Validation error |
401 |
Not authenticated |
403 |
Forbidden (wrong role) |
404 |
Resource not found |
405 |
Method not allowed |
415 |
Unsupported content type |
429 |
Rate limited |
500 |
Internal server error |