Skip to main content

Live article:

  • FAQ
  • How can I export all invoices for all spaces for accounting?

You can utilize our Management API to consume your information, including your invoices. Below you can find a Node.js script that uses our Storyblok JavaScript SDK to consume the endpoint of the management API. All you need to do is to replace YOUR_OAUTH_TOKEN with your own oauth token and you will receive a invoice-{timestamp}.csv in the folder.


npm i --save json2csv
npm i --save storyblok-js-client


const StoryblokClient = require('storyblok-js-client')
const json2csv = require('json2csv').parse;
const fs = require('fs')

const Storyblok = new StoryblokClient({
  oauthToken: 'YOUR_OAUTH_TOKEN'

const start = async () => {
  // load space overview list
  let spacesList = await Storyblok.get(`spaces/`)
  // build requests for invoices for all spaces
  let invoiceRequests = [] => {
  // execute requests and filter invoices to actual paid invoices (tatal != 0)
  let invoices = []
  let invoiceResponses = await Promise.all(invoiceRequests)
  invoiceResponses.forEach(response => {
    invoices = invoices.concat(
  invoices = invoices.filter(invoice => {
    return !== '0.0'

  try {
    let fields = Object.keys(invoices[0])
    let csv = json2csv(invoices, { fields })

    fs.writeFileSync(`./invoices-${}.csv`, csv);
  } catch (err) {



Save the above script as index.js and make sure the dependencies are installed before you run the following command:

node index.js