Soliddeploy

Build your own returns analysis with the bol API

A monthly overview of all your returns, linked to reasons per EAN and sorted by priority. So you can see which products are really eating into your margin, and why.

Written by Founder of SolidDeploy ·

Built with: Node.js, the bol Retailer API, Google Sheets and a monthly cron.

// how it works

From raw API data to a usable sheet

Four steps you set up once, then run automatically every month. No more manual exports from the Partnerplatform.

  1. 01
    Fetch returns via the bol Retailer APIThe script authenticates via OAuth2 and fetches all returns from the past 30 days. It keeps paginating until it gets an empty response, so you miss nothing.
  2. 02
    Group by EAN and filter on a thresholdAll returns are counted per product. You set the threshold yourself, for example more than 5 returns in 30 days.
  3. 03
    Map return reasons to readable textThe API returns codes such as DEFECT or NOT_AS_EXPECTED. These are converted into Dutch, with the frequency per reason per product.
  4. 04
    Results in a Google Sheet, sorted by priorityOne tab with all products above the threshold, sorted by number of returns. Ready to pass on to your purchasing or content team.

// what you get

A monthly overview your team can act on straight away

No SaaS subscription, no vendor lock-in. Your own pipeline, on your own infrastructure, with data that stays yours.

01

Prioritised list

Products above your threshold, automatically sorted by most returns. Your team knows straight away where to start.

02

Reasons in plain language

No API codes in your sheet, but readable Dutch reasons with the frequency per product.

03

Your own Google Sheet

A familiar interface for your team. Anyone can filter, sort and leave comments without training.

04

Automatic monthly run

Once set up, the script runs on its own. You get a new overview every month without anyone having to look after it.

// what you need

The building blocks for this setup

  • Bol Retailer API access. Request it via the Partnerplatform. It is linked to your seller account.
  • Google Cloud account. To create a service account that can write to your Sheets. The free tier is enough.
  • A Google Sheet. As the destination for the output. Anyone on your team with access can follow along.
  • Server or local machine. A Mac Mini, VPS or cloud scheduler. Something that can run a job every month without your involvement.
  • Development knowledge. Experience with API integrations, OAuth flows and error handling. Or someone who builds this for you.

// what the script does

The data you get back

These are the columns that will appear in your Google Sheet. Everything immediately readable for your team.

  • columnEAN and product name
    To link the product directly to your PIM or content system.
  • columnNumber of returns (30 days)
    The total number of return requests per EAN in the last 30 days. This determines the sort order.
  • columnReturn reasons with frequency
    For example: "product defective (4x), does not meet expectations (2x), too big (1x)". Readable at a glance.
  • columnFulfilment method
    FBR or FBB, so you know whether you or bol handles the return.
  • optionalReturn rate
    Number of returns divided by sales in the same period, if you also have your sales data in Sheets.
  • optionalDate of the run
    Useful if you want to build up history in a separate tab per month.

// how it works under the hood

Seven layers that together build your returns overview

This is the architecture your script follows, from authentication to output. Each layer has its own pitfalls. Most problems arise in the middle layers, not at the start or the end.

Why this matters. If one of these layers fails silently, your sheet keeps filling up, but with the wrong data. That is more dangerous than a crash.

1

Authentication layer with token lifecycle management

The bol API uses the OAuth2 client credentials flow. Your application exchanges credentials for a short-lived bearer token that you send with every request as the Authorization header. The token has a TTL of a few minutes. On longer runs, or if you pause between API calls, the token expires mid-flow. Your script has to track when the token is nearing expiry and request a new one proactively, not reactively after a 401.

Edge case most people miss: bol also applies a different rate limit on the oauth endpoint than on the resource endpoints. If you request a new token for every API call (the "safe" approach), you will be blocked within 5 minutes. Token caching with a 60-second buffer before expiry is the only workable balance, but you do need to make that buffer configurable, because bol adjusts the TTL from time to time.

2

Fetching data with cursor-based pagination

The returns endpoint returns data in chunks via page parameters, not via cursors. Your script paginates until the response signals there is nothing more. That sounds simple, but the API does not provide a total page count or a "has more" flag. You have to detect it yourself: the page contains fewer items than the maximum batch size, or the page is empty. Both conditions need to be handled, because they behave differently in edge cases.

Classic silent error: the script stops after page 1 because it already holds 50 items, or keeps paginating to page 20 because every page returns exactly 50 items while in reality there are only 47 returns (the last page was padded with older records). Result: either you miss 200 returns or you count 150 twice. Neither problem shows up in errors, only in totals that do not match the Partnerplatform when you compare them.

3

Date filtering and window definition

The API offers no server-side filtering by date range for returns, so you have to fetch all returns and filter them yourself. Note: each return has three different date fields (the customer's registration date, the date you received it, the processing date). Which one you use as the anchor determines whether next month's 30 days are comparable with this month's 30 days. Choose wrong and it looks as if returns are falling, when they simply have not been processed yet.

Subtlety: bol occasionally changes the status of returns administratively. A return that fell within your window last month can drop out of it this month because its registration date was updated. This is rare, but it happens. If you want to build up history, you have to decide: freeze snapshots (reproducible but sometimes outdated) or run live queries (accurate, but last month's figures change). Both work, but you have to choose explicitly, otherwise you end up with inconsistencies.

4

Return reason normalisation and mapping table

The API returns two fields per return: a main reason and a detailed reason. More than 20 combinations are possible. Some combinations are almost identical in substance but are counted separately in the API ("not what I expected" vs "does not match description"). Map them 1 to 1 and you get an unreadable list per product. Group them too aggressively and you lose the nuance your team needs to take action. The balance lies somewhere around 8 to 10 categories, but those differ per product category: for clothing, sizing is crucial; for electronics, it is defects.

What many people overlook: bol quietly adds new reason codes without any deprecation warning. Your mapping needs a default for unknown codes plus logging, otherwise your script crashes or new codes slip into your data unnoticed as "other". Both are bad. And you cannot let your script crash either, because then you have no data for that month. So: graceful degradation plus monitoring, not just a throw.

5

Aggregation and enrichment per product

Per EAN you want more than just a counter. You want: total number of returns, which reasons occur, frequency per reason, and ideally the product name and category too. The product name is not included in the returns response by default, so you have to enrich it via a separate endpoint or your own PIM. That doubles the number of API calls and brings you closer to rate limits. Caching per EAN across multiple runs is necessary, but then you have to handle invalidation when product names change. A product with 8 returns, 6 of them for defects, is a different conversation from 8 returns with 8 different reasons, so that nuance needs to come through clearly in your output.

6

Google Sheets batch writes and rate limits

Sheets has its own authentication flow via a service account with scoped permissions. That account gets access to specific sheets by sharing them explicitly. The pitfall lies in the API limits: the default quota is 60 write requests per user per minute and 300 per project per minute. If you do a separate update per row, you hit the limit within 2 minutes with a normal catalogue. You want to do batch writes with the values.batchUpdate endpoint, but those have a different payload structure from individual updates and the limits per batch are configured differently.

Hidden gotcha: if you overwrite a tab, you have to clear the old data first, otherwise old rows remain at the bottom when the new dataset is shorter. But clear plus write is two API calls, so you double your rate limit usage. The elegant solution is a range-specific update that overwrites exactly, but then you need to know in advance how many rows you are going to write. That sounds trivial until you notice that your aggregation step is dynamic and sometimes returns 47 rows and sometimes 312.

7

Scheduling, idempotency and error handling

Running monthly means that if something goes wrong, you only notice a month later. Or worse, you never notice because the sheet was updated with partial data. Good error handling means: your script knows its own baseline (for example 50 to 500 returns per month), alerts on deviations, and is idempotent so a restart halfway through does not produce duplicate data. That last part is not trivial, because sheets have no transactions. You need an intermediate layer (staging tab, lock file or database) that guarantees you never end up with a half-written state in your production tab.

Where most setups fail: the happy path works after a day of building. What is missing is observability. If your script quietly returns 0 returns in month 3 (because the token refresh logic failed after a bol API update), for example, your sheet is empty and your team thinks there are no problems. It is exactly those false negatives that are expensive. Alerting on deviations, structured logging and a heartbeat check are not nice-to-haves, they are half the work.

// integrating with other systems

This script is a starting point, not an end point

Once you have the data from bol, you connect it to what you already use. A few common combinations.

returnless

Returns portal integration

If you use Returnless for your bol returns, fetch the data from Returnless alongside the bol API. That way you see per product not only the bol return reason, but also the extra context customers fill in on the returns form.

fulfilment

WMS or fulfilment portal

Fulfilment tools such as Picqer, GoedGepickt, Channeldock or MyParcel often have their own returns API. Connect it to the same script so you also know what physically comes in, including the condition of the product on receipt.

slack

Slack notification per run

Add a Slack webhook that sends a message to a channel after each monthly run with the top 5 products of that month. So your team does not have to open anything to see the key signals.

database

Supabase or Postgres for history

Google Sheets is fine for the monthly overview, but for trend analysis across several months a real database works better. Write the same data to a database as well and you can pull returns per month per EAN in seconds.

reviews

Review data per product

Combine the returns data with your product reviews. If a product with many returns also has low reviews with specific complaints, you know straight away where to start improving.

ads

Advertising pause trigger

Connect to the bol Advertising API: products with a return rate above a threshold (for example 20 per cent) get a flag so you can pause them in Sponsored Products. Otherwise you are paying for clicks that cost you money.

// maintenance

What to keep an eye on

API credentials can be revoked

If someone on your team deletes the API key in the Partnerplatform, the script stops working. Put this on the checklist for staff changes.

Keep the API version up to date

Bol regularly deprecates old API versions. Keep an eye on the developer changelog and upgrade within 12 months of a new release.

Restart cron after a machine restart

If you run the script locally on a Mac: check after a reboot whether the cron is still active. A VPS is more stable for this.

Further reading

What is the first thing we should tackle?

Tell us about a process that takes too long, an agent you have in mind or an opportunity you have not got round to yet. We show you what it delivers and how it fits your business.