Skip to main content

Live article:

  • FAQ
  • How to get list of folders from Management API

If you want to get only the folder associated with stories, you can do that using the Storyblok management API like this;

Firstly, you need to initialize the Storyblok client with a personal access token. You can do that by going to the MyAccount section {1} and Personal access tokens {2}. Click Generate new Token {3} button.

Storyblok user profile and management API

Storyblok user profile and management API

Copy the token immediately because once that page is refreshed, you won’t be able to do that again, and keep it in a safe place. Ideally, in a .env file.

Initialize the Storyblok client and fetch the folders from your space.

Copy to clipboard
      const Storyblok = new StoryblokClient({
  oauthToken: {YOUR OAUTH TOKEN},

 const res = await Storyblok.get("spaces/126850/stories/", { //126850 is the space ID.
    folder_only: true,

The response data contains an array of the folder each having the data structure below.

Copy to clipboard
  alternates: []
  can_not_view: false
  content_summary: {}
  content_type: ""
  created_at: "2022-04-09T23:02:05.531Z"
  default_root: ""
  deleted_at: null
  disble_fe_editor: false
  expire_at: null
  first_published_at: null
  full_slug: "folder3"
  group_id: "a2decefd-8ae6-49be-a31f-d2afef91f43f"
  id: 123225125
  is_folder: true
  is_startpage: false
  last_author: {id: 95728, userid: '', friendly_name: '', avatar: null}
  name: "folder3"
  parent_id: 0
  path: null
  pinned: false
  position: -50
  publish_at: null
  published: false
  published_at: null
  release_ids: []
  slug: "folder3"
  sort_by_date: null
  stage: null
  tag_list: []
  unpublished_changes: false
  updated_at: "2022-04-09T23:02:05.531Z"
  uuid: "d6e15afe-a3b2-4dfe-85c0-0b89e4c9051f"