← Back to case studies

Integrations

Invoice generation automation (Mirakl + GreenInvoice)

Automated invoice creation system connecting Mirakl marketplace orders to GreenInvoice accounting software — running on GCP Cloud Run with full logging, error handling, and Google Sheets record-keeping.

Updated Jan 2026 By Shahzeb

Highlights

  • Real-time invoice generation when Mirakl orders are detected
  • Deployed on GCP Cloud Run for reliability and auto-scaling
  • Complete logging and Google Sheets backup for audit trails
Invoice generation automation (Mirakl + GreenInvoice)

The problem

The client operated a multi-marketplace business using Mirakl, processing hundreds of orders daily. Their invoicing workflow was manual and error-prone:

  • Orders came through Mirakl but invoices had to be manually created in GreenInvoice
  • Delays in invoice generation caused accounting headaches and cash flow issues
  • Manual data entry led to frequent errors (wrong amounts, missing details, duplicate invoices)
  • No central record of which orders had been invoiced
  • Operations team spent hours daily on repetitive invoice creation

They needed a reliable automation that would detect Mirakl orders and immediately generate accurate GreenInvoice records.

The solution: Event-driven invoice automation

We built a serverless automation system that bridges Mirakl and GreenInvoice:

How it works:

  1. Order detection: System polls Mirakl API for new/updated orders (or uses webhooks if available)
  2. Data validation: Extracts order details and validates required fields
  3. Invoice creation: Calls GreenInvoice API to generate invoice with correct line items, amounts, and customer details
  4. Logging: Records the operation in Google Sheets for audit trail and ops visibility
  5. Error handling: Retries failed operations with exponential backoff, alerts on persistent failures
Invoice automation architecture diagram

GCP Cloud Run deployment

The system runs as a containerized service on GCP Cloud Run:

Why Cloud Run?

  • Serverless: No infrastructure to manage, auto-scales based on load
  • Cost-efficient: Only pay when processing orders (scales to zero when idle)
  • Fast cold starts: Invocation latency suitable for near-real-time processing
  • Easy deployment: Container-based, simple CI/CD integration

Trigger mechanism:

Two deployment modes supported:

  • Option 1 (Webhook): Mirakl webhook triggers Cloud Run endpoint directly
  • Option 2 (Scheduled polling): Cloud Scheduler triggers Cloud Run every 10 minutes to check for new orders

The client chose Option 2 for reliability (no dependency on webhook delivery).

Logging and record-keeping

Complete operational visibility through multi-layered logging:

1. GCP Cloud Logging

  • All requests, API calls, and errors logged to GCP Cloud Logging
  • Structured logs for easy filtering and debugging
  • Retention policies for compliance

2. Google Sheets Record

Every processed order is logged to a shared Google Sheet with:

  • Timestamp of processing
  • Mirakl order ID
  • GreenInvoice invoice ID
  • Order amount and customer details
  • Status (success, failed, retrying)
  • Error message (if applicable)

This provides a human-readable audit trail that ops teams can check without accessing logs.

Benefit: Finance team can cross-reference Mirakl orders with GreenInvoice invoices directly from the Google Sheet, ensuring nothing slips through the cracks.

Error handling and retries

Production-grade error handling ensures reliability:

Retry logic:

  • Transient failures (network issues, API rate limits) are retried with exponential backoff
  • Maximum 3 retry attempts per order
  • Failed orders marked in Google Sheets for manual review

Validation checks:

  • Order data validated before calling GreenInvoice (missing fields, invalid amounts, etc.)
  • Duplicate detection: checks if invoice already exists for the order ID
  • Amount reconciliation: ensures Mirakl order total matches GreenInvoice invoice total

Alerting:

  • Persistent failures trigger email alerts to ops team
  • Daily summary report of processing stats (orders processed, success rate, errors)

Tech stack

  • APIs: Mirakl API, GreenInvoice API, Google Sheets API
  • Language: Python (Flask for HTTP endpoint)
  • Deployment: Docker container on GCP Cloud Run
  • Scheduling: GCP Cloud Scheduler (10-minute intervals)
  • Logging: GCP Cloud Logging + Google Sheets
  • Monitoring: GCP Cloud Monitoring for uptime and error rates

Outcome

The automation transformed invoice management from a manual bottleneck into a reliable, hands-off system:

Time savings:

  • Eliminated ~2-3 hours daily of manual invoice creation
  • Ops team shifted focus from data entry to exception handling

Accuracy improvements:

  • Zero data entry errors (automated extraction from Mirakl)
  • No duplicate invoices or missed orders
  • Amount discrepancies caught before invoice generation

Operational visibility:

  • Real-time visibility via Google Sheets dashboard
  • Clear audit trail for accounting and compliance
  • Proactive alerts when issues occur

The system now processes hundreds of invoices daily with minimal human intervention, running reliably since deployment with 99.8% success rate.

Want something like this?

Tell me your stack + what you want automated. I’ll reply with a simple plan.

WhatsApp